Skip to content

Commit a8b56fd

Browse files
author
Brian Dussault
committed
Merge pull request liatrio#45 from dussab/service_updates
Timezone fix
2 parents 21d13c9 + abe302a commit a8b56fd

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

spring-nanotrader-services/src/test/java/org/springframework/nanotrader/web/configuration/ServiceTestConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import java.math.BigDecimal;
2525
import java.math.RoundingMode;
26+
import java.text.SimpleDateFormat;
2627
import java.util.ArrayList;
2728
import java.util.Date;
2829
import java.util.HashSet;
@@ -79,7 +80,6 @@ public class ServiceTestConfiguration {
7980
public static String PASSWORD = "password";
8081
public static String BAD_USER_ID = "NA";
8182
public static String BAD_PASSWORD = "NA";
82-
8383
//Order constants
8484
public static Integer ORDER_ID = 555;
8585
public static BigDecimal ORDER_PRICE = BigDecimal.valueOf(100);
@@ -123,6 +123,8 @@ public class ServiceTestConfiguration {
123123
public static String PAGE_SIZE = "pageSize";
124124
public static String TOTAL_RECORDS = "totalRecords";
125125
public static Long RESULT_COUNT = new Long(1);
126+
public static String DATE = new SimpleDateFormat("yyyy-MM-dd").format(new Date(1329759342904l));
127+
126128
@Bean
127129
public TradingService tradingService() {
128130
TradingService tradingService = Mockito.mock(TradingService.class);

spring-nanotrader-services/src/test/java/org/springframework/nanotrader/web/controller/AccountControllerTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,18 @@
3333
*/
3434

3535
public class AccountControllerTest extends AbstractSecureControllerTest {
36-
private static String DATE = "2012-02-20";
3736

3837
@Test
3938
public void getQuoteBySymbolJson() throws Exception {
4039
mockMvc.perform(get("/account/" + ServiceTestConfiguration.ACCOUNT_ID).accept(MediaType.APPLICATION_JSON))
4140
.andExpect(status().isOk())
4241
.andExpect(content().mimeType(MediaType.APPLICATION_JSON))
4342
.andExpect(jsonPath("$.accountid").value(ServiceTestConfiguration.ACCOUNT_ID))
44-
.andExpect(jsonPath("$.creationdate").value(DATE))
43+
.andExpect(jsonPath("$.creationdate").value(ServiceTestConfiguration.DATE))
4544
.andExpect(jsonPath("$.openbalance").value(ServiceTestConfiguration.ACCOUNT_OPEN_BALANCE.doubleValue()))
4645
.andExpect(jsonPath("$.logoutcount").value(ServiceTestConfiguration.LOGOUT_COUNT.intValue()))
4746
.andExpect(jsonPath("$.balance").value(ServiceTestConfiguration.ACCOUNT_BALANCE.doubleValue()))
48-
.andExpect(jsonPath("$.lastlogin").value(DATE))
47+
.andExpect(jsonPath("$.lastlogin").value(ServiceTestConfiguration.DATE))
4948
.andExpect(jsonPath("$.logincount").value(ServiceTestConfiguration.LOGIN_COUNT))
5049
.andDo(print());
5150
}

spring-nanotrader-services/src/test/java/org/springframework/nanotrader/web/controller/HoldingControllerTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
public class HoldingControllerTest extends AbstractSecureControllerTest {
3838
private static Integer PURCHASE_PRICE = 50000;
39-
private static String PURCHASE_DATE = "2012-02-20";
4039
private static Integer QUANTITY = 200;
4140

4241
@Test
@@ -45,7 +44,7 @@ public void getHoldingByIdJson() throws Exception {
4544
.andExpect(content().mimeType(MediaType.APPLICATION_JSON))
4645
.andExpect(jsonPath("$.holdingid").value(ServiceTestConfiguration.HOLDING_ID))
4746
.andExpect(jsonPath("$.accountAccountid").value(ServiceTestConfiguration.ACCOUNT_ID))
48-
.andExpect(jsonPath("$.purchasedate").value(PURCHASE_DATE))
47+
.andExpect(jsonPath("$.purchasedate").value(ServiceTestConfiguration.DATE))
4948
.andExpect(jsonPath("$.quote.symbol").value(ServiceTestConfiguration.SYMBOL))
5049
.andExpect(jsonPath("$.purchaseprice").value(PURCHASE_PRICE))
5150
.andExpect(jsonPath("$.quantity").value(QUANTITY))
@@ -70,7 +69,7 @@ public void getHoldingsByAccountIdJson() throws Exception {
7069
.andExpect(content().mimeType(MediaType.APPLICATION_JSON))
7170
.andExpect(jsonPath("$.results.[0].holdingid").value(ServiceTestConfiguration.HOLDING_ID))
7271
.andExpect(jsonPath("$.results.[0].accountAccountid").value(ServiceTestConfiguration.ACCOUNT_ID))
73-
.andExpect(jsonPath("$.results.[0].purchasedate").value(PURCHASE_DATE))
72+
.andExpect(jsonPath("$.results.[0].purchasedate").value(ServiceTestConfiguration.DATE))
7473
.andExpect(jsonPath("$.results.[0].quote.symbol").value(ServiceTestConfiguration.SYMBOL))
7574
.andExpect(jsonPath("$.results.[0].purchaseprice").value(PURCHASE_PRICE))
7675
.andExpect(jsonPath("$.results.[0].quantity").value(QUANTITY)).andDo(print());

spring-nanotrader-services/src/test/java/org/springframework/nanotrader/web/controller/OrderControllerTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,15 @@
4040

4141

4242
public class OrderControllerTest extends AbstractSecureControllerTest {
43-
private static String PURCHASE_DATE = "2012-02-20";
4443

4544
@Test
4645
public void getOrderByIdJson() throws Exception {
4746
mockMvc.perform(get("/account/" + ServiceTestConfiguration.ACCOUNT_ID + "/order/999/").accept(MediaType.APPLICATION_JSON))
4847
.andExpect(status().isOk())
4948
.andExpect(content().mimeType(MediaType.APPLICATION_JSON))
5049
.andExpect(jsonPath("$.orderid").value(ServiceTestConfiguration.ORDER_ID))
51-
.andExpect(jsonPath("$.completiondate").value(PURCHASE_DATE))
52-
.andExpect(jsonPath("$.opendate").value(PURCHASE_DATE))
50+
.andExpect(jsonPath("$.completiondate").value(ServiceTestConfiguration.DATE))
51+
.andExpect(jsonPath("$.opendate").value(ServiceTestConfiguration.DATE))
5352
.andExpect(jsonPath("$.orderfee").value(TradingServiceImpl.DEFAULT_ORDER_FEE.doubleValue()))
5453
.andExpect(jsonPath("$.price").value(ServiceTestConfiguration.ORDER_PRICE.intValue()))
5554
.andExpect(jsonPath("$.quantity").value(ServiceTestConfiguration.ORDER_QUANTITY.intValue()))
@@ -73,8 +72,8 @@ public void getOrders() throws Exception {
7372
.andExpect(status().isOk())
7473
.andExpect(content().mimeType(MediaType.APPLICATION_JSON))
7574
.andExpect(jsonPath("$.results.[0].orderid").value(ServiceTestConfiguration.ORDER_ID))
76-
.andExpect(jsonPath("$.results.[0].completiondate").value(PURCHASE_DATE))
77-
.andExpect(jsonPath("$.results.[0].opendate").value(PURCHASE_DATE))
75+
.andExpect(jsonPath("$.results.[0].completiondate").value(ServiceTestConfiguration.DATE))
76+
.andExpect(jsonPath("$.results.[0].opendate").value(ServiceTestConfiguration.DATE))
7877
.andExpect(jsonPath("$.results.[0].orderfee").value(TradingServiceImpl.DEFAULT_ORDER_FEE.doubleValue()))
7978
.andExpect(jsonPath("$.results.[0].price").value(ServiceTestConfiguration.ORDER_PRICE.intValue()))
8079
.andExpect(jsonPath("$.results.[0].quantity").value(ServiceTestConfiguration.ORDER_QUANTITY.intValue()))
@@ -99,8 +98,8 @@ public void getClosedOrders() throws Exception {
9998
.andExpect(status().isOk())
10099
.andExpect(content().mimeType(MediaType.APPLICATION_JSON))
101100
.andExpect(jsonPath("$.results.[0].orderid").value(ServiceTestConfiguration.ORDER_ID))
102-
.andExpect(jsonPath("$.results.[0].completiondate").value(PURCHASE_DATE))
103-
.andExpect(jsonPath("$.results.[0].opendate").value(PURCHASE_DATE))
101+
.andExpect(jsonPath("$.results.[0].completiondate").value(ServiceTestConfiguration.DATE))
102+
.andExpect(jsonPath("$.results.[0].opendate").value(ServiceTestConfiguration.DATE))
104103
.andExpect(jsonPath("$.results.[0].orderfee").value(TradingServiceImpl.DEFAULT_ORDER_FEE.doubleValue()))
105104
.andExpect(jsonPath("$.results.[0].price").value(ServiceTestConfiguration.ORDER_PRICE.intValue()))
106105
.andExpect(jsonPath("$.results.[0].quantity").value(ServiceTestConfiguration.ORDER_QUANTITY.intValue()))

0 commit comments

Comments
 (0)