@Override public Representation create() throws YardException { return yard.create(); }
@Override public Representation create(String id) throws IllegalArgumentException, YardException { return yard.create(id); }
@Override public Representation create() throws YardException { return yard.create(); }
@Override public Representation create(String id) throws IllegalArgumentException, YardException { return yard.create(id); }
/** * Lookups (or initialises) the metadata for the entity with the parsed id * @param entityId The id of the entity * @param init if the metadata should be initialised of not existing * @return the metadata for that Entity or <code>null</code> if not existing * and <code>init == false</code> * @throws YardException */ private Representation lookupMetadata(String entityId, boolean init) throws YardException { Representation metadata; //TODO: check the asumption that the Metadata always use the // extension ".meta" String metaID = entityId+".meta"; metadata = entityhubYard.getRepresentation(metaID); if(metadata == null){ metadata = entityhubYard.create(metaID); } return metadata; } /**
/** * Lookups (or initialises) the metadata for the entity with the parsed id * @param entityId The id of the entity * @param init if the metadata should be initialised of not existing * @return the metadata for that Entity or <code>null</code> if not existing * and <code>init == false</code> * @throws YardException */ private Representation lookupMetadata(String entityId, boolean init) throws YardException { Representation metadata; //TODO: check the asumption that the Metadata always use the // extension ".meta" String metaID = entityId+".meta"; metadata = entityhubYard.getRepresentation(metaID); if(metadata == null){ metadata = entityhubYard.create(metaID); } return metadata; } /**
protected Representation create() throws YardException { Representation r = getYard().create(); representationIds.add(r.getId()); return r; }
@Test(expected = IllegalArgumentException.class) public void testCreateWithEmptyString() throws YardException { getYard().create("");// throws an IllegalArgumentException }
@Test public void testDefaultCreate() throws YardException { Yard yard = getYard(); Representation test = yard.create(); assertNotNull(test); Representation test2 = yard.create(); assertNotNull(test2); assertNotSame(test, test2); assertFalse("Two Representation created with create() MUST NOT be equals", test.equals(test2)); }
@Test public void testCreateWithNull() throws YardException { Yard yard = getYard(); Representation test = yard.create(null); assertNotNull("Parsing NULL to create(String) MUST create a valid Representation", test); representationIds.add(test.getId()); // add id to cleanup list Representation test2 = yard.create(null); assertNotNull("Parsing NULL to create(String) MUST create a valid Representation", test2); representationIds.add(test2.getId()); // add id to cleanup list assertNotSame(test, test2); assertFalse("Two Representation created with create(null) MUST NOT be equals", test.equals(test2)); }
protected Representation create(String id, boolean store) throws YardException { Representation r; if (store) { r = getYard().create(id); } else if (id != null && !id.isEmpty()) { r = getYard().getValueFactory().createRepresentation(id); } else { throw new IllegalArgumentException("If store is FALSE the id MUST NOT be NULL nor EMPTY!"); } representationIds.add(r.getId()); return r; }
@Test(expected = IllegalArgumentException.class) public void testCreateWithExistingId() throws YardException { Yard yard = getYard(); Representation test = create(); assertNotNull(test); yard.create(test.getId()); // throws an IllegalArgumentException }
Representation localRep = entityhubYard.create(constructResourceId(DEFAULT_MANAGED_ENTITY_PREFIX)); Entity localEntity = loadEntity(localRep); importEntity(remoteEntity, site, localEntity, valueFactory); Representation entityMappingRepresentation = entityhubYard.create( constructResourceId(DEFAULT_MAPPING_PREFIX)); Entity entityMappingEntity = loadEntity(entityMappingRepresentation);
/** * 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())); }
Representation localRep = entityhubYard.create(constructResourceId(DEFAULT_MANAGED_ENTITY_PREFIX)); Entity localEntity = loadEntity(localRep); importEntity(remoteEntity, site, localEntity, valueFactory); Representation entityMappingRepresentation = entityhubYard.create( constructResourceId(DEFAULT_MAPPING_PREFIX)); Entity entityMappingEntity = loadEntity(entityMappingRepresentation);
/** * 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 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())); } /**
Representation test1 = yard.create(id); // create and add