InMemoryConfigMaster implements ConfigMaster { @Override public ConfigDocument update(final ConfigDocument document) { ArgumentChecker.notNull(document, "document"); ArgumentChecker.notNull(document.getUniqueId(), "document.uniqueId"); ArgumentChecker.notNull(document.getConfig(), "document.object"); ArgumentChecker.notNull(document.getConfig().getValue(), "document.object.value"); UniqueId uniqueId = document.getUniqueId(); final Instant now = Instant.now(); final ConfigDocument storedDocument = _store.get(uniqueId.getObjectId()); if (storedDocument == null) { throw new DataNotFoundException("Config not found: " + uniqueId); } document.setVersionFromInstant(now); document.setVersionToInstant(null); document.setCorrectionFromInstant(now); document.setCorrectionToInstant(null); uniqueId = uniqueId.withVersion(Long.toString(_versions.incrementAndGet())); document.setUniqueId(uniqueId); IdUtils.setInto(document.getConfig().getValue(), uniqueId); if (_store.replace(uniqueId.getObjectId(), storedDocument, document) == false) { throw new IllegalArgumentException("Concurrent modification"); } _changeManager.entityChanged(ChangeType.CHANGED, document.getObjectId(), document.getVersionFromInstant(), document.getVersionToInstant(), now); return document; } InMemoryConfigMaster();  InMemoryConfigMaster(final ChangeManager changeManager);  InMemoryConfigMaster(final Supplier<ObjectId> objectIdSupplier);  InMemoryConfigMaster(final Supplier<ObjectId> objectIdSupplier, final ChangeManager changeManager); @Override ConfigSearchResult<T> search(final ConfigSearchRequest<T> request); @Override ConfigDocument get(final ObjectIdentifiable objectId, final VersionCorrection versionCorrection); @Override ConfigDocument add(final ConfigDocument document); @Override ConfigDocument update(final ConfigDocument document); @Override void remove(final ObjectIdentifiable objectIdentifiable); @Override ConfigDocument correct(final ConfigDocument document); @Override ChangeManager changeManager(); @Override ConfigDocument get(final UniqueId uniqueId); @Override ConfigMetaDataResult metaData(final ConfigMetaDataRequest request); @Override List<UniqueId> replaceVersions(final ObjectIdentifiable objectId, final List<ConfigDocument> replacementDocuments); @Override List<UniqueId> replaceVersion(final UniqueId uniqueId, final List<ConfigDocument> replacementDocuments); @Override List<UniqueId> replaceAllVersions(final ObjectIdentifiable objectId, final List<ConfigDocument> replacementDocuments); @Override UniqueId addVersion(final ObjectIdentifiable objectId, final ConfigDocument documentToAdd); @Override void removeVersion(final UniqueId uniqueId); @Override UniqueId replaceVersion(final ConfigDocument replacementDocument); @Override ConfigHistoryResult<R> history(final ConfigHistoryRequest<R> request); @Override Map<UniqueId, ConfigDocument> get(final Collection<UniqueId> uniqueIds); static final String DEFAULT_OID_SCHEME; }
@Test(expectedExceptions = DataNotFoundException.class) public void test_update_emptyMaster() { ConfigItem<ExternalId> item = ConfigItem.of(VAL1); item.setUniqueId(OTHER_UID); _testEmpty.update(new ConfigDocument(item)); }