### Question:
InMemoryRepository extends RDFRepositoryBase { public void addData(Model newData){ model.getNamedModel(DEFAULT_GRAPH).add(newData); } InMemoryRepository(); private  InMemoryRepository(SPARQLQueryBuilder sqb, UniqueURIGenerator uriGenerator); void addData(Model newData); Model getModel();  }### Answer:
@Test public void test_add_data(){ Model testModel = ModelFactory.createDefaultModel(); Statement s = createStatement( createResource("http: NAME, createPlainLiteral("Test")); repository.addData(testModel); assertFalse(repository.askIfStatementExists(s)); testModel.add(s); repository.addData(testModel); assertTrue(repository.askIfStatementExists(s)); }
@Test public void test_retrieve_work_by_id() throws Exception { repository.addData(ModelFactory.createDefaultModel().add(workWithPublicationStatements)); Model testModel = repository.retrieveResourceByURI(new XURI(workUri), true); assertTrue("Work <" + workUri + "> should be a Work", testModel.contains(workIsAWorkStmt)); assertTrue("Work <" + workUri + "> should should have name", testModel.contains(workHasNameStmt)); }
@Test public void test_retrieve_work_by_id2() throws Exception { Model temp = ModelFactory.createDefaultModel(); temp.add(workWithPublicationStatements); repository.addData(temp); Model testModel = repository.retrieveWorkAndLinkedResourcesByURI(new XURI(workUri)); List<Statement> missing = workWithPublicationStatements.stream() .filter(stmt -> !testModel.contains(stmt)) .collect(Collectors.<Statement>toList()); assertTrue("oups, some statements are missing: " + missing, missing.isEmpty()); }
@Test public void test_retrieve_publication_by_id() throws Exception { Model temp = ModelFactory.createDefaultModel(); temp.add(publHasANameStmt); repository.addData(temp); Model testModel = repository.retrieveResourceByURI(new XURI(publicationUri),true); assertTrue(testModel.contains(publHasANameStmt)); }