Package org.threeten.bp

Examples of org.threeten.bp.Instant


   *
   */
  public void test_ReplaceAllVersions2() {
    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);
      }
      replacement.get(replacement.size() - 1).setVersionToInstant(now.plus(2, MINUTES).plus(100, SECONDS));

      _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), values.get(2).getVersionToInstant());
      //
      assertEquals(now.plus(3, MINUTES), 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(now.plus(3, MINUTES).plus(40, SECONDS), values.get(0).getVersionToInstant());

    } finally {
      _cfgMaster.setClock(origClock);
    }
  }
View Full Code Here


    _orgMaster.add(doc);
  }

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

    ManageableOrganization org = new ManageableOrganization("TestOrganization101",
                                                            "RED_code_101",
                                                            "ticker_101",
                                                            Region.AFRICA,
View Full Code Here

   *
   */
  public void test_ReplaceAllVersions3() {
    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.minus(60, SECONDS).plus(i * 30, SECONDS));
        replacement.add(doc);
      }
      replacement.get(replacement.size() - 1).setVersionToInstant(now.plus(90, SECONDS));

      _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(-30, SECONDS), values.get(3).getVersionFromInstant());
      assertEquals(now.plus(0, SECONDS), values.get(3).getVersionToInstant());
      //
      assertEquals(now.plus(0, SECONDS), values.get(2).getVersionFromInstant());
      assertEquals(now.plus(30, SECONDS), values.get(2).getVersionToInstant());
      //
      assertEquals(now.plus(30, SECONDS), values.get(1).getVersionFromInstant());
      assertEquals(now.plus(60, SECONDS), values.get(1).getVersionToInstant());
      //
      assertEquals(now.plus(60, SECONDS), values.get(0).getVersionFromInstant());
      assertEquals(now.plus(90, SECONDS), values.get(0).getVersionToInstant());
      //     
    } finally {
      _cfgMaster.setClock(origClock);
    }
  }
View Full Code Here

    _compTargetSpec = target.getLeafSpecification();
    _requirement = new ValueRequirement("FAIR_VALUE", _compTargetSpec);
    _specification = new ValueSpecification("FAIR_VALUE", _compTargetSpec, ValueProperties.with(ValuePropertyNames.FUNCTION, "IDENTITY_FUNCTION").get());

    final Instant _valuationTime = Instant.parse("2011-12-14T14:20:17.143Z");

    _cycleMetadataStub = new ViewCycleMetadata() {

      @Override
      public UniqueId getViewCycleId() {
View Full Code Here

    _prtMaster.update(doc);
  }

  @Test
  public void test_update_getUpdateGet() {
    Instant now = Instant.now(_prtMaster.getClock());
   
    UniqueId oldPortfolioId = UniqueId.of("DbPrt", "101", "0");
    PortfolioDocument base = _prtMaster.get(oldPortfolioId);
    Map<String, String> oldAttr = base.getPortfolio().getAttributes();
    assertNotNull(oldAttr);
View Full Code Here

//    ver_to_instant timestamp not null,
//    corr_from_instant timestamp not null,
//    corr_to_instant timestamp not null,
//    name varchar(255) not null,
//    sec_type varchar(255) not null,
    Instant now = Instant.now();
    _secMaster.setClock(Clock.fixed(now, ZoneOffset.UTC));
    _version1Instant = now.minusSeconds(100);
    _version2Instant = now.minusSeconds(50);
    s_logger.debug("test data now:   {}", _version1Instant);
    s_logger.debug("test data later: {}", _version2Instant);
    final JdbcOperations template = _secMaster.getDbConnector().getJdbcOperations();
    template.update("INSERT INTO sec_security VALUES (?,?,?,?,?, ?,?,?,?)",
        101, 101, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, "TestSecurity101", "EQUITY", "D");
View Full Code Here

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

  @Test
  public void test_correct_getUpdateGet() {
    Instant now = Instant.now(_secMaster.getClock());
   
    UniqueId uniqueId = UniqueId.of("DbSec", "101", "0");
    SecurityDocument base = _secMaster.get(uniqueId);
    ManageableSecurity security = new ManageableSecurity(uniqueId, "Name", "Type", ExternalIdBundle.of("A", "B"));
    SecurityDocument input = new SecurityDocument(security);
View Full Code Here

    }

    VersionCorrection resolutionTime = properties.getResolutionTime();
    uri = DependencyGraphTraceProviderResource.uriResolutionTime(uri, resolutionTime);

    Instant valuationTime = properties.getValuationTime();
    if (valuationTime != null) {
      uri = DependencyGraphTraceProviderResource.uriValuationTime(uri, valuationTime);
    }

    //process requirements:
View Full Code Here

//    region_scheme varchar(255),
//    region_value varchar(255),
//    exchange_scheme varchar(255),
//    exchange_value varchar(255),
//    currency_iso varchar(255),
    Instant now = Instant.now();
    _holMaster.setClock(Clock.fixed(now, ZoneOffset.UTC));
    _version1Instant = now.minusSeconds(100);
    _version2Instant = now.minusSeconds(50);
    s_logger.debug("test data now:   {}", _version1Instant);
    s_logger.debug("test data later: {}", _version2Instant);
    final JdbcOperations template = _holMaster.getDbConnector().getJdbcOperations();
    template.update("INSERT INTO hol_holiday VALUES (?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?)",
        101, 101, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP,
View Full Code Here

//    obligor_fitch_credit_rating                  varchar(255) NOT NULL,
//    obligor_moodys_credit_rating                 varchar(255) NOT NULL,
//    obligor_standard_and_poors_credit_rating     varchar(255) NOT NULL,
//    obligor_has_defaulted                        smallint NOT NULL,

    Instant now = Instant.now();
    _orgMaster.setClock(Clock.fixed(now, ZoneId.of("UTC")));
    _version1Instant = now.minusSeconds(100);
    _version2Instant = now.minusSeconds(50);
    s_logger.debug("test data now:   {}", _version1Instant);
    s_logger.debug("test data later: {}", _version2Instant);

    final JdbcOperations template = _orgMaster.getDbConnector().getJdbcOperations();
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.