Package org.threeten.bp

Examples of org.threeten.bp.Instant


  @Test
  public void test_ReplaceVersions2() {
    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);
      Instant latestFrom = latestDoc.getVersionFromInstant();


      List<ConfigDocument> replacement = newArrayList();
      for (int i = 0; i <= 10; i++) {
        String val = "test" + i;
        ConfigDocument doc = new ConfigDocument(ConfigItem.of(val, "some_name_"+i));
        doc.setVersionFromInstant(latestFrom.plus(i - 3, MINUTES));
        replacement.add(doc);
      }

      _cfgMaster.replaceVersions(latestDoc, replacement);
View Full Code Here


   */
  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_ReplaceVersion_notInTimeBounds() {
    Clock origClock = _cfgMaster.getClock();
    try {
      Instant now = Instant.now();

      ObjectId baseOid = setupTestData(now);
      _cfgMaster.setClock(Clock.fixed(now.plus(2, HOURS), ZoneOffset.UTC));
      @SuppressWarnings("unused")
      ConfigDocument latestDoc = _cfgMaster.get(baseOid, VersionCorrection.LATEST);
     
      List<ConfigDocument> replacement = newArrayList();
      for (int i = 1; i <= 3; i++) {
        String val = "replace_" + i;
        ConfigDocument doc = new ConfigDocument(ConfigItem.of(val));
        doc.setVersionFromInstant(now.plus(1, MINUTES).plus(i * 10, SECONDS));
        replacement.add(doc);
      }

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

      ConfigDocument secondVersionDoc = confDocs.get(confDocs.size() - 2);

View Full Code Here

   */
  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_ReplaceVersion_inTimeBounds() {
    Clock origClock = _cfgMaster.getClock();
    try {
      Instant now = Instant.now();

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

      List<ConfigDocument> replacement = newArrayList();
      for (int i = 1; i <= 3; i++) {
        String val = "replace_" + i;
        ConfigDocument doc = new ConfigDocument(ConfigItem.of(val));
        doc.setVersionFromInstant(now.plus(1, MINUTES).plus(i * 10, SECONDS));
        replacement.add(doc);
      }
      replacement.get(replacement.size() - 1).setVersionToInstant(now.plus(1, MINUTES).plus(40, SECONDS));

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

      ConfigDocument secondVersionDoc = confDocs.get(confDocs.size() - 2);

View Full Code Here

    _prtMaster.add(doc);
  }

  @Test
  public void test_add_add() {
    Instant now = Instant.now(_prtMaster.getClock());
   
    ManageablePortfolioNode rootNode = new ManageablePortfolioNode("Root");
    ManageablePortfolioNode childNode = new ManageablePortfolioNode("Child");
    childNode.addPosition(UniqueId.of("TestPos", "1234"));
    rootNode.addChildNode(childNode);
View Full Code Here

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

      ObjectId baseOid = setupTestData(now);
      _cfgMaster.setClock(Clock.fixed(now.plus(2, HOURS), ZoneOffset.UTC));


      List<ConfigDocument> replacement = newArrayList();
      for (int i = 0; i <= 2; i++) {
        String val = "replace_" + i;
        ConfigDocument doc = new ConfigDocument(ConfigItem.of(val, "some_name_"+i));
        doc.setVersionFromInstant(now.plus(1, MINUTES).plus(i * 20, SECONDS));
        replacement.add(doc);
      }
      replacement.get(replacement.size() - 1).setVersionToInstant(now.plus(2, MINUTES));

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

      ConfigDocument secondVersionDoc = confDocs.get(confDocs.size() - 2);

      _cfgMaster.replaceVersion(secondVersionDoc.getUniqueId(), replacement);

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

      assertEquals(7, confDocs.size());

      assertEquals(now, confDocs.get(6).getVersionFromInstant());
      assertEquals(now.plus(1, MINUTES), confDocs.get(6).getVersionToInstant());
      //
      assertEquals(now.plus(1, MINUTES), confDocs.get(5).getVersionFromInstant());
      assertEquals(now.plus(1, MINUTES).plus(20, SECONDS), confDocs.get(5).getVersionToInstant());
      //
      assertEquals(now.plus(1, MINUTES).plus(20, SECONDS), confDocs.get(4).getVersionFromInstant());
      assertEquals(now.plus(1, MINUTES).plus(40, SECONDS), confDocs.get(4).getVersionToInstant());
      //
      assertEquals(now.plus(1, MINUTES).plus(40, SECONDS), confDocs.get(3).getVersionFromInstant());
      assertEquals(now.plus(1, MINUTES).plus(60, SECONDS), confDocs.get(3).getVersionToInstant());
      //
      assertEquals(now.plus(1, MINUTES).plus(60, SECONDS), confDocs.get(2).getVersionFromInstant());
      assertEquals(now.plus(1, MINUTES).plus(120, SECONDS), confDocs.get(2).getVersionToInstant());
      //
      assertEquals(now.plus(1, MINUTES).plus(120, SECONDS), confDocs.get(1).getVersionFromInstant());
      assertEquals(now.plus(1, MINUTES).plus(180, SECONDS), confDocs.get(1).getVersionToInstant());
      //
      assertEquals(now.plus(1, MINUTES).plus(180, SECONDS), confDocs.get(0).getVersionFromInstant());
      assertEquals(null, confDocs.get(0).getVersionToInstant());
    } finally {
      _cfgMaster.setClock(origClock);
    }
  }
View Full Code Here

    assertEquals(ObjectId.of("TestPos", "1234"), testChildNode.getPositionIds().get(0));
  }
 
  @Test
  public void test_addWithAttributes_add() {
    Instant now = Instant.now(_prtMaster.getClock());
   
    ManageablePortfolioNode rootNode = new ManageablePortfolioNode("Root");
    ManageablePortfolioNode childNode = new ManageablePortfolioNode("Child");
    childNode.addPosition(UniqueId.of("TestPos", "1234"));
    rootNode.addChildNode(childNode);
View Full Code Here

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

      ObjectId baseOid = setupTestData(now);
      _cfgMaster.setClock(Clock.fixed(now.plus(2, HOURS), ZoneOffset.UTC));


      List<ConfigDocument> replacement = newArrayList();
      for (int i = 0; i <= 2; i++) {
        String val = "replace_" + i;
        ConfigDocument doc = new ConfigDocument(ConfigItem.of(val, "some_name_"+i));
        doc.setVersionFromInstant(now.plus(1, MINUTES).plus(i * 20, SECONDS));
        replacement.add(doc);
      }

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

      ConfigDocument secondVersionDoc = confDocs.get(confDocs.size() - 2);

      _cfgMaster.replaceVersion(secondVersionDoc.getUniqueId(), replacement);

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

      assertEquals(7, confDocs.size());

      assertEquals(now, confDocs.get(6).getVersionFromInstant());
      assertEquals(now.plus(1, MINUTES), confDocs.get(6).getVersionToInstant());
      //
      assertEquals(now.plus(1, MINUTES), confDocs.get(5).getVersionFromInstant());
      assertEquals(now.plus(1, MINUTES).plus(20, SECONDS), confDocs.get(5).getVersionToInstant());
      //
      assertEquals(now.plus(1, MINUTES).plus(20, SECONDS), confDocs.get(4).getVersionFromInstant());
      assertEquals(now.plus(1, MINUTES).plus(40, SECONDS), confDocs.get(4).getVersionToInstant());
      //
      assertEquals(now.plus(1, MINUTES).plus(40, SECONDS), confDocs.get(3).getVersionFromInstant());
      assertEquals(now.plus(1, MINUTES).plus(60, SECONDS), confDocs.get(3).getVersionToInstant());
      //
      assertEquals(now.plus(1, MINUTES).plus(60, SECONDS), confDocs.get(2).getVersionFromInstant());
      assertEquals(now.plus(1, MINUTES).plus(120, SECONDS), confDocs.get(2).getVersionToInstant());
      //
      assertEquals(now.plus(1, MINUTES).plus(120, SECONDS), confDocs.get(1).getVersionFromInstant());
      assertEquals(now.plus(1, MINUTES).plus(180, SECONDS), confDocs.get(1).getVersionToInstant());
      //
      assertEquals(now.plus(1, MINUTES).plus(180, SECONDS), confDocs.get(0).getVersionFromInstant());
      assertEquals(null, confDocs.get(0).getVersionToInstant());
    } finally {
      _cfgMaster.setClock(origClock);
    }
  }
View Full Code Here

    _orgMaster.remove(uniqueId);
  }

  @Test
  public void test_remove_removed() {
    Instant now = Instant.now(_orgMaster.getClock());

    UniqueId uniqueId = UniqueId.of("DbOrg", "101", "0");
    _orgMaster.remove(uniqueId);
    OrganizationDocument test = _orgMaster.get(uniqueId);
View Full Code Here

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_ReplaceVersion_noUid() {
    Clock origClock = _cfgMaster.getClock();
    try {
      Instant now = Instant.now();

      ObjectId baseOid = setupTestData(now);
      _cfgMaster.setClock(Clock.fixed(now.plus(2, HOURS), ZoneOffset.UTC));


      List<ConfigDocument> replacement = newArrayList();
      for (int i = 0; i <= 2; i++) {
        String val = "replace_" + i;
        ConfigDocument doc = new ConfigDocument(ConfigItem.of(val));
        doc.setVersionFromInstant(now.plus(1, MINUTES).plus(i * 20, SECONDS));
        replacement.add(doc);
      }

      _cfgMaster.replaceVersion(baseOid.atVersion("no such uid"), replacement);
    } finally {
View Full Code Here

//    _orgMaster.correct(doc);
//  }

  @Test
  public void test_correct_getUpdateGet() {
    Instant now = Instant.now(_holMaster.getClock());
   
    UniqueId uniqueId = UniqueId.of("DbHol", "101", "0");
    HolidayDocument base = _holMaster.get(uniqueId);
    ManageableHoliday holiday = new ManageableHoliday(Currency.USD, Arrays.asList(LocalDate.of(2010, 6, 9)));
    holiday.setUniqueId(uniqueId);
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.