SimpleOntologyManager extends AbstractOntologyManager { @Override public Ontology applyChanges(Ontology ontology, Difference difference) { Model changedOntologyModel = utilsService.applyDifference(ontology.asModel(modelFactory), difference); return createOntology(changedOntologyModel); } SimpleOntologyManager(); @Reference void setValueFactory(ValueFactory valueFactory); @Reference void setModelFactory(ModelFactory modelFactory); @Reference void setSesameTransformer(SesameTransformer sesameTransformer); @Reference void setCatalogManager(CatalogManager catalogManager); @Reference void setRepositoryManager(RepositoryManager repositoryManager); @Reference void setBranchFactory(BranchFactory branchFactory); @Reference(type = '*', dynamic = true, optional = true) void addOntologyCache(OntologyCache ontologyCache); void removeOntologyCache(OntologyCache ontologyCache); @Reference void setbNodeService(BNodeService bNodeService); @Override Ontology createOntology(InputStream inputStream, boolean resolveImports); @Override Ontology createOntology(Model model); @Override Ontology applyChanges(Ontology ontology, Difference difference); @Override OntologyId createOntologyId(); @Override OntologyId createOntologyId(Resource resource); @Override OntologyId createOntologyId(IRI ontologyIRI); @Override OntologyId createOntologyId(IRI ontologyIRI, IRI versionIRI); @Override OntologyId createOntologyId(Model model);  }
@Test public void testApplyChangesDifference() { manager.applyChanges(ontology, difference); verify(catalogUtilsService).applyDifference(eq(ontologyModel), eq(difference)); }
@Test public void testApplyChangesInProgressCommit() { manager.applyChanges(ontology, inProgressCommit); verify(catalogUtilsService).getCommitDifference(eq(inProgressCommit.getResource()), any(RepositoryConnection.class)); verify(catalogUtilsService).applyDifference(eq(ontologyModel), eq(difference)); }
@Test(expected = IllegalStateException.class) public void testApplyChangesInProgressCommitDifferenceNotFoundCommit() { when(catalogUtilsService.getCommitDifference(any(Resource.class), any(RepositoryConnection.class))).thenThrow(new IllegalStateException()); manager.applyChanges(ontology, inProgressCommit); }
@Test public void testApplyChangesInProgressCommitId() { manager.applyChanges(ontology, inProgressCommit.getResource()); verify(ontologyId).getOntologyIRI(); verify(ontologyId).getOntologyIdentifier(); verify(catalogManager).getInProgressCommit(eq(catalogIRI), eq(recordIRI), eq(inProgressCommit.getResource())); verify(catalogUtilsService).getCommitDifference(eq(inProgressCommit.getResource()), any(RepositoryConnection.class)); verify(catalogUtilsService).applyDifference(eq(ontologyModel), eq(difference)); }
@Test public void testApplyChangesInProgressCommitIdOntologyIRINotSet() { when(ontologyId.getOntologyIRI()).thenReturn(Optional.empty()); manager.applyChanges(ontology, inProgressCommit.getResource()); verify(ontologyId).getOntologyIRI(); verify(ontologyId).getOntologyIdentifier(); verify(catalogManager).getInProgressCommit(eq(catalogIRI), eq(recordIRI), eq(inProgressCommit.getResource())); verify(catalogUtilsService).getCommitDifference(eq(inProgressCommit.getResource()), any(RepositoryConnection.class)); verify(catalogUtilsService).applyDifference(eq(ontologyModel), eq(difference)); }
@Test(expected = IllegalStateException.class) public void testApplyChangesInProgressCommitIdRecordNotFound() { when(ontologyId.getOntologyIRI()).thenReturn(Optional.of(versionIRI)); manager.applyChanges(ontology, inProgressCommit.getResource()); }
@Test(expected = IllegalStateException.class) public void testApplyChangesInProgressCommitIdInProgressCommitNotFound() { when(catalogManager.getInProgressCommit(any(Resource.class), any(Resource.class), any(Resource.class))).thenReturn(Optional.empty()); manager.applyChanges(ontology, inProgressCommit.getResource()); }