### Question:
DetachedEntityTreeImpl extends AbstractList<Entity> implements EntityTree { @Override public Entity get(final int index) { return entities.get(index); } DetachedEntityTreeImpl(final List<Entity> entities); @Override SearchCriteriaBuilder find(); @Override Entity get(final int index); @Override int size(); @Override EntityTreeNodeImpl getRoot(); boolean checkIfTreeContainsEntity(final Long entityId); @Override String toString();  }### Answer:
@Test public final void shouldReturnTreeItem() throws Exception { Entity entity1 = mock(Entity.class); Entity entity2 = mock(Entity.class); Entity entity3 = mock(Entity.class); when(entity1.getId()).thenReturn(1L); when(entity2.getId()).thenReturn(2L); when(entity3.getId()).thenReturn(3L); when(entity1.getField("parent")).thenReturn(null); when(entity2.getField("parent")).thenReturn(1L); when(entity3.getField("parent")).thenReturn(2L); when(entity1.getBelongsToField("parent")).thenReturn(null); when(entity2.getBelongsToField("parent")).thenReturn(entity1); when(entity3.getBelongsToField("parent")).thenReturn(entity2); EntityTree tree = new DetachedEntityTreeImpl(Lists.newArrayList(entity1, entity2, entity3)); Entity res1 = tree.get(0); Entity res2 = tree.get(1); Entity res3 = tree.get(2); Assert.assertEquals(entity1, res1); Assert.assertEquals(entity2, res2); Assert.assertEquals(entity3, res3); }