* @throws YardException
*/
@Test
public void testGetRepresentation() throws YardException {
String id = "urn:yard.test.testGetRepresentation.id";
Yard yard = getYard();
String field = "urn:the.field:used.for.this.Test";
String value1 = "this is a test";
// Representations created via the yard need to be created (as empty
// representation within the yard
Representation test = create(id, true);
// retrieve the representation from the store
Representation retrieved = yard.getRepresentation(id);
assertNotNull(retrieved);
// they MUST NOT be the same, but the MUST be equals
// Note:
// the fact that two representations with the same id are equals is tested
// by the unit tests for the representation interface
assertEquals(test, retrieved);
assertNotSame("getRepresentation MUST return an new instance for each "
+ "call, so that changes in one return instance do not influence "
+ "an other returned instance!", test, retrieved);
// now add a property to the original one
test.add(field, value1);
// and check that the retrieved does not have the value
assertFalse(retrieved.get(field).hasNext());
// now store the representation and check that updated are not reflected
// within the retrieved one
yard.store(test);
assertFalse(retrieved.get(field).hasNext());
// now retrieve again an representation
retrieved = null;
retrieved = yard.getRepresentation(id);
// now the Representation MUST HAVE the new field
assertTrue(retrieved.get(field).hasNext());
assertEquals(value1, retrieved.getFirst(field));
// finally retrieve a second and perform the change test again
Representation retrieved2 = yard.getRepresentation(id);
retrieved.removeAll(field);
// check the value is still in retrieved2
assertTrue(retrieved2.get(field).hasNext());
assertEquals(value1, retrieved2.getFirst(field));