Package org.threeten.bp

Examples of org.threeten.bp.Instant


   
    PositionDocument doc = new PositionDocument();
    doc.setPosition(position);
    PositionDocument test = _posMaster.add(doc);
   
    Instant now = Instant.now(_posMaster.getClock());
    UniqueId uniqueId = test.getUniqueId();
    assertNotNull(uniqueId);
    assertEquals("DbPos", uniqueId.getScheme());
    assertTrue(uniqueId.isVersioned());
    assertTrue(Long.parseLong(uniqueId.getValue()) >= 1000);
View Full Code Here


   
    PositionDocument doc = new PositionDocument();
    doc.setPosition(position);
    PositionDocument test = _posMaster.add(doc);
   
    Instant now = Instant.now(_posMaster.getClock());
    UniqueId uniqueId = test.getUniqueId();
    assertNotNull(uniqueId);
    assertEquals("DbPos", uniqueId.getScheme());
    assertTrue(uniqueId.isVersioned());
    assertTrue(Long.parseLong(uniqueId.getValue()) >= 1000);
View Full Code Here

    assertEquals(added, fromDb);
  }

  @Test
  public void test_addWithTwoTrades_add() {
    Instant now = Instant.now(_posMaster.getClock());
   
    OffsetDateTime offsetDateTime = OffsetDateTime.now();
   
    ManageablePosition position = new ManageablePosition(BigDecimal.TEN, ExternalId.of("A", "B"));
    position.getTrades().add(new ManageableTrade(BigDecimal.TEN, ExternalId.of("A", "C"), offsetDateTime.toLocalDate(), offsetDateTime.minusSeconds(600).toOffsetTime(), ExternalId.of("CPS", "CPV")));
View Full Code Here

    _cfgMaster.remove(uniqueId);
  }

  @Test
  public void test_remove_removed() {
    Instant now = Instant.now(_cfgMaster.getClock());
   
    UniqueId uniqueId = UniqueId.of("DbCfg", "101", "0");
    _cfgMaster.remove(uniqueId);
    ConfigDocument test = _cfgMaster.get(uniqueId);
   
View Full Code Here

    assertEquals(added, fromDb);
  }

  @Test
  public void test_addTradeDeal_add() {
    Instant now = Instant.now(_posMaster.getClock());
   
    ManageablePosition position = new ManageablePosition(BigDecimal.TEN, ExternalId.of("A", "B"));
       
    LocalDate tradeDate = _now.toLocalDate();
    OffsetTime tradeTime = _now.toOffsetTime().minusSeconds(500);
View Full Code Here

    _holMaster.add(doc);
  }

  @Test
  public void test_add_add_currency() {
    Instant now = Instant.now(_holMaster.getClock());
   
    ManageableHoliday holiday = new ManageableHoliday(Currency.USD, Arrays.asList(LocalDate.of(2010, 6, 9)));
    HolidayDocument doc = new HolidayDocument(holiday);
    String name = doc.getName();
    HolidayDocument test = _holMaster.add(doc);
View Full Code Here

    assertEquals(Arrays.asList(LocalDate.of(2010, 6, 9)), testHoliday.getHolidayDates());
  }

  @Test
  public void test_add_add_bank() {
    Instant now = Instant.now(_holMaster.getClock());
   
    ManageableHoliday holiday = new ManageableHoliday(HolidayType.BANK, ExternalId.of("A", "B"), Arrays.asList(LocalDate.of(2010, 6, 9)));
    HolidayDocument doc = new HolidayDocument(holiday);
    String name = doc.getName();
    HolidayDocument test = _holMaster.add(doc);
View Full Code Here

    assertEquals(Arrays.asList(LocalDate.of(2010, 6, 9)), testHoliday.getHolidayDates());
  }

  @Test
  public void test_add_add_settlement() {
    Instant now = Instant.now(_holMaster.getClock());
   
    ManageableHoliday holiday = new ManageableHoliday(HolidayType.SETTLEMENT, ExternalId.of("A", "B"), Arrays.asList(LocalDate.of(2010, 6, 9)));
    HolidayDocument doc = new HolidayDocument(holiday);
    String name = doc.getName();
    HolidayDocument test = _holMaster.add(doc);
View Full Code Here

    assertEquals(Arrays.asList(LocalDate.of(2010, 6, 9)), testHoliday.getHolidayDates());
  }

  @Test
  public void test_add_add_trading() {
    Instant now = Instant.now(_holMaster.getClock());
   
    ManageableHoliday holiday = new ManageableHoliday(HolidayType.TRADING, ExternalId.of("A", "B"), Arrays.asList(LocalDate.of(2010, 6, 9)));
    HolidayDocument doc = new HolidayDocument(holiday);
    String name = doc.getName();
    HolidayDocument test = _holMaster.add(doc);
View Full Code Here

   *
   */
  public void test_ReplaceAllVersions1() {
    Clock origClock = _cfgMaster.getClock();
    try {
      Instant now = Instant.now();

      ObjectId baseOid = setupTestData(now);
      _cfgMaster.setClock(Clock.fixed(now.plus(2, HOURS), ZoneOffset.UTC));
      ConfigDocument latestDoc = _cfgMaster.get(baseOid, VersionCorrection.LATEST);


      List<ConfigDocument> replacement = newArrayList();
      for (int i = 1; i <= 4; i++) {
        String val = "replace_" + i;
        ConfigDocument doc = new ConfigDocument(ConfigItem.of(val, "some_name_"+i));

        doc.setVersionFromInstant(now.plus(2, MINUTES).plus(i * 20, SECONDS));
        replacement.add(doc);
      }

      _cfgMaster.replaceAllVersions(latestDoc, replacement);

      ConfigHistoryRequest<String> historyRequest = new ConfigHistoryRequest<String>();
      historyRequest.setObjectId(baseOid);
      historyRequest.setCorrectionsFromInstant(now.plus(2, HOURS));
      ConfigHistoryResult<String> result = _cfgMaster.history(historyRequest);
      List<ConfigDocument> values = result.getDocuments();

      assertEquals(4, values.size());

      assertEquals(now.plus(2, MINUTES).plus(20, SECONDS), values.get(3).getVersionFromInstant());
      assertEquals(now.plus(2, MINUTES).plus(40, SECONDS), values.get(3).getVersionToInstant());
      //
      assertEquals(now.plus(2, MINUTES).plus(40, SECONDS), values.get(2).getVersionFromInstant());
      assertEquals(now.plus(3, MINUTES).plus(0, SECONDS), values.get(2).getVersionToInstant());
      //
      assertEquals(now.plus(3, MINUTES).plus(0, SECONDS), values.get(1).getVersionFromInstant());
      assertEquals(now.plus(3, MINUTES).plus(20, SECONDS), values.get(1).getVersionToInstant());
      //
      assertEquals(now.plus(3, MINUTES).plus(20, SECONDS), values.get(0).getVersionFromInstant());
      assertEquals(null, values.get(0).getVersionToInstant());
      //
    } finally {
      _cfgMaster.setClock(origClock);
    }
View Full Code Here

TOP

Related Classes of org.threeten.bp.Instant

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.