OwlapiTypes implements Types { @Override public void addTypes(NamedResource individual, URI context, Set<URI> types) throws OntoDriverException { ensureValidity(individual, types); if (!types.isEmpty()) { adapter.getTypesHandler().addTypes(individual, context, types); } afterChangeCallback.execute(); } OwlapiTypes(OwlapiAdapter adapter, Procedure beforeCallback, Procedure afterChangeCallback); @Override Set<Axiom<URI>> getTypes(NamedResource individual, URI context, boolean includeInferred); @Override void addTypes(NamedResource individual, URI context, Set<URI> types); @Override void removeTypes(NamedResource individual, URI context, Set<URI> types);  }
@Test public void addTypesAddsTypes() throws Exception { final URI type = URI.create("http: types.addTypes(INDIVIDUAL, null, Collections.singleton(type)); verify(typesHandlerMock).addTypes(INDIVIDUAL, null, Collections.singleton(type)); }
@Test(expected = IllegalStateException.class) public void addTypesOnClosedThrowsException() throws Exception { doThrow(IllegalStateException.class).when(beforeMock).execute(); final URI type = URI.create("http: try { types.addTypes(INDIVIDUAL, null, Collections.singleton(type)); } finally { verify(typesHandlerMock, never()).addTypes(any(), any(), any()); } }
@Test public void addTypesDoesNothingWhenTypesAreEmpty() throws Exception { types.addTypes(INDIVIDUAL, null, Collections.emptySet()); verify(typesHandlerMock, never()).addTypes(any(), any(), any()); }