@Test
public void verifyUniqueFieldsAreMappedToHibernateObject()
{

   Schema schema = createSchema( DataElement.class, "dataElement",
       Stream.of(
        createUniqueProperty( Integer.class, "id", true, true ),
        createProperty( String.class, "name", true, true ),
        createUniqueProperty( String.class, "code", true, true ),
        createProperty( Date.class, "created", true, true ),
        createProperty( Date.class, "lastUpdated", true, true ),
        createProperty( Integer.class, "int", true, true )).collect(toList())
   );
    mockSession( "SELECT code,id from " + schema.getKlass().getSimpleName() );
    List<Object[]> l = new ArrayList<>();
    l.add( new Object[] { "abc", 123456 } );
    l.add( new Object[] { "bce", 123888 } );
    l.add( new Object[] { "def", 123999 } );
    when( query.getResultList() ).thenReturn( l );
    List<DataElement> result = (List<DataElement>) subject.fetch( schema );
    assertThat( result, hasSize( 3 ) );
    assertThat( result, IsIterableContainingInAnyOrder.containsInAnyOrder(
        allOf(
            hasProperty( "code", is( "abc" ) ),
            hasProperty( "id", is( 123456L ) )
        ),
        allOf(
            hasProperty( "code", is( "bce" ) ),
            hasProperty( "id", is( 123888L ) )
        ),
        allOf(
            hasProperty( "code", is( "def" ) ),
            hasProperty( "id", is( 123999L ) )
        )
    ) );
}