CatalogProvUtilsImpl implements CatalogProvUtils { @Override public CreateActivity startCreateActivity(User user) { ActivityConfig config = new ActivityConfig.Builder(Collections.singleton(CreateActivity.class), user) .build(); Activity activity = initializeActivity(config); provenanceService.addActivity(activity); return createActivityFactory.getExisting(activity.getResource(), activity.getModel()).orElseThrow(() -> new IllegalStateException("CreateActivity not made correctly")); }  @Override CreateActivity startCreateActivity(User user); @Override void endCreateActivity(CreateActivity createActivity, Resource recordIRI); @Override DeleteActivity startDeleteActivity(User user, Resource recordIri); @Override void endDeleteActivity(DeleteActivity deleteActivity, Record record); @Override void removeActivity(Activity activity);  }
@Test public void startCreateActivityTest() throws Exception { when(provenanceService.createActivity(any(ActivityConfig.class))).thenReturn(createActivity); CreateActivity result = utils.startCreateActivity(user); verify(provenanceService).createActivity(any(ActivityConfig.class)); verify(provenanceService).addActivity(createActivity); verify(mobi).getServerIdentifier(); assertTrue(result.getModel().contains(createActivity.getResource(), VALUE_FACTORY.createIRI(Activity.startedAtTime_IRI), null)); assertTrue(result.getModel().contains(createActivity.getResource(), VALUE_FACTORY.createIRI(predAtLocation), null)); }
@Test(expected = IllegalStateException.class) public void startCreateActivityWithNoCreateActivityTest() { Activity activity1 = activityFactory.createNew(VALUE_FACTORY.createIRI("http: when(provenanceService.createActivity(any(ActivityConfig.class))).thenReturn(activity1); utils.startCreateActivity(user); }