@Test
public void whenNewEntityThenCanFindEntityAndCorrectValues()
throws Exception
{
UnitOfWork unitOfWork = module.newUnitOfWork();
try
{
TestEntity instance = createEntity( unitOfWork );
unitOfWork.complete();
// Find entity
unitOfWork = module.newUnitOfWork();
instance = unitOfWork.get( instance );
// Check state
assertThat( "property 'name' has correct value", instance.name().get(), equalTo( "Test" ) );
assertThat( "property 'unsetName' has correct value", instance.unsetName().get(), equalTo( null ) );
assertThat( "property has correct value", instance.valueProperty()
.get()
.valueProperty()
.get()
.stringValue().get(), equalTo( "Bar" ) );
assertThat( "property has correct value", instance.valueProperty()
.get()
.listProperty()
.get().get( 0 ), equalTo( "Foo" ) );
assertThat( "property has correct value", instance.valueProperty()
.get()
.valueProperty()
.get()
.anotherValue()
.get()
.bling().get(), equalTo( "BlinkLjus" ) );
assertThat( "property has correct value", instance.valueProperty()
.get()
.tjabbaProperty()
.get()
.bling().get(), equalTo( "Brakfis" ) );
Map<String, String> mapValue = new HashMap<String, String>();
mapValue.put( "foo", "bar" );
assertThat( "property has correct value", instance.valueProperty()
.get()
.serializableProperty().get(), equalTo( mapValue ) );
assertThat( "association has correct value", instance.association().get(), equalTo( instance ) );
assertThat( "manyAssociation has correct value", instance.manyAssociation()
.iterator().next(), equalTo( instance ) );
unitOfWork.discard();
}
finally
{
unitOfWork.discard();
}
}