### Question:
EntityTreeImpl extends AbstractList<Entity> implements EntityTree { @Override public SearchCriteriaBuilder find() { return dataDefinition.find().add( SearchRestrictions.belongsTo(joinFieldDefinition.getName(), ((BelongsToType) joinFieldDefinition.getType()).getDataDefinition(), belongsToId)); } EntityTreeImpl(final DataDefinition dataDefinition, final String joinFieldName, final Long belongsToId); @Override SearchCriteriaBuilder find(); @Override Entity get(final int index); @Override int size(); @Override EntityTreeNodeImpl getRoot(); @Override String toString();  }### Answer:
@Test public void shouldReturnCriteriaBuilder() throws Exception { BelongsToType fieldType = mock(BelongsToType.class); InternalDataDefinition dataDefinition = mock(InternalDataDefinition.class, RETURNS_DEEP_STUBS); given(fieldType.getDataDefinition()).willReturn(dataDefinition); FieldDefinition fieldDefinition = mock(FieldDefinition.class); given(fieldDefinition.getType()).willReturn(fieldType); given(fieldDefinition.getName()).willReturn("field"); given(dataDefinition.getField("tree")).willReturn(fieldDefinition); SearchCriteriaBuilder searchCriteriaBuilder = mock(SearchCriteriaBuilder.class); given( dataDefinition.find().createAlias(fieldDefinition.getName(), fieldDefinition.getName()) .add(SearchRestrictions.eq(fieldDefinition.getName() + ".id", 1L))).willReturn(searchCriteriaBuilder); EntityList list = new EntityListImpl(dataDefinition, "tree", 1L); assertEquals(searchCriteriaBuilder, list.find()); }