Package org.threeten.bp

Examples of org.threeten.bp.Instant


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

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

      final ExternalIdBundle bundle = ExternalIdBundle.of("B", "B0");
      final ExternalIdBundle region = ExternalIdBundle.of("R", "R0");
      List<ExchangeDocument> replacement = newArrayList();
      for (int i = 0; i <= 2; i++) {
        ManageableExchange ex = new ManageableExchange(bundle, "replace_" + i, region, null);
        ExchangeDocument doc = new ExchangeDocument(ex);
        doc.setVersionFromInstant(now.plus(1, MINUTES).plus(i * 20, SECONDS));
        replacement.add(doc);
      }
      replacement.get(replacement.size() - 1).setVersionToInstant(now.plus(2, MINUTES));

      ExchangeHistoryRequest historyRequest = new ExchangeHistoryRequest();
      historyRequest.setObjectId(baseOid);
      historyRequest.setCorrectionsFromInstant(now.plus(2, HOURS));
      ExchangeHistoryResult result = _exgMaster.history(historyRequest);
      List<ExchangeDocument> exchanges = result.getDocuments();

      ExchangeDocument secondVersionDoc = exchanges.get(exchanges.size() - 2);

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

      historyRequest = new ExchangeHistoryRequest();
      historyRequest.setObjectId(baseOid);
      historyRequest.setCorrectionsFromInstant(now.plus(2, HOURS));
      result = _exgMaster.history(historyRequest);
      exchanges = result.getDocuments();

      assertEquals(7, exchanges.size());

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


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

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

      final ExternalIdBundle bundle = ExternalIdBundle.of("B", "B0");
      final ExternalIdBundle region = ExternalIdBundle.of("R", "R0");
      List<ExchangeDocument> replacement = newArrayList();
      for (int i = 0; i <= 2; i++) {
        ManageableExchange ex = new ManageableExchange(bundle, "replace_" + i, region, null);
        ExchangeDocument doc = new ExchangeDocument(ex);
        doc.setVersionFromInstant(now.plus(1, MINUTES).plus(i * 20, SECONDS));
        replacement.add(doc);
      }

      ExchangeHistoryRequest historyRequest = new ExchangeHistoryRequest();
      historyRequest.setObjectId(baseOid);
      historyRequest.setCorrectionsFromInstant(now.plus(2, HOURS));
      ExchangeHistoryResult result = _exgMaster.history(historyRequest);
      List<ExchangeDocument> exchanges = result.getDocuments();

      ExchangeDocument secondVersionDoc = exchanges.get(exchanges.size() - 2);

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

      historyRequest = new ExchangeHistoryRequest();
      historyRequest.setObjectId(baseOid);
      historyRequest.setCorrectionsFromInstant(now.plus(2, HOURS));
      result = _exgMaster.history(historyRequest);
      exchanges = result.getDocuments();

      assertEquals(7, exchanges.size());

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

    String engineURI = getProperty("engineURI", line, configProperties, configPropertyFile);

    String brokerURL = getProperty("brokerURL", line, configProperties, configPropertyFile);

    Instant valuationTime = getValuationTime(line, configProperties, configPropertyFile);
    LocalDate observationDate = getObservationDate(line, configProperties, configPropertyFile);

    UniqueId viewDefinitionUniqueId = getViewDefinitionUniqueId(line, configProperties);

    URI vpBase;
View Full Code Here

  public int deleteClients(final Instant timestamp) {
    final Iterator<Map.Entry<String, FinancialClient>> clientIterator = _clientMap.entrySet().iterator();
    int activeClients = 0;
    while (clientIterator.hasNext()) {
      final Map.Entry<String, FinancialClient> clientEntry = clientIterator.next();
      final Instant clientTime = clientEntry.getValue().getLastAccessed();
      if (clientTime.isBefore(timestamp)) {
        clientIterator.remove();
        getClientTracker().clientDiscarded(getUserName(), clientEntry.getKey());
      } else {
        activeClients++;
      }
View Full Code Here

    _secMaster.remove(uniqueId);
  }

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

    _htsMaster.remove(objectId);
  }

  @Test
  public void test_removeHistoricalTimeSeries_removed() {
    Instant now = Instant.now(_htsMaster.getClock());
   
    UniqueId uniqueId = UniqueId.of("DbHts", "102", "0");
    _htsMaster.remove(uniqueId);
    HistoricalTimeSeriesInfoDocument test = _htsMaster.get(uniqueId);
   
View Full Code Here

*/
public abstract class InstantDoubleTimeSeriesTest extends DoubleTimeSeriesTest<Instant> {

  @Override
  protected Instant[] testTimes() {
    Instant one = OffsetDateTime.of(2010, 2, 8, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant two = OffsetDateTime.of(2010, 2, 9, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant three = OffsetDateTime.of(2010, 2, 10, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant four = OffsetDateTime.of(2010, 2, 11, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant five = OffsetDateTime.of(2010, 2, 12, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant six = OffsetDateTime.of(2010, 2, 13, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    return new Instant[] {one, two, three, four, five, six };
  }
View Full Code Here

    return new Instant[] {one, two, three, four, five, six };
  }

  @Override
  protected Instant[] testTimes2() {
    Instant one = OffsetDateTime.of(2010, 2, 11, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant two = OffsetDateTime.of(2010, 2, 12, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant three = OffsetDateTime.of(2010, 2, 13, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant four = OffsetDateTime.of(2010, 2, 14, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant five = OffsetDateTime.of(2010, 2, 15, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant six = OffsetDateTime.of(2010, 2, 16, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    return new Instant[] {one, two, three, four, five, six };
  }
View Full Code Here

*/
public abstract class InstantObjectTimeSeriesTest extends PreciseObjectTimeSeriesTest<Instant> {

  @Override
  protected Instant[] testTimes() {
    Instant one = OffsetDateTime.of(2010, 2, 8, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant two = OffsetDateTime.of(2010, 2, 9, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant three = OffsetDateTime.of(2010, 2, 10, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant four = OffsetDateTime.of(2010, 2, 11, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant five = OffsetDateTime.of(2010, 2, 12, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant six = OffsetDateTime.of(2010, 2, 13, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    return new Instant[] { one, two, three, four, five, six };
  }
View Full Code Here

    return new Instant[] { one, two, three, four, five, six };
  }

  @Override
  protected Instant[] testTimes2() {
    Instant one = OffsetDateTime.of(2010, 2, 11, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant two = OffsetDateTime.of(2010, 2, 12, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant three = OffsetDateTime.of(2010, 2, 13, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant four = OffsetDateTime.of(2010, 2, 14, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant five = OffsetDateTime.of(2010, 2, 15, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    Instant six = OffsetDateTime.of(2010, 2, 16, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
    return new Instant[] { one, two, three, four, five, six };
  }
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.