@Test public void shouldLazyLoadEntitiesUsingProxy() throws Exception { InternalDataDefinition dataDefinition = mock(InternalDataDefinition.class, RETURNS_DEEP_STUBS); FieldDefinition fieldDefinition = mock(FieldDefinition.class); BelongsToType fieldType = mock(BelongsToType.class); Entity entity1 = new DefaultEntity(dataDefinition, 1L); Entity entity2 = new DefaultEntity(dataDefinition, 2L); given(fieldDefinition.getName()).willReturn("joinField"); given(fieldDefinition.getType()).willReturn(fieldType); given(fieldType.getDataDefinition()).willReturn(dataDefinition); given(dataDefinition.isEnabled()).willReturn(true); given(dataDefinition.getField("joinField")).willReturn(fieldDefinition); given( dataDefinition.find().createAlias(fieldDefinition.getName(), fieldDefinition.getName()) .add(SearchRestrictions.eq(fieldDefinition.getName() + ".id", 5L)).list().getEntities()).willReturn( Lists.newArrayList(entity1, entity2)); List<Entity> entityList = new EntityListImpl(dataDefinition, "joinField", 5L); assertNotNull(entityList); assertEquals(2, entityList.size()); assertThat(entityList, JUnitMatchers.hasItems(entity1, entity2)); }
@Override public Object getField(final Object databaseEntity, final FieldDefinition fieldDefinition) { return getField(databaseEntity, fieldDefinition, null); }
EntityServiceImpl implements EntityService { @Override public Object getField(final Object databaseEntity, final FieldDefinition fieldDefinition) { return getField(databaseEntity, fieldDefinition, null); } }
EntityServiceImpl implements EntityService { @Override public Object getField(final Object databaseEntity, final FieldDefinition fieldDefinition) { return getField(databaseEntity, fieldDefinition, null); }  }
EntityServiceImpl implements EntityService { @Override public Object getField(final Object databaseEntity, final FieldDefinition fieldDefinition) { return getField(databaseEntity, fieldDefinition, null); }  @Override Long getId(final Object databaseEntity); Boolean getActive(final Object databaseEntity); void setActive(final Object databaseEntity, final boolean active); @Override void setId(final Object databaseEntity, final Long id); @Override void setField(final Object databaseEntity, final FieldDefinition fieldDefinition, final Object value); @Override Object getField(final Object databaseEntity, final FieldDefinition fieldDefinition); Object getField(final Object databaseEntity, final FieldDefinition fieldDefinition, final Entity performer); @Override Entity convertToGenericEntity(final InternalDataDefinition dataDefinition, final Object databaseEntity); Entity convertToGenericEntity(final InternalDataDefinition dataDefinition, final Object databaseEntity,
            final Entity performer); @SuppressWarnings("unchecked") @Override Object convertToDatabaseEntity(final InternalDataDefinition dataDefinition, final Entity genericEntity,
            final Object existingDatabaseEntity); }
EntityServiceImpl implements EntityService { @Override public Object getField(final Object databaseEntity, final FieldDefinition fieldDefinition) { return getField(databaseEntity, fieldDefinition, null); }  @Override Long getId(final Object databaseEntity); Boolean getActive(final Object databaseEntity); void setActive(final Object databaseEntity, final boolean active); @Override void setId(final Object databaseEntity, final Long id); @Override void setField(final Object databaseEntity, final FieldDefinition fieldDefinition, final Object value); @Override Object getField(final Object databaseEntity, final FieldDefinition fieldDefinition); Object getField(final Object databaseEntity, final FieldDefinition fieldDefinition, final Entity performer); @Override Entity convertToGenericEntity(final InternalDataDefinition dataDefinition, final Object databaseEntity); Entity convertToGenericEntity(final InternalDataDefinition dataDefinition, final Object databaseEntity,
            final Entity performer); @SuppressWarnings("unchecked") @Override Object convertToDatabaseEntity(final InternalDataDefinition dataDefinition, final Entity genericEntity,
            final Object existingDatabaseEntity);  }