@Test public void insert_and_load() { String docId = randomUUID().toString(); assertThat(documentStore.getFullGraph(docId).isEmpty()).isTrue(); Product product = new Product(); product.id = 123l; product.name = "product"; ObjectVersion<String> versionOne = versionManager.versionBuilder(product).build(); documentStore.append(docId, versionManager.getVersionNode(versionOne.revision)); assertThat(documentStore.getFullGraph(docId).isEmpty()).isTrue(); documentStore.publish(); ObjectVersionGraph<String> versionGraph = documentStore.getFullGraph(docId); assertThat(versionGraph.isEmpty()).isFalse(); assertThat(versionGraph.getTip().getVersion()).isEqualTo(versionOne); product.price = new Price(new BigDecimal(10)); product.tags = ImmutableList.of("tag", "and", "another"); product.vat = 22.5; documentStore.append(docId, versionManager.versionBuilder(product).buildVersionNode()); product.outOfStock = true; ObjectVersion<String> lastVersion = versionManager.versionBuilder(product).build(); documentStore.append(docId, versionManager.getVersionNode(lastVersion.revision)); assertThat(documentStore.getFullGraph(docId).getTip().getVersion()).isEqualTo(versionOne); documentStore.publish(); versionGraph = documentStore.getFullGraph(docId); assertThat(versionGraph.getTip().getVersion()).isEqualTo(lastVersion); versionManager.init(versionGraph); Product persisted = versionManager.mergeBranches(Version.DEFAULT_BRANCH).object; assertThat(persisted.id).isEqualTo(product.id); assertThat(persisted.name).isEqualTo(product.name); assertThat(persisted.outOfStock).isEqualTo(product.outOfStock); assertThat(persisted.price.amount).isEqualTo(product.price.amount); assertThat(persisted.tags).isEqualTo(product.tags); assertThat(persisted.vat).isEqualTo(product.vat); }
public void append(Id docId, VersionNode<PropertyPath, Object, M> version) { options.transactions.writeRequired(() -> { doAppend(ImmutableMultimap.of(docId, version)); return null; }); }
DocumentVersionStoreJdbc extends AbstractVersionStoreJdbc<Id, M, V, DocumentUpdateBatch<Id, M, V>, DocumentStoreOptions<Id, M, V>> { public void append(Id docId, VersionNode<PropertyPath, Object, M> version) { options.transactions.writeRequired(() -> { doAppend(ImmutableMultimap.of(docId, version)); return null; }); } }
DocumentVersionStoreJdbc extends AbstractVersionStoreJdbc<Id, M, V, DocumentUpdateBatch<Id, M, V>, DocumentStoreOptions<Id, M, V>> { public void append(Id docId, VersionNode<PropertyPath, Object, M> version) { options.transactions.writeRequired(() -> { doAppend(ImmutableMultimap.of(docId, version)); return null; }); } @SuppressWarnings("unused")  DocumentVersionStoreJdbc();  DocumentVersionStoreJdbc(DocumentStoreOptions<Id, M, V> options); }
DocumentVersionStoreJdbc extends AbstractVersionStoreJdbc<Id, M, V, DocumentUpdateBatch<Id, M, V>, DocumentStoreOptions<Id, M, V>> { public void append(Id docId, VersionNode<PropertyPath, Object, M> version) { options.transactions.writeRequired(() -> { doAppend(ImmutableMultimap.of(docId, version)); return null; }); } @SuppressWarnings("unused")  DocumentVersionStoreJdbc();  DocumentVersionStoreJdbc(DocumentStoreOptions<Id, M, V> options); void append(Id docId, VersionNode<PropertyPath, Object, M> version); void append(Id docId, Iterable<VersionNode<PropertyPath, Object, M>> versions); void append(Multimap<Id, VersionNode<PropertyPath, Object, M>> versionsByDocId); @Override DocumentUpdateBatch<Id, M, V> updateBatch(Collection<Id> ids); }
DocumentVersionStoreJdbc extends AbstractVersionStoreJdbc<Id, M, V, DocumentUpdateBatch<Id, M, V>, DocumentStoreOptions<Id, M, V>> { public void append(Id docId, VersionNode<PropertyPath, Object, M> version) { options.transactions.writeRequired(() -> { doAppend(ImmutableMultimap.of(docId, version)); return null; }); } @SuppressWarnings("unused")  DocumentVersionStoreJdbc();  DocumentVersionStoreJdbc(DocumentStoreOptions<Id, M, V> options); void append(Id docId, VersionNode<PropertyPath, Object, M> version); void append(Id docId, Iterable<VersionNode<PropertyPath, Object, M>> versions); void append(Multimap<Id, VersionNode<PropertyPath, Object, M>> versionsByDocId); @Override DocumentUpdateBatch<Id, M, V> updateBatch(Collection<Id> ids);  }