@Override public boolean isRepresentation(String id) throws YardException, IllegalArgumentException { return yard.isRepresentation(id); }
@Override public boolean isRepresentation(String id) throws YardException, IllegalArgumentException { return yard.isRepresentation(id); }
@Override public final boolean isRepresentation(String entityId) throws EntityhubException, IllegalArgumentException { if(entityId == null || entityId.isEmpty()){ throw new IllegalArgumentException("The parsed id MUST NOT be NULL nor empty!"); } return entityhubYard.isRepresentation(entityId); } @Override
@Override public final boolean isRepresentation(String entityId) throws EntityhubException, IllegalArgumentException { if(entityId == null || entityId.isEmpty()){ throw new IllegalArgumentException("The parsed id MUST NOT be NULL nor empty!"); } return entityhubYard.isRepresentation(entityId); } @Override
@Test(expected = IllegalArgumentException.class) public void testIsRepresentationWithNull() throws YardException { getYard().isRepresentation(null); }
@Test(expected = IllegalArgumentException.class) public void testIsRepresentationWithEmptyString() throws YardException { getYard().isRepresentation(""); }
/** * Tests that {@link Representation} IDs that are not stored by the yard are ignored by the multiple * remove method * * @throws YardException */ @Test public void testRemoveRepresentationsWithNonStoredValue() throws YardException { // NOTE: This test needs not to use the create(..) method, because we // remove the created representation form the store anyway as part of the // test String id = "urn:yard.test.testRemoveRepresentationsWithNullValue:representation.stored"; String id2 = "urn:yard.test.testRemoveRepresentationsWithNullValue:representation.notStored"; Yard yard = getYard(); Representation test = yard.create(id); // create and add assertTrue(yard.isRepresentation(test.getId())); yard.remove(Arrays.asList(test.getId(), id2)); assertFalse(yard.isRepresentation(test.getId())); assertFalse(yard.isRepresentation(id2)); }
/** * Tests if <code>null</code> values within the Iterable are ignored and do not cause an Exception * * @throws YardException */ @Test public void testRemoveRepresentationsWithNullValue() throws YardException { // NOTE: This test needs not to use the create(..) method, because we // remove the created representation form the store anyway as part of the // test String id = "urn:yard.test.testRemoveRepresentationsWithNullValue:representation.id"; Yard yard = getYard(); Representation test = yard.create(id); // create and add assertTrue(yard.isRepresentation(test.getId())); yard.remove(Arrays.asList(test.getId(), null)); assertFalse(yard.isRepresentation(test.getId())); }
@Test public void testIsRepresentation() throws YardException { String id = "urn:yard.test.testIsRepresentation:representation.id"; Yard yard = getYard(); // Representations created via the yard need to be created (as empty // representation within the yard Representation test = create(); assertTrue(yard.isRepresentation(test.getId())); // Representations created via the ValueFactory MUST NOT be added to the // Yard Representation test2 = create(id, false); assertFalse(yard.isRepresentation(test2.getId())); // now store test2 and test again yard.store(test2); assertTrue(yard.isRepresentation(test2.getId())); // now remove test and test again yard.remove(test.getId()); assertFalse(yard.isRepresentation(test.getId())); yard.remove(test2.getId()); assertFalse(yard.isRepresentation(test2.getId())); }
assertTrue(yard.isRepresentation(test1.getId())); // test if stored assertTrue(yard.isRepresentation(test2.getId())); assertFalse(yard.isRepresentation(test1.getId())); // test if removed assertFalse(yard.isRepresentation(test2.getId())); assertTrue(yard.isRepresentation(test1.getId())); // test if stored assertFalse(yard.isRepresentation(test1.getId()));
/** * Tests that multiple Representations are removed. * * @throws YardException */ @Test public void testRemoveRepresentations() throws YardException { // NOTE: This test needs not to use the create(..) method, because we // remove the created representation form the store anyway as part of the // test String id = "urn:yard.test.testRemoveRepresentationsWithNullValue:representation.id1"; String id2 = "urn:yard.test.testRemoveRepresentationsWithNullValue:representation.id2"; String field = "urn:the.field:used.for.this.Test"; String testValue = "This is a test"; Yard yard = getYard(); // use both ways to add the two Representations (should make no differences, // but one never can know ... Representation test1 = yard.create(id); // create and add Representation test2 = yard.getValueFactory().createRepresentation(id2); // create test2.add(field, testValue); // add value yard.store(test2);// store assertTrue(yard.isRepresentation(test1.getId())); // test if stored assertTrue(yard.isRepresentation(test2.getId())); yard.remove(Arrays.asList(test1.getId(), test2.getId())); // remove assertFalse(yard.isRepresentation(test1.getId())); // test if removed assertFalse(yard.isRepresentation(test2.getId())); } /**
test.add(field, testValue); assertTrue(yard.isRepresentation(test.getId())); // test if stored assertFalse(yard.isRepresentation(test.getId()));// test if removed