SimpleProvenanceService implements ProvenanceService { @Override public Activity createActivity(ActivityConfig config) { Map<Class<? extends Activity>, OrmFactory<? extends Activity>> factoryMap = getActivityFactories(); Activity activity = activityFactory.createNew(vf.createIRI(ACTIVITY_NAMESPACE + UUID.randomUUID())); for (Class<? extends Activity> type : config.getTypes()) { if (!factoryMap.containsKey(type)) { throw new IllegalStateException("No factory registered for type: " + type); } activity = factoryMap.get(type).createNew(activity.getResource(), activity.getModel()); } activity.setWasAssociatedWith(Collections.singleton(config.getUser())); activity.setGenerated(config.getGeneratedEntities()); addEntitiesToModel(config.getInvalidatedEntities(), activity.getModel()); activity.setInvalidated(config.getInvalidatedEntities()); addEntitiesToModel(config.getGeneratedEntities(), activity.getModel()); activity.setUsed(config.getUsedEntities()); addEntitiesToModel(config.getUsedEntities(), activity.getModel()); return activity; }  @Override RepositoryConnection getConnection(); @Override Activity createActivity(ActivityConfig config); @Override void addActivity(Activity activity); @Override Optional<Activity> getActivity(Resource activityIRI); @Override void updateActivity(Activity newActivity); @Override void deleteActivity(Resource activityIRI);  }
@Test public void createActivityTest() throws Exception { User user = userFactory.createNew(VALUE_FACTORY.createIRI("http: Entity generated = entityFactory.createNew(VALUE_FACTORY.createIRI("http: Entity invalidated = entityFactory.createNew(VALUE_FACTORY.createIRI("http: Entity used = entityFactory.createNew(VALUE_FACTORY.createIRI("http: ActivityConfig config = new ActivityConfig.Builder(Collections.singleton(Activity.class), user) .generatedEntity(generated) .invalidatedEntity(invalidated) .usedEntity(used) .build(); Activity result = service.createActivity(config); assertEquals(1, result.getWasAssociatedWith_resource().size()); TestCase.assertEquals(user.getResource(), result.getWasAssociatedWith_resource().iterator().next()); assertEquals(1, result.getGenerated().size()); assertTrue(result.getModel().containsAll(generated.getModel())); assertEquals(1, result.getInvalidated().size()); assertTrue(result.getModel().containsAll(invalidated.getModel())); assertEquals(1, result.getUsed().size()); assertTrue(result.getModel().containsAll(used.getModel())); }