@Test(expected = YardException.class) public void testStoreOnReadOnlyYard() throws YardException { RdfRepresentation rep = RdfValueFactory.getInstance().createRepresentation("http://www.test.org/addedEntity"); rep.addReference(RDF.type.getUnicodeString(), SKOS.Concept.getUnicodeString()); rep.addNaturalText(SKOS.prefLabel.getUnicodeString(), "added Entity", "en"); rep.addNaturalText(SKOS.prefLabel.getUnicodeString(), "hinzugefüte Entity", "de"); readonlyYard.store(rep); }
/** * Used by {@link #testRetrival()} to validate that an Entity is correctly retrieved by the tested * {@link ClerezzaYard}s. * * @param entity key - URI; value - expected RDF data */ private void validateEntity(ClerezzaYard yard, Entry<UriRef, TripleCollection> entity) { Representation rep = yard.getRepresentation(entity.getKey().getUnicodeString()); assertNotNull( "The Representation for " + entity.getKey() + "is missing in the " + yard.getId(), rep); assertTrue("RdfRepresentation expected", rep instanceof RdfRepresentation); TripleCollection repGraph = ((RdfRepresentation) rep).getRdfGraph(); for (Iterator<Triple> triples = entity.getValue().iterator(); triples.hasNext(); ) { Triple triple = triples.next(); assertTrue( "Data of Representation " + entity.getKey() + "is missing the triple " + triple, repGraph.remove(triple)); } assertTrue( repGraph.size() + " unexpected Triples are present in the " + "Representation of Entity " + entity.getKey(), repGraph.isEmpty()); }
@Test public void testModificationsOnReadWirteYard() throws YardException { RdfRepresentation rep = RdfValueFactory.getInstance().createRepresentation("http://www.test.org/addedEntity"); rep.addReference(RDF.type.getUnicodeString(), SKOS.Concept.getUnicodeString()); rep.addNaturalText(SKOS.prefLabel.getUnicodeString(), "added Entity", "en"); rep.addNaturalText(SKOS.prefLabel.getUnicodeString(), "hinzugefüte Entity", "de"); readwriteYard.store(rep); // test that the data where added and modified in the read/wirte grpah validateEntity( readwriteYard, singletonMap(rep.getNode(), rep.getRdfGraph()).entrySet().iterator().next()); readwriteYard.remove(rep.getId()); Assert.assertNull( "Representation " + rep.getId() + " was not correctly " + "deleted from " + readwriteYard.getId(), readwriteYard.getRepresentation(rep.getId())); }
@Test(expected = YardException.class) public void testRemovalOnReadOnlyYard() throws YardException { readonlyYard.remove(entityData.keySet().iterator().next().getUnicodeString()); }