@Test(expected = UnsupportedOperationException.class) public final void shouldThrowExceptionWhenTryingToGetSearchCriteria() 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)); tree.find(); }
@Override public SearchCriteriaBuilder find() { throw new UnsupportedOperationException("Cannot find entity for detached entity tree"); }
DetachedEntityTreeImpl extends AbstractList<Entity> implements EntityTree { @Override public SearchCriteriaBuilder find() { throw new UnsupportedOperationException("Cannot find entity for detached entity tree"); } }
DetachedEntityTreeImpl extends AbstractList<Entity> implements EntityTree { @Override public SearchCriteriaBuilder find() { throw new UnsupportedOperationException("Cannot find entity for detached entity tree"); } DetachedEntityTreeImpl(final List<Entity> entities); }
DetachedEntityTreeImpl extends AbstractList<Entity> implements EntityTree { @Override public SearchCriteriaBuilder find() { throw new UnsupportedOperationException("Cannot find entity for detached entity tree"); } 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(); }
DetachedEntityTreeImpl extends AbstractList<Entity> implements EntityTree { @Override public SearchCriteriaBuilder find() { throw new UnsupportedOperationException("Cannot find entity for detached entity tree"); } 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();  }