JenaTypes implements Types { @Override public void addTypes(NamedResource individual, URI context, Set<URI> types) throws OntoDriverException { Objects.requireNonNull(individual, "individual"); Objects.requireNonNull(types, "types"); beforeCallback.execute(); adapter.typesHandler().addTypes(individual, context, types); afterCallback.execute(); } JenaTypes(JenaAdapter adapter, Procedure beforeCallback, Procedure afterCallback); @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 addTypesCallsBeforeHandlerBeforeAddingTypes() throws Exception { final Set<URI> toAdd = Collections.singleton(Generator.generateUri()); types.addTypes(SUBJECT, null, toAdd); final InOrder inOrder = Mockito.inOrder(beforeMock, typesHandlerMock); inOrder.verify(beforeMock).execute(); inOrder.verify(typesHandlerMock).addTypes(SUBJECT, null, toAdd); }
@Test public void addTypesCallsAfterHandlerAfterAddingTypes() throws Exception { final Set<URI> toAdd = Collections.singleton(Generator.generateUri()); types.addTypes(SUBJECT, null, toAdd); final InOrder inOrder = Mockito.inOrder(afterMock, typesHandlerMock); inOrder.verify(typesHandlerMock).addTypes(SUBJECT, null, toAdd); inOrder.verify(afterMock).execute(); }