### Question:
HistoryLogService { public URI createLogForPrivacyPreference(PrivacyPreference privacyPref) { TripleStore tripleStore = resourceStore.getTripleStore(); URI logGraph = resourceStore.createGraph(DUHO.PrivacyPreferenceLog); URI metadataGraph = tripleStore.getOrCreateMetadataGraph(logGraph); tripleStore.addAll(logGraph, privacyPref.getModel().iterator()); try { tripleStore.addAll(logGraph, resourceStore.get(privacyPref.getAllAccessSpace().next().asResource()).getModel().iterator()); } catch (NoSuchElementException e) { logger.error("The privacy preference "+privacyPref.asResource()+" does not contain any AccessSpace: "+e.getMessage(), e); } catch (NotFoundException e) { logger.error("The privacy preference "+privacyPref.asResource()+" references an AccessSpace which does not exist: "+e.getMessage(), e); } tripleStore.addStatement(metadataGraph, logGraph, DUHO.timestamp, DateUtil.currentDateTimeAsLiteral()); broadcastManager.sendBroadcast(new Event(resourceStore.getName(), Event.ACTION_GRAPH_ADD, logGraph)); return logGraph; } HistoryLogService(ResourceStore resourceStore); void cleanup(URI type, Calendar from); URI createLogForContext(URI contextGraph); URI createLogForPrivacyPreference(PrivacyPreference privacyPref);  }### Answer:
@Test public void testCreateLogForPrivacyPreference() throws ResourceExistsException { URI testGraph = new URIImpl("test:graph"); URI group1 = new URIImpl("urn:group:1"); URI person3 = new URIImpl("urn:person:3"); URI person14 = new URIImpl("urn:person:14"); PrivacyPreference privacyPref = modelFactory.getPPOFactory().createPrivacyPreference(); privacyPref.setPrefLabel("example"); AccessSpace accessSpace = modelFactory.getNSOFactory().createAccessSpace(); accessSpace.addIncludes(group1); accessSpace.addExcludes(person3); privacyPref.setAccessSpace(accessSpace); resourceStore.createOrUpdate(testGraph, privacyPref); resourceStore.createOrUpdate(testGraph, accessSpace); URI logUri = historyLogService.createLogForPrivacyPreference(privacyPref); URI metadataUri = tripleStore.getOrCreateMetadataGraph(logUri); accessSpace.addIncludes(person14); resourceStore.createOrUpdate(testGraph, accessSpace); assertTrue(tripleStore.containsStatements(metadataUri, logUri, RDF.type, DUHO.PrivacyPreferenceLog)); assertTrue(tripleStore.containsStatements(logUri, privacyPref, RDF.type, PPO.PrivacyPreference)); assertTrue(tripleStore.containsStatements(logUri, privacyPref, PPO.hasAccessSpace, accessSpace)); assertTrue(tripleStore.containsStatements(logUri, accessSpace, NSO.includes, group1)); assertTrue(tripleStore.containsStatements(logUri, accessSpace, NSO.excludes, person3)); assertFalse(tripleStore.containsStatements(logUri, accessSpace, NSO.includes, person14)); assertTrue(tripleStore.containsStatements(testGraph, accessSpace, NSO.includes, person14)); }