forked from microservices-patterns/ftgo-application
-
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.
Added restaurantName to OrderCreatedEvent and changed to Order Histor…
…y Service to use it
- Loading branch information
Showing
21 changed files
with
147 additions
and
35 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
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
55 changes: 55 additions & 0 deletions
55
.../test/java/net/chrisrichardson/ftgo/cqrs/orderhistory/web/OrderHistoryControllerTest.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,55 @@ | ||
package net.chrisrichardson.ftgo.cqrs.orderhistory.web; | ||
|
||
import io.eventuate.javaclient.commonimpl.JSonMapper; | ||
import net.chrisrichardson.ftgo.common.CommonJsonMapperInitializer; | ||
import net.chrisrichardson.ftgo.cqrs.orderhistory.OrderHistoryDao; | ||
import net.chrisrichardson.ftgo.cqrs.orderhistory.dynamodb.Order; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | ||
import org.springframework.test.web.servlet.setup.MockMvcBuilders; | ||
import org.springframework.test.web.servlet.setup.StandaloneMockMvcBuilder; | ||
|
||
import java.util.Optional; | ||
|
||
import static io.restassured.module.mockmvc.RestAssuredMockMvc.given; | ||
import static org.hamcrest.CoreMatchers.equalTo; | ||
import static org.junit.Assert.*; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class OrderHistoryControllerTest { | ||
|
||
private OrderHistoryDao orderHistoryDao; | ||
private OrderHistoryController orderHistoryController; | ||
|
||
@Before | ||
public void setUp() { | ||
orderHistoryDao = mock(OrderHistoryDao.class); | ||
orderHistoryController = new OrderHistoryController(orderHistoryDao); | ||
} | ||
|
||
@Test | ||
public void testGetOrder() { | ||
when(orderHistoryDao.findOrder("1")).thenReturn(Optional.of(new Order("1", null, null, null, null, "Ajanta"))); | ||
|
||
given(). | ||
standaloneSetup(configureControllers(orderHistoryController)). | ||
when(). | ||
get("/orders/1"). | ||
then(). | ||
statusCode(200). | ||
body("restaurantName", equalTo("Ajanta")) | ||
; | ||
|
||
} | ||
|
||
// TODO move to test library | ||
|
||
private StandaloneMockMvcBuilder configureControllers(Object... controllers) { | ||
CommonJsonMapperInitializer.registerMoneyModule(); | ||
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(JSonMapper.objectMapper); | ||
return MockMvcBuilders.standaloneSetup(controllers).setMessageConverters(converter); | ||
} | ||
|
||
} |
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
7 changes: 7 additions & 0 deletions
7
...rc/main/java/net/chrisrichardson/ftgo/orderservice/domain/InvalidMenuItemIdException.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,7 @@ | ||
package net.chrisrichardson.ftgo.orderservice.domain; | ||
|
||
public class InvalidMenuItemIdException extends RuntimeException { | ||
public InvalidMenuItemIdException(String menuItemId) { | ||
super("Invalid menu item id " + menuItemId); | ||
} | ||
} |
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
Oops, something went wrong.