SimpleVersioningManager implements VersioningManager { @Override public Resource merge(Resource catalogId, Resource recordId, Resource sourceBranchId, Resource targetBranchId, User user, Model additions, Model deletions) { try (RepositoryConnection conn = getCatalogRepoConnection()) { OrmFactory<? extends VersionedRDFRecord> correctFactory = getFactory(recordId, conn); VersionedRDFRecord record = catalogUtils.getRecord(catalogId, recordId, correctFactory, conn); VersioningService<VersionedRDFRecord> service = versioningServices.get(correctFactory.getTypeIRI().stringValue()); conn.begin(); Resource commitId = mergeBranches(record, service, sourceBranchId, targetBranchId, user, additions, deletions, conn); conn.commit(); return commitId; } }  @Override Resource commit(Resource catalogId, Resource recordId, Resource branchId, User user, String message); @Override Resource commit(Resource catalogId, Resource recordId, Resource branchId, User user,
                                            String message, RepositoryConnection conn); @Override Resource commit(Resource catalogId, Resource recordId, Resource branchId, User user, String message,
                                            Model additions, Model deletions); @Override Resource commit(Resource catalogId, Resource recordId, Resource branchId, User user, String message,
                                            Model additions, Model deletions, RepositoryConnection conn); @Override Resource merge(Resource catalogId, Resource recordId, Resource sourceBranchId, Resource targetBranchId,
                                           User user, Model additions, Model deletions); @Override Resource merge(Resource catalogId, Resource recordId, Resource sourceBranchId, Resource targetBranchId,
                                           User user, Model additions, Model deletions, RepositoryConnection conn);  }
@Test public void mergeWithVersionedRDFRecordTest() throws Exception { Model additions = MODEL_FACTORY.createModel(); Model deletions = MODEL_FACTORY.createModel(); Resource result = manager.merge(CATALOG_IRI, record.getResource(), sourceBranch.getResource(), targetBranch.getResource(), user, additions, deletions); assertEquals(commit.getResource(), result); verify(catalogUtils).getRecord(eq(CATALOG_IRI), eq(record.getResource()), eq(versionedRDFRecordFactory), any(RepositoryConnection.class)); verify(baseService).getSourceBranch(eq(record), eq(sourceBranch.getResource()), any(RepositoryConnection.class)); verify(baseService).getTargetBranch(eq(record), eq(targetBranch.getResource()), any(RepositoryConnection.class)); verify(baseService).getBranchHeadCommit(eq(sourceBranch), any(RepositoryConnection.class)); verify(baseService).getBranchHeadCommit(eq(targetBranch), any(RepositoryConnection.class)); verify(baseService).addCommit(eq(targetBranch), eq(user), eq("Merge of Source into Target"), eq(additions), eq(deletions), eq(commit), eq(commit), any(RepositoryConnection.class)); }
@Test public void mergeWithOntologyRecordTest() throws Exception { Model additions = MODEL_FACTORY.createModel(); Model deletions = MODEL_FACTORY.createModel(); Resource result = manager.merge(CATALOG_IRI, ontologyRecord.getResource(), sourceBranch.getResource(), targetBranch.getResource(), user, additions, deletions); assertEquals(commit.getResource(), result); verify(catalogUtils).getRecord(eq(CATALOG_IRI), eq(ontologyRecord.getResource()), eq(ontologyRecordFactory), any(RepositoryConnection.class)); verify(ontologyService).getSourceBranch(eq(ontologyRecord), eq(sourceBranch.getResource()), any(RepositoryConnection.class)); verify(ontologyService).getTargetBranch(eq(ontologyRecord), eq(targetBranch.getResource()), any(RepositoryConnection.class)); verify(ontologyService).getBranchHeadCommit(eq(sourceBranch), any(RepositoryConnection.class)); verify(ontologyService).getBranchHeadCommit(eq(targetBranch), any(RepositoryConnection.class)); verify(ontologyService).addCommit(eq(targetBranch), eq(user), eq("Merge of Source into Target"), eq(additions), eq(deletions), eq(commit), eq(commit), any(RepositoryConnection.class)); }
@Test public void mergeWithVersionedRDFRecordWithRepoConnTest() throws Exception { Model additions = MODEL_FACTORY.createModel(); Model deletions = MODEL_FACTORY.createModel(); Resource result = manager.merge(CATALOG_IRI, record.getResource(), sourceBranch.getResource(), targetBranch.getResource(), user, additions, deletions, repo.getConnection()); assertEquals(commit.getResource(), result); verify(catalogUtils).getRecord(eq(CATALOG_IRI), eq(record.getResource()), eq(versionedRDFRecordFactory), any(RepositoryConnection.class)); verify(baseService).getSourceBranch(eq(record), eq(sourceBranch.getResource()), any(RepositoryConnection.class)); verify(baseService).getTargetBranch(eq(record), eq(targetBranch.getResource()), any(RepositoryConnection.class)); verify(baseService).getBranchHeadCommit(eq(sourceBranch), any(RepositoryConnection.class)); verify(baseService).getBranchHeadCommit(eq(targetBranch), any(RepositoryConnection.class)); verify(baseService).addCommit(eq(targetBranch), eq(user), eq("Merge of Source into Target"), eq(additions), eq(deletions), eq(commit), eq(commit), any(RepositoryConnection.class)); }
@Test public void mergeWithOntologyRecordWithRepoConnTest() throws Exception { Model additions = MODEL_FACTORY.createModel(); Model deletions = MODEL_FACTORY.createModel(); Resource result = manager.merge(CATALOG_IRI, ontologyRecord.getResource(), sourceBranch.getResource(), targetBranch.getResource(), user, additions, deletions, repo.getConnection()); assertEquals(commit.getResource(), result); verify(catalogUtils).getRecord(eq(CATALOG_IRI), eq(ontologyRecord.getResource()), eq(ontologyRecordFactory), any(RepositoryConnection.class)); verify(ontologyService).getSourceBranch(eq(ontologyRecord), eq(sourceBranch.getResource()), any(RepositoryConnection.class)); verify(ontologyService).getTargetBranch(eq(ontologyRecord), eq(targetBranch.getResource()), any(RepositoryConnection.class)); verify(ontologyService).getBranchHeadCommit(eq(sourceBranch), any(RepositoryConnection.class)); verify(ontologyService).getBranchHeadCommit(eq(targetBranch), any(RepositoryConnection.class)); verify(ontologyService).addCommit(eq(targetBranch), eq(user), eq("Merge of Source into Target"), eq(additions), eq(deletions), eq(commit), eq(commit), any(RepositoryConnection.class)); }