-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from NashTech-Labs/testcases/issues
Testcases/issues
- Loading branch information
Showing
9 changed files
with
101 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
order-service/src/test/java/com/nashtech/order/aggregate/OrdersCommandControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.nashtech.order.aggregate; | ||
|
||
import com.nashtech.common.utils.OrderStatus; | ||
import com.nashtech.order.commands.CreateOrderCommand; | ||
import com.nashtech.order.restapi.OrdersCommandController; | ||
import com.nashtech.order.restapi.request.OrderCreateRequest; | ||
import com.nashtech.order.restapi.response.OrderSummary; | ||
import org.axonframework.commandhandling.gateway.CommandGateway; | ||
import org.axonframework.queryhandling.QueryGateway; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.ArgumentCaptor; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
import static org.hamcrest.Matchers.any; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
class OrdersCommandControllerTest { | ||
|
||
@Mock | ||
private CommandGateway commandGateway; | ||
|
||
@Mock | ||
private QueryGateway queryGateway; | ||
|
||
@InjectMocks | ||
private OrdersCommandController controller; | ||
|
||
public OrdersCommandControllerTest() { | ||
MockitoAnnotations.openMocks(this); | ||
} | ||
|
||
@Test | ||
void createOrder_shouldCreateOrderAndReturnOrderSummary() { | ||
|
||
OrderCreateRequest orderRequest = new OrderCreateRequest("123", 2, "user123"); | ||
|
||
when(commandGateway.send(any(CreateOrderCommand.class))).thenReturn(CompletableFuture.completedFuture(null)); | ||
|
||
OrderSummary result = controller.createOrder(orderRequest); | ||
|
||
assertEquals(OrderStatus.ORDER_PLACED.toString(), result.getOrderStatus()); | ||
assertEquals("Thank you for your order! We’ll let you know as soon as it ships. " + | ||
"You can track your order here,review us here, or shop again here.", result.getMessage()); | ||
|
||
ArgumentCaptor<CreateOrderCommand> commandCaptor = ArgumentCaptor.forClass(CreateOrderCommand.class); | ||
verify(commandGateway).send(commandCaptor.capture()); | ||
CreateOrderCommand sentCommand = commandCaptor.getValue(); | ||
assertEquals(orderRequest.getProductId(), sentCommand.getProductId()); | ||
assertEquals(orderRequest.getUserId(), sentCommand.getUserId()); | ||
assertEquals(orderRequest.getQuantity(), sentCommand.getQuantity()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 0 additions & 81 deletions
81
order-service/src/test/java/com/nashtech/order/restapi/RestTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters