Example usage for java.time ZonedDateTime of

List of usage examples for java.time ZonedDateTime of

Introduction

In this page you can find the example usage for java.time ZonedDateTime of.

Prototype

public static ZonedDateTime of(int year, int month, int dayOfMonth, int hour, int minute, int second,
        int nanoOfSecond, ZoneId zone) 

Source Link

Document

Obtains an instance of ZonedDateTime from a year, month, day, hour, minute, second, nanosecond and time-zone.

Usage

From source file:org.openlmis.fulfillment.web.ShipmentControllerIntegrationTest.java

@Test
public void shouldCreateShipment() {
    Order shipmentOrder = shipment.getOrder();
    shipmentOrder.setStatus(OrderStatus.ORDERED);
    when(orderRepository.findOne(shipment.getOrder().getId())).thenReturn(shipment.getOrder());
    //necessary as SaveAnswer change shipment id value also in captor
    when(shipmentRepository.save(any(Shipment.class))).thenReturn(shipment);
    when(proofOfDeliveryRepository.save(any(ProofOfDelivery.class))).thenReturn(proofOfDelivery);

    ShipmentDto extracted = restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader())
            .contentType(APPLICATION_JSON_VALUE).body(shipmentDto).when().post(RESOURCE_URL).then()
            .statusCode(201).extract().as(ShipmentDto.class);

    shipmentOrder.setStatus(OrderStatus.SHIPPED);
    shipmentOrder.setUpdateDetails(new UpdateDetails(INITIAL_USER_ID,
            ZonedDateTime.of(2015, 5, 7, 10, 5, 20, 500, ZoneId.systemDefault())));

    assertEquals(shipmentDtoExpected, extracted);
    verify(orderRepository).save(shipmentOrder);
    verify(shipmentRepository).save(captor.capture());
    verify(stockEventBuilder).fromShipment(any(Shipment.class));
    verify(stockEventService).submit(any(StockEventDto.class));
    assertTrue(reflectionEquals(shipment, captor.getValue(), singletonList("id")));
    assertNull(captor.getValue().getId());
    assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.responseChecks());
}

From source file:com.github.ithildir.airbot.service.impl.AirNowMeasurementServiceImpl.java

private long _parseTime(String dateString, String timeString, String timeZoneString) {

    int year = Integer.parseInt(dateString.substring(6)) + 2000;
    int month = Integer.parseInt(dateString.substring(0, 2));
    int dayOfMonth = Integer.parseInt(dateString.substring(3, 5));
    int hour = Integer.parseInt(timeString.substring(0, timeString.length() - 3));
    int minute = Integer.parseInt(timeString.substring(timeString.length() - 2));

    ZoneId zoneId = ZoneId.of(timeZoneString, _shortZoneIds);

    ZonedDateTime zonedDateTime = ZonedDateTime.of(year, month, dayOfMonth, hour, minute, 0, 0, zoneId);

    Instant instant = zonedDateTime.toInstant();

    return instant.toEpochMilli();
}

From source file:org.openlmis.fulfillment.web.OrderControllerIntegrationTest.java

@Before
public void setUp() {
    this.setUpBootstrapData();

    when(authenticationHelper.getCurrentUser()).thenReturn(user);

    when(dateHelper.getCurrentDateTimeWithSystemZone())
            .thenReturn(ZonedDateTime.of(2015, 5, 7, 10, 5, 20, 500, ZoneId.systemDefault()));

    program1 = new ProgramDataBuilder().withId(program1Id).build();
    program2 = new ProgramDataBuilder().withId(program2Id).build();

    period1 = new ProcessingPeriodDataBuilder().withId(period1Id).build();
    period2 = new ProcessingPeriodDataBuilder().withId(period2Id).build();

    facility = new FacilityDataBuilder().withId(facilityId)
            .withSupportedPrograms(Arrays.asList(program1, program2)).build();
    facility1 = new FacilityDataBuilder().withId(facility1Id)
            .withSupportedPrograms(Arrays.asList(program1, program2)).build();
    facility2 = new FacilityDataBuilder().withId(facility2Id)
            .withSupportedPrograms(Arrays.asList(program1, program2)).build();

    when(programService.findOne(eq(program1Id))).thenReturn(program1);
    when(programService.findOne(eq(program2Id))).thenReturn(program2);
    when(programService.findByIds(anySetOf(UUID.class))).thenReturn(Arrays.asList(program1, program2));

    when(facilityService.findOne(eq(facilityId))).thenReturn(facility);
    when(facilityService.findOne(eq(facility1Id))).thenReturn(facility1);
    when(facilityService.findOne(eq(facility2Id))).thenReturn(facility2);
    when(facilityService.findByIds(anySetOf(UUID.class)))
            .thenReturn(Arrays.asList(facility, facility1, facility2));

    when(shipmentRepository.save(any(Shipment.class)))
            .thenAnswer(invocation -> invocation.getArgumentAt(0, Shipment.class));

    product1 = new OrderableDataBuilder().withId(product1Id).build();
    product2 = new OrderableDataBuilder().withId(product2Id).build();

    when(orderableReferenceDataService.findByIds(anySetOf(UUID.class)))
            .thenReturn(Arrays.asList(product1, product2));

    when(userReferenceDataService.findByIds(anySetOf(UUID.class))).thenReturn(Collections.singletonList(user));

    when(periodReferenceDataService.findByIds(anyCollectionOf(UUID.class)))
            .thenReturn(Arrays.asList(period1, period2));

    when(periodReferenceDataService.findOne(period1Id)).thenReturn(period1);

    when(periodReferenceDataService.findOne(period2Id)).thenReturn(period2);

    firstOrder = createOrder(period1Id, program1Id, facilityId, facilityId, new BigDecimal("1.29"),
            createOrderLineItem(product1Id, 50L));

    secondOrder = createOrder(period1Id, program1Id, facility2Id, facility1Id, new BigDecimal(100),
            createOrderLineItem(product1Id, 50L), createOrderLineItem(product2Id, 15L));

    thirdOrder = createOrder(period2Id, program2Id, facility2Id, facility1Id, new BigDecimal(200),
            createOrderLineItem(product1Id, 50L), createOrderLineItem(product2Id, 10L));

    firstOrder.setExternalId(secondOrder.getExternalId());

    firstOrderDto = OrderDto.newInstance(firstOrder, exporter);
    secondOrderDto = OrderDto.newInstance(secondOrder, exporter);
}

From source file:com.sumzerotrading.intraday.trading.strategy.ReportGeneratorTest.java

@Test
public void testWriteRoundTrip() throws Exception {
    Path path = Files.createTempFile("ReportGeneratorUnitTest", ".txt");
    reportGenerator.outputFile = path.toString();
    String expected = "2016-03-19T07:01:10,LONG,ABC,100,100.23,0,2016-03-20T06:01:10,101.23,0";

    Ticker longTicker = new StockTicker("ABC");
    Ticker shortTicker = new StockTicker("XYZ");
    int longSize = 100;
    int shortSize = 50;
    double longEntryFillPrice = 100.23;
    double longExitFillPrice = 101.23;
    ZonedDateTime entryTime = ZonedDateTime.of(2016, 3, 19, 7, 1, 10, 0, ZoneId.systemDefault());
    ZonedDateTime exitTime = ZonedDateTime.of(2016, 3, 20, 6, 1, 10, 0, ZoneId.systemDefault());

    TradeOrder longEntry = new TradeOrder("123", longTicker, longSize, TradeDirection.BUY);
    longEntry.setFilledPrice(longEntryFillPrice);
    longEntry.setOrderFilledTime(entryTime);
    TradeReferenceLine entryLine = new TradeReferenceLine();
    entryLine.correlationId = "123";
    entryLine.direction = Direction.LONG;
    entryLine.side = Side.ENTRY;/*from w  w  w .  j  ava 2 s.c o  m*/

    TradeOrder longExit = new TradeOrder("123", longTicker, longSize, TradeDirection.SELL);
    longExit.setFilledPrice(longExitFillPrice);
    longExit.setOrderFilledTime(exitTime);
    TradeReferenceLine exitLine = new TradeReferenceLine();
    exitLine.correlationId = "123";
    exitLine.direction = LONG;
    exitLine.side = Side.EXIT;

    RoundTrip roundTrip = new RoundTrip();
    roundTrip.addTradeReference(longEntry, entryLine);
    roundTrip.addTradeReference(longExit, exitLine);

    System.out.println("Writing out to file: " + path);

    reportGenerator.writeRoundTripToFile(roundTrip);

    List<String> lines = Files.readAllLines(path);
    assertEquals(1, lines.size());
    assertEquals(expected, lines.get(0));

    Files.deleteIfExists(path);

}

From source file:com.sumzerotrading.eod.trading.strategy.ReportGeneratorTest.java

@Test
public void testWriteRoundTrip() throws Exception {
    Path path = Files.createTempFile("ReportGeneratorUnitTest", ".txt");
    reportGenerator.outputFile = path.toString();
    String expected = "2016-03-19T07:01:10,Long,ABC,100,100.23,0,2016-03-20T06:01:10,101.23,0,Short,XYZ,50,250.34,0,251.34,0";

    Ticker longTicker = new StockTicker("ABC");
    Ticker shortTicker = new StockTicker("XYZ");
    int longSize = 100;
    int shortSize = 50;
    double longEntryFillPrice = 100.23;
    double longExitFillPrice = 101.23;
    double shortEntryFillPrice = 250.34;
    double shortExitFillPrice = 251.34;
    ZonedDateTime entryTime = ZonedDateTime.of(2016, 3, 19, 7, 1, 10, 0, ZoneId.systemDefault());
    ZonedDateTime exitTime = ZonedDateTime.of(2016, 3, 20, 6, 1, 10, 0, ZoneId.systemDefault());

    TradeOrder longEntry = new TradeOrder("123", longTicker, longSize, TradeDirection.BUY);
    longEntry.setFilledPrice(longEntryFillPrice);
    longEntry.setOrderFilledTime(entryTime);

    TradeOrder longExit = new TradeOrder("123", longTicker, longSize, TradeDirection.SELL);
    longExit.setFilledPrice(longExitFillPrice);
    longExit.setOrderFilledTime(exitTime);

    TradeOrder shortEntry = new TradeOrder("123", shortTicker, shortSize, TradeDirection.SELL);
    shortEntry.setFilledPrice(shortEntryFillPrice);
    shortEntry.setOrderFilledTime(entryTime);

    TradeOrder shortExit = new TradeOrder("123", shortTicker, shortSize, TradeDirection.BUY);
    shortExit.setFilledPrice(shortExitFillPrice);
    shortExit.setOrderFilledTime(exitTime);

    RoundTrip roundTrip = new RoundTrip();
    roundTrip.longEntry = longEntry;//from   w w w.j  a va  2s  . c o m
    roundTrip.longExit = longExit;
    roundTrip.shortEntry = shortEntry;
    roundTrip.shortExit = shortExit;

    System.out.println("Writing out to file: " + path);

    reportGenerator.writeRoundTripToFile(roundTrip);

    List<String> lines = Files.readAllLines(path);
    assertEquals(1, lines.size());
    assertEquals(expected, lines.get(0));

    Files.deleteIfExists(path);

}

From source file:com.sumzerotrading.reporting.csv.ReportGeneratorTest.java

@Test
public void testWriteRoundTrip() throws Exception {
    Path path = Files.createTempFile("ReportGeneratorUnitTest", ".txt");
    reportGenerator.outputFile = path.toString();
    String expected = "2016-03-19T07:01:10,Long,ABC,100,100.23,0,2016-03-20T06:01:10,101.23,0,Short,XYZ,50,250.34,0,251.34,0";

    Ticker longTicker = new StockTicker("ABC");
    Ticker shortTicker = new StockTicker("XYZ");
    int longSize = 100;
    int shortSize = 50;
    double longEntryFillPrice = 100.23;
    double longExitFillPrice = 101.23;
    double shortEntryFillPrice = 250.34;
    double shortExitFillPrice = 251.34;
    ZonedDateTime entryTime = ZonedDateTime.of(2016, 3, 19, 7, 1, 10, 0, ZoneId.systemDefault());
    ZonedDateTime exitTime = ZonedDateTime.of(2016, 3, 20, 6, 1, 10, 0, ZoneId.systemDefault());

    TradeOrder longEntry = new TradeOrder("123", longTicker, longSize, TradeDirection.BUY);
    longEntry.setFilledPrice(longEntryFillPrice);
    longEntry.setOrderFilledTime(entryTime);

    TradeOrder longExit = new TradeOrder("123", longTicker, longSize, TradeDirection.SELL);
    longExit.setFilledPrice(longExitFillPrice);
    longExit.setOrderFilledTime(exitTime);

    TradeOrder shortEntry = new TradeOrder("123", shortTicker, shortSize, TradeDirection.SELL);
    shortEntry.setFilledPrice(shortEntryFillPrice);
    shortEntry.setOrderFilledTime(entryTime);

    TradeOrder shortExit = new TradeOrder("123", shortTicker, shortSize, TradeDirection.BUY);
    shortExit.setFilledPrice(shortExitFillPrice);
    shortExit.setOrderFilledTime(exitTime);

    PairTradeRoundTrip roundTrip = new PairTradeRoundTrip();
    roundTrip.longEntry = longEntry;//  w w w. ja  va2s  .c  om
    roundTrip.longExit = longExit;
    roundTrip.shortEntry = shortEntry;
    roundTrip.shortExit = shortExit;

    System.out.println("Writing out to file: " + path);

    reportGenerator.writeRoundTripToFile(roundTrip);

    List<String> lines = Files.readAllLines(path);
    assertEquals(1, lines.size());
    assertEquals(expected, lines.get(0));

    Files.deleteIfExists(path);

}

From source file:com.sumzerotrading.intraday.trading.strategy.ReportGeneratorTest.java

@Test
public void testReportGeneratorEndToEnd() throws Exception {
    StockTicker longTicker = new StockTicker("ABC");
    StockTicker shortTicker = new StockTicker("XYZ");

    ZonedDateTime entryOrderTime = ZonedDateTime.of(2016, 3, 25, 6, 18, 35, 0, ZoneId.systemDefault());
    ZonedDateTime exitOrderTime = ZonedDateTime.of(2016, 3, 25, 6, 19, 35, 0, ZoneId.systemDefault());

    String directory = System.getProperty("java.io.tmpdir");
    if (!directory.endsWith("/")) {
        directory += "/";
    }/*from www . j a va  2 s. co m*/
    Path reportPath = Paths.get(directory + "report.csv");
    Files.deleteIfExists(reportPath);
    System.out.println("Creating directory at: " + directory);
    ReportGenerator generator = new ReportGenerator(directory);

    TradeOrder longEntryOrder = new TradeOrder("123", longTicker, 100, TradeDirection.BUY);
    longEntryOrder.setFilledPrice(100.00);
    longEntryOrder.setReference("Intraday-Strategy:guid-123:Entry:Long*");
    longEntryOrder.setCurrentStatus(OrderStatus.Status.FILLED);
    longEntryOrder.setOrderFilledTime(entryOrderTime);

    generator.orderEvent(new OrderEvent(longEntryOrder, null));
    assertFalse(Files.exists(reportPath));

    TradeOrder longExitOrder = new TradeOrder("1234", longTicker, 100, TradeDirection.SELL);
    longExitOrder.setFilledPrice(105.00);
    longExitOrder.setReference("Intraday-Strategy:guid-123:Exit:Long*");
    longExitOrder.setCurrentStatus(OrderStatus.Status.FILLED);
    longExitOrder.setOrderFilledTime(exitOrderTime);

    generator.orderEvent(new OrderEvent(longExitOrder, null));
    assertTrue(Files.exists(reportPath));

    List<String> lines = Files.readAllLines(reportPath);
    assertEquals(1, lines.size());

    String line = lines.get(0);
    String expected = "2016-03-25T06:18:35,LONG,ABC,100,100.0,0,2016-03-25T06:19:35,105.0,0";
    assertEquals(expected, line);

    generator.orderEvent(new OrderEvent(longEntryOrder, null));
    generator.orderEvent(new OrderEvent(longExitOrder, null));

    lines = Files.readAllLines(reportPath);
    assertEquals(2, lines.size());
    assertEquals(expected, lines.get(0));
    assertEquals(expected, lines.get(1));

}

From source file:com.sumzerotrading.eod.trading.strategy.ReportGeneratorTest.java

@Test
public void testReportGeneratorEndToEnd() throws Exception {
    StockTicker longTicker = new StockTicker("ABC");
    StockTicker shortTicker = new StockTicker("XYZ");

    ZonedDateTime entryOrderTime = ZonedDateTime.of(2016, 3, 25, 6, 18, 35, 0, ZoneId.systemDefault());
    ZonedDateTime exitOrderTime = ZonedDateTime.of(2016, 3, 25, 6, 19, 35, 0, ZoneId.systemDefault());

    String directory = System.getProperty("java.io.tmpdir");
    if (!directory.endsWith("/")) {
        directory += "/";
    }/*from   ww  w.j  av  a  2s .c  o m*/
    Path reportPath = Paths.get(directory + "report.csv");
    Files.deleteIfExists(reportPath);
    System.out.println("Creating directory at: " + directory);
    ReportGenerator generator = new ReportGenerator(directory);

    TradeOrder longEntryOrder = new TradeOrder("123", longTicker, 100, TradeDirection.BUY);
    longEntryOrder.setFilledPrice(100.00);
    longEntryOrder.setReference("EOD-Pair-Strategy:guid-123:Entry:Long*");
    longEntryOrder.setCurrentStatus(OrderStatus.Status.FILLED);
    longEntryOrder.setOrderFilledTime(entryOrderTime);

    TradeOrder shortEntryOrder = new TradeOrder("234", shortTicker, 50, TradeDirection.SELL);
    shortEntryOrder.setFilledPrice(50.00);
    shortEntryOrder.setReference("EOD-Pair-Strategy:guid-123:Entry:Short*");
    shortEntryOrder.setCurrentStatus(OrderStatus.Status.FILLED);
    shortEntryOrder.setOrderFilledTime(entryOrderTime);

    generator.orderEvent(new OrderEvent(longEntryOrder, null));
    assertFalse(Files.exists(reportPath));

    generator.orderEvent(new OrderEvent(shortEntryOrder, null));
    assertFalse(Files.exists(reportPath));

    TradeOrder longExitOrder = new TradeOrder("1234", longTicker, 100, TradeDirection.SELL);
    longExitOrder.setFilledPrice(105.00);
    longExitOrder.setReference("EOD-Pair-Strategy:guid-123:Exit:Long*");
    longExitOrder.setCurrentStatus(OrderStatus.Status.FILLED);
    longExitOrder.setOrderFilledTime(exitOrderTime);

    TradeOrder shortExitOrder = new TradeOrder("2345", shortTicker, 50, TradeDirection.BUY);
    shortExitOrder.setFilledPrice(40.00);
    shortExitOrder.setReference("EOD-Pair-Strategy:guid-123:Exit:Short*");
    shortExitOrder.setCurrentStatus(OrderStatus.Status.FILLED);
    shortExitOrder.setOrderFilledTime(exitOrderTime);

    generator.orderEvent(new OrderEvent(longExitOrder, null));
    assertFalse(Files.exists(reportPath));

    generator.orderEvent(new OrderEvent(shortExitOrder, null));
    assertTrue(Files.exists(reportPath));

    List<String> lines = Files.readAllLines(reportPath);
    assertEquals(1, lines.size());

    String line = lines.get(0);
    String expected = "2016-03-25T06:18:35,Long,ABC,100,100.0,0,2016-03-25T06:19:35,105.0,0,Short,XYZ,50,50.0,0,40.0,0";
    assertEquals(expected, line);

    generator.orderEvent(new OrderEvent(longEntryOrder, null));
    generator.orderEvent(new OrderEvent(longExitOrder, null));
    generator.orderEvent(new OrderEvent(shortEntryOrder, null));
    generator.orderEvent(new OrderEvent(shortExitOrder, null));

    lines = Files.readAllLines(reportPath);
    assertEquals(2, lines.size());
    assertEquals(expected, lines.get(0));
    assertEquals(expected, lines.get(1));

}

From source file:com.tesobe.obp.transport.spi.ConnectorNov2016Test.java

@Test
public void getPagedTransactions() throws Exception {
    Decoder.Response owned;//from  www. j a  va2 s .  co m
    Map<String, String> parameters = new HashMap<>();
    // Jan 1st, 1999 00:00 - Jan 8th, 2000 00:00
    ZonedDateTime earliest = ZonedDateTime.of(1999, 1, 1, 0, 0, 0, 0, UTC);
    ZonedDateTime latest = ZonedDateTime.of(1999, 1, 8, 0, 0, 0, 0, UTC);
    Pager.Filter filter = new TimestampFilter(Transaction.postedDate, earliest, latest);
    Pager.Sorter sorter = DefaultSorter.build(Transaction.completedDate, ascending)
            .add("counterPartyId", descending).toSorter();
    int pageSize = 3;
    Pager pager = connector.pager(pageSize, 0, filter, sorter);

    parameters.put(Parameters.accountId, "account-x");
    parameters.put(Parameters.bankId, "bank-x");
    parameters.put(Parameters.userId, "user-x");

    owned = connector.get("getTransactions", Transport.Target.transactions, pager, parameters);

    assertThat("pager.count", pager.count(), is(0));
    assertThat("pager.hasMorePages", pager.hasMorePages(), is(true));
    assertThat("owned.size", owned.data().size(), is(pageSize));

    assertThat("owned.get(0)", owned.data().get(0).text(Transaction.transactionId), is("transactionId-7"));
    assertThat("owned.get(1)", owned.data().get(1).text(Transaction.transactionId), is("transactionId-6"));
    assertThat("owned.get(2)", owned.data().get(2).text(Transaction.transactionId), is("transactionId-5"));

    pager.nextPage();

    owned = connector.get("getTransactions", Transport.Target.transactions, pager, null);

    assertThat("pager.count", pager.count(), is(1));
    assertThat("pager.hasMorePages", pager.hasMorePages(), is(true));
    assertThat("owned.size", owned.data().size(), is(pageSize));

    assertThat("owned.get(0)", owned.data().get(0).text(Transaction.transactionId), is("transactionId-4"));
    assertThat("owned.get(1)", owned.data().get(1).text(Transaction.transactionId), is("transactionId-3"));
    assertThat("owned.get(2)", owned.data().get(2).text(Transaction.transactionId), is("transactionId-2"));

    pager.nextPage();

    owned = connector.get("getTransactions", Transport.Target.transactions, pager, null);

    assertThat("pager.count", pager.count(), is(2));
    assertThat("pager.hasMorePages", pager.hasMorePages(), is(false));
    assertThat("owned.size", owned.data().size(), is(2));

    assertThat("owned.get(0)", owned.data().get(0).text(Transaction.transactionId), is("transactionId-1"));
    assertThat("owned.get(1)", owned.data().get(1).text(Transaction.transactionId), is("transactionId-0"));
}

From source file:com.sumzerotrading.reporting.csv.ReportGeneratorTest.java

@Test
public void testReportGeneratorEndToEnd() throws Exception {
    StockTicker longTicker = new StockTicker("ABC");
    StockTicker shortTicker = new StockTicker("XYZ");

    ZonedDateTime entryOrderTime = ZonedDateTime.of(2016, 3, 25, 6, 18, 35, 0, ZoneId.systemDefault());
    ZonedDateTime exitOrderTime = ZonedDateTime.of(2016, 3, 25, 6, 19, 35, 0, ZoneId.systemDefault());

    String directory = System.getProperty("java.io.tmpdir");
    if (!directory.endsWith("/")) {
        directory += "/";
    }/*  w  w w  .j  a  v  a  2 s .  co m*/
    Path reportPath = Paths.get(directory + "report.csv");
    Files.deleteIfExists(reportPath);
    System.out.println("Creating directory at: " + directory);
    ReportGenerator generator = new ReportGenerator("EOD-Pair-Strategy", directory, pairRoundtripBuilder);

    TradeOrder longEntryOrder = new TradeOrder("123", longTicker, 100, TradeDirection.BUY);
    longEntryOrder.setFilledPrice(100.00);
    longEntryOrder.setReference("EOD-Pair-Strategy:guid-123:Entry:Long*");
    longEntryOrder.setCurrentStatus(OrderStatus.Status.FILLED);
    longEntryOrder.setOrderFilledTime(entryOrderTime);

    TradeOrder shortEntryOrder = new TradeOrder("234", shortTicker, 50, TradeDirection.SELL);
    shortEntryOrder.setFilledPrice(50.00);
    shortEntryOrder.setReference("EOD-Pair-Strategy:guid-123:Entry:Short*");
    shortEntryOrder.setCurrentStatus(OrderStatus.Status.FILLED);
    shortEntryOrder.setOrderFilledTime(entryOrderTime);

    generator.orderEvent(new OrderEvent(longEntryOrder, null));
    assertFalse(Files.exists(reportPath));

    generator.orderEvent(new OrderEvent(shortEntryOrder, null));
    assertFalse(Files.exists(reportPath));

    TradeOrder longExitOrder = new TradeOrder("1234", longTicker, 100, TradeDirection.SELL);
    longExitOrder.setFilledPrice(105.00);
    longExitOrder.setReference("EOD-Pair-Strategy:guid-123:Exit:Long*");
    longExitOrder.setCurrentStatus(OrderStatus.Status.FILLED);
    longExitOrder.setOrderFilledTime(exitOrderTime);

    TradeOrder shortExitOrder = new TradeOrder("2345", shortTicker, 50, TradeDirection.BUY);
    shortExitOrder.setFilledPrice(40.00);
    shortExitOrder.setReference("EOD-Pair-Strategy:guid-123:Exit:Short*");
    shortExitOrder.setCurrentStatus(OrderStatus.Status.FILLED);
    shortExitOrder.setOrderFilledTime(exitOrderTime);

    generator.orderEvent(new OrderEvent(longExitOrder, null));
    assertFalse(Files.exists(reportPath));

    generator.orderEvent(new OrderEvent(shortExitOrder, null));
    assertTrue(Files.exists(reportPath));

    List<String> lines = Files.readAllLines(reportPath);
    assertEquals(1, lines.size());

    String line = lines.get(0);
    String expected = "2016-03-25T06:18:35,Long,ABC,100,100.0,0,2016-03-25T06:19:35,105.0,0,Short,XYZ,50,50.0,0,40.0,0";
    assertEquals(expected, line);

    generator.orderEvent(new OrderEvent(longEntryOrder, null));
    generator.orderEvent(new OrderEvent(longExitOrder, null));
    generator.orderEvent(new OrderEvent(shortEntryOrder, null));
    generator.orderEvent(new OrderEvent(shortExitOrder, null));

    lines = Files.readAllLines(reportPath);
    assertEquals(2, lines.size());
    assertEquals(expected, lines.get(0));
    assertEquals(expected, lines.get(1));

}