Package com.opengamma.master.config

Examples of com.opengamma.master.config.ConfigDocument


 
  @Test
  public void test_add_addThenGet() {
    ConfigItem<ExternalId> item = ConfigItem.of(ExternalId.of("A", "B"));
    item.setName("TestConfig");
    ConfigDocument added = _cfgMaster.add(new ConfigDocument(item));
   
    ConfigDocument test = _cfgMaster.get(added.getUniqueId());
    assertEquals(added, test);
  }
View Full Code Here


  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_correct_noConfigId() {
    ConfigItem<ExternalId> item = ConfigItem.of(ExternalId.of("A", "B"));
    item.setName("Name");   
    _cfgMaster.correct(new ConfigDocument(item));
  }
View Full Code Here

  public void test_correct_notFound() {
    UniqueId uniqueId = UniqueId.of("DbCfg", "0", "0");
    ConfigItem<ExternalId> doc = ConfigItem.of(ExternalId.of("A", "B"));
    doc.setUniqueId(uniqueId);
    doc.setName("Name");  
    _cfgMaster.correct(new ConfigDocument(doc));
  }
View Full Code Here

  @Test
  public void test_correct_getUpdateGet() {
    Instant now = Instant.now(_cfgMaster.getClock());
   
    UniqueId uniqueId = UniqueId.of("DbCfg", "101", "0");
    ConfigDocument base = _cfgMaster.get(uniqueId);

    ConfigItem<ExternalId> input = ConfigItem.of(ExternalId.of("A", "B"));
    input.setUniqueId(uniqueId);
    input.setName("NewName");

   
    ConfigDocument corrected = _cfgMaster.correct(new ConfigDocument(input));
    assertEquals(false, base.getUniqueId().equals(corrected.getUniqueId()));
    assertEquals(base.getVersionFromInstant(), corrected.getVersionFromInstant());
    assertEquals(base.getVersionToInstant(), corrected.getVersionToInstant());
    assertEquals(now, corrected.getCorrectionFromInstant());
    assertEquals(null, corrected.getCorrectionToInstant());
    assertEquals("NewName", corrected.getName());
    assertEquals(ExternalId.of("A", "B"), corrected.getConfig().getValue());
   
    ConfigDocument old = _cfgMaster.get(uniqueId);
    assertEquals(base.getUniqueId(), old.getUniqueId());
    assertEquals(base.getVersionFromInstant(), old.getVersionFromInstant());
    assertEquals(base.getVersionToInstant(), old.getVersionToInstant());
    assertEquals(base.getCorrectionFromInstant(), old.getCorrectionFromInstant());
    assertEquals(now, old.getCorrectionToInstant())// old version ended
    assertEquals(base.getConfig().getValue(), old.getConfig().getValue());
   
    ConfigHistoryRequest<ExternalId> search = new ConfigHistoryRequest<ExternalId>(base.getUniqueId(), now, null);
    search.setType(ExternalId.class);
   
    ConfigHistoryResult<ExternalId> searchResult = _cfgMaster.history(search);
View Full Code Here

  @Test
  public void test_correct_nameChangeNullValue() {
    Instant now = Instant.now(_cfgMaster.getClock());
   
    UniqueId uniqueId = UniqueId.of("DbCfg", "101", "0");
    ConfigDocument base = _cfgMaster.get(uniqueId);
    ConfigItem<?> input = base.getConfig();
    input.setName("NewName"); // name change only
   
    ConfigDocument corrected = _cfgMaster.correct(new ConfigDocument(input));
    assertEquals(false, base.getUniqueId().equals(corrected.getUniqueId()));
    assertEquals("NewName", corrected.getName())// name changed
    assertEquals(base.getConfig().getValue(), corrected.getConfig().getValue())// value unchanged
   
    ConfigDocument old = _cfgMaster.get(uniqueId);
    assertEquals(base.getUniqueId(), old.getUniqueId());
    assertEquals(now, old.getCorrectionToInstant())// old version ended
    assertEquals(base.getName(), old.getName());
    assertEquals(base.getConfig().getValue(), old.getConfig().getValue());
  }
View Full Code Here

    try {
      _cfgMaster.setClock(Clock.fixed(now, ZoneOffset.UTC));

      String initialValue = "initial";
      ConfigItem<String> initial = ConfigItem.of(initialValue, "some_name");     
      _cfgMaster.add(new ConfigDocument(initial));

      ObjectId baseOid = initial.getObjectId();

      List<ConfigDocument> firstReplacement = newArrayList();
      for (int i = 0; i < 5; i++) {
        String val = "setup_" + i;
        ConfigItem<String> item = ConfigItem.of(val, "some_name_"+i);
        ConfigDocument doc = new ConfigDocument(item);
        doc.setVersionFromInstant(now.plus(i, MINUTES));
        firstReplacement.add(doc);
      }
      _cfgMaster.setClock(Clock.fixed(now.plus(1, HOURS), ZoneOffset.UTC));
      _cfgMaster.replaceVersions(baseOid.getObjectId(), firstReplacement);
      return baseOid;
View Full Code Here

    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, MINUTES));
        replacement.add(doc);
      }

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

    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 = 1; i <= 10; i++) {
        String val = "test" + i;
        ConfigDocument doc = new ConfigDocument(ConfigItem.of(val));
        doc.setVersionFromInstant(latestFrom.plus(i, MINUTES));
        replacement.add(doc);
      }

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

      historyRequest.setObjectId(baseOid);
      historyRequest.setCorrectionsToInstant(null);
      ConfigHistoryResult<String> result = _cfgMaster.history(historyRequest);
      List<ConfigDocument> values = result.getDocuments();

      ConfigDocument lastButOneDoc = values.get(values.size() - 1);
      Instant lastButOneDocVersionFrom = lastButOneDoc.getVersionFromInstant();

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

      _cfgMaster.replaceVersion(lastButOneDoc.getUniqueId(), replacement);
View Full Code Here

      historyRequest.setObjectId(baseOid);
      historyRequest.setCorrectionsToInstant(null);
      ConfigHistoryResult<String> result = _cfgMaster.history(historyRequest);
      List<ConfigDocument> values = result.getDocuments();

      ConfigDocument lastButOneDoc = values.get(values.size() - 3);
      Instant lastButOneDocVersionFrom = lastButOneDoc.getVersionFromInstant();

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

      _cfgMaster.replaceVersion(lastButOneDoc.getUniqueId(), replacement);
View Full Code Here

TOP

Related Classes of com.opengamma.master.config.ConfigDocument

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.