TagDaoHelper { public List<TagEntity> getTagChildrenEntities(TagEntity parentTagEntity) { Integer maxAllowedTagNesting = configurationHelper.getProperty(ConfigurationValue.MAX_ALLOWED_TAG_NESTING, Integer.class); List<TagEntity> parentTagEntities = new ArrayList<>(); parentTagEntities.add(parentTagEntity); List<TagEntity> tagEntities = new ArrayList<>(); for (int level = 0; !parentTagEntities.isEmpty() && level < maxAllowedTagNesting; level++) { parentTagEntities = tagDao.getChildrenTags(parentTagEntities); tagEntities.addAll(parentTagEntities); } return tagEntities; }  void assertDisplayNameDoesNotExistForTag(String tagCode, String displayName); List<TagEntity> getTagChildrenEntities(TagEntity parentTagEntity); TagEntity getTagEntity(TagKey tagKey); void validateParentTagEntity(TagEntity tagEntity, TagEntity parentTagEntity); void validateParentTagType(String tagTypeCode, String parentTagTypeCode);  }
@Test public void testGetTagChildrenEntities() { TagTypeEntity tagTypeEntity = new TagTypeEntity(); tagTypeEntity.setCode(TAG_TYPE_CODE); TagEntity tagEntity = new TagEntity(); tagEntity.setTagType(tagTypeEntity); tagEntity.setTagCode(TAG_CODE); tagEntity.setDisplayName(TAG_DISPLAY_NAME); List<TagEntity> parentTagEntities = new ArrayList<>(); parentTagEntities.add(tagEntity); when(configurationHelper.getProperty(ConfigurationValue.MAX_ALLOWED_TAG_NESTING, Integer.class)).thenReturn(1); when(tagDao.getChildrenTags(parentTagEntities)).thenReturn(parentTagEntities); List<TagEntity> result = tagDaoHelper.getTagChildrenEntities(tagEntity); assertThat("Result not equal to parent tag entities list.", result, is(equalTo(parentTagEntities))); verify(configurationHelper).getProperty(ConfigurationValue.MAX_ALLOWED_TAG_NESTING, Integer.class); verify(tagDao).getChildrenTags(parentTagEntities); verifyNoMoreInteractions(configurationHelper, tagDao); }