use of org.finra.herd.model.jpa.TagTypeEntity in project herd by FINRAOS.
the class TagDaoTest method testGetPercentageOfAllTagsZeroPercent.
@Test
public void testGetPercentageOfAllTagsZeroPercent() {
// Create a tag type entity.
TagTypeEntity tagTypeEntity = tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION);
// Create two root tag entities for the tag type with tag display name in reverse order.
List<TagEntity> rootTagEntities = Arrays.asList(tagDaoTestHelper.createTagEntity(tagTypeEntity, TAG_CODE, TAG_DISPLAY_NAME_2, TAG_DESCRIPTION), tagDaoTestHelper.createTagEntity(tagTypeEntity, TAG_CODE_2, TAG_DISPLAY_NAME, TAG_DESCRIPTION_2));
// Create an empty list
List<TagEntity> emptyList = new ArrayList<>();
// Get the list of all tags aka. 0%
assertEquals(emptyList, tagDao.getPercentageOfAllTags(0.0));
}
use of org.finra.herd.model.jpa.TagTypeEntity in project herd by FINRAOS.
the class TagDaoTest method testGetTagsByTagTypeEntityAndParentTagCode.
@Test
public void testGetTagsByTagTypeEntityAndParentTagCode() {
// Create a tag type entity.
TagTypeEntity tagTypeEntity = tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION);
// Create two root tag entities for the tag type with tag display name in reverse order.
List<TagEntity> rootTagEntities = Arrays.asList(tagDaoTestHelper.createTagEntity(tagTypeEntity, TAG_CODE, TAG_DISPLAY_NAME_2, TAG_DESCRIPTION), tagDaoTestHelper.createTagEntity(tagTypeEntity, TAG_CODE_2, TAG_DISPLAY_NAME, TAG_DESCRIPTION_2));
// Create two children for the first root tag and one child for the second with tag display name in reverse order.
List<TagEntity> childrenTagEntities = Arrays.asList(tagDaoTestHelper.createTagEntity(tagTypeEntity, TAG_CODE_3, TAG_DISPLAY_NAME_5, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION_3, rootTagEntities.get(0)), tagDaoTestHelper.createTagEntity(tagTypeEntity, TAG_CODE_4, TAG_DISPLAY_NAME_4, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION_4, rootTagEntities.get(0)), tagDaoTestHelper.createTagEntity(tagTypeEntity, TAG_CODE_5, TAG_DISPLAY_NAME_3, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION_5, rootTagEntities.get(1)));
// Get all tag entities for the tag type regardless of their parent tag field.
assertEquals(Arrays.asList(rootTagEntities.get(1), rootTagEntities.get(0), childrenTagEntities.get(2), childrenTagEntities.get(1), childrenTagEntities.get(0)), tagDao.getTagsByTagTypeEntityAndParentTagCode(tagTypeEntity, NO_PARENT_TAG_CODE, NO_IS_PARENT_TAG_NULL_FLAG));
// Get root tag entities (parent tag must not be set).
assertEquals(Arrays.asList(rootTagEntities.get(1), rootTagEntities.get(0)), tagDao.getTagsByTagTypeEntityAndParentTagCode(tagTypeEntity, NO_PARENT_TAG_CODE, PARENT_TAG_IS_NULL));
// Get all non-root tag entities (parent tag must be set).
assertEquals(Arrays.asList(childrenTagEntities.get(2), childrenTagEntities.get(1), childrenTagEntities.get(0)), tagDao.getTagsByTagTypeEntityAndParentTagCode(tagTypeEntity, NO_PARENT_TAG_CODE, PARENT_TAG_IS_NOT_NULL));
// Get all immediate children of the root tag.
assertEquals(Arrays.asList(childrenTagEntities.get(1), childrenTagEntities.get(0)), tagDao.getTagsByTagTypeEntityAndParentTagCode(tagTypeEntity, TAG_CODE, NO_IS_PARENT_TAG_NULL_FLAG));
// Get all immediate children of the root tag when isParentTagNull flag is set to true (the flag value should get ignored).
assertEquals(Arrays.asList(childrenTagEntities.get(1), childrenTagEntities.get(0)), tagDao.getTagsByTagTypeEntityAndParentTagCode(tagTypeEntity, TAG_CODE, PARENT_TAG_IS_NULL));
// Get all immediate children of the root tag by passing all case-insensitive parameters in lowercase.
assertEquals(Arrays.asList(childrenTagEntities.get(1), childrenTagEntities.get(0)), tagDao.getTagsByTagTypeEntityAndParentTagCode(tagTypeEntity, TAG_CODE.toUpperCase(), NO_IS_PARENT_TAG_NULL_FLAG));
// Get all immediate children of the root tag by passing all case-insensitive parameters in lowercase.
assertEquals(Arrays.asList(childrenTagEntities.get(1), childrenTagEntities.get(0)), tagDao.getTagsByTagTypeEntityAndParentTagCode(tagTypeEntity, TAG_CODE.toLowerCase(), NO_IS_PARENT_TAG_NULL_FLAG));
// Create another tag type entity without any tag associated with it.
TagTypeEntity invalidTagTypeEntity = tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE_2, TAG_TYPE_DISPLAY_NAME_2, TAG_TYPE_ORDER_2, TAG_TYPE_DESCRIPTION_2);
// Try to get all immediate children of the root tag with invalid values for all input parameters.
assertTrue(tagDao.getTagsByTagTypeEntityAndParentTagCode(invalidTagTypeEntity, TAG_CODE, NO_IS_PARENT_TAG_NULL_FLAG).isEmpty());
assertTrue(tagDao.getTagsByTagTypeEntityAndParentTagCode(tagTypeEntity, I_DO_NOT_EXIST, NO_IS_PARENT_TAG_NULL_FLAG).isEmpty());
}
use of org.finra.herd.model.jpa.TagTypeEntity in project herd by FINRAOS.
the class TagDaoTest method testGetMostRecentTags.
@Ignore
public void testGetMostRecentTags() {
List<TagEntity> tagEntities = new ArrayList<>();
// Create a tag type entity.
TagTypeEntity tagTypeEntity = tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION);
// Create two root tag entities for the tag type with tag display name in reverse order.
List<TagEntity> rootTagEntities = Arrays.asList(tagDaoTestHelper.createTagEntity(tagTypeEntity, TAG_CODE, TAG_DISPLAY_NAME, TAG_DESCRIPTION), tagDaoTestHelper.createTagEntity(tagTypeEntity, TAG_CODE_2, TAG_DISPLAY_NAME_2, TAG_DESCRIPTION_2));
// Only add the most recent 1 to the list
tagEntities.add(rootTagEntities.get(1));
// Get the list of most recent tags
assertEquals(tagEntities, tagDao.getMostRecentTags(1));
}
use of org.finra.herd.model.jpa.TagTypeEntity in project herd by FINRAOS.
the class TagTypeDaoTest method testGetTagTypeByDisplayName.
@Test
public void testGetTagTypeByDisplayName() {
// Create a tag type entity.
tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION);
// Retrieve the tag type entity.
TagTypeEntity resultTagTypeEntity = tagTypeDao.getTagTypeByDisplayName(TAG_TYPE_DISPLAY_NAME);
// Validate the results.
assertEquals(TAG_TYPE, resultTagTypeEntity.getCode());
assertEquals(TAG_TYPE_DISPLAY_NAME, resultTagTypeEntity.getDisplayName());
assertEquals(new Integer(1), resultTagTypeEntity.getOrderNumber());
}
use of org.finra.herd.model.jpa.TagTypeEntity in project herd by FINRAOS.
the class TagTypeDaoTestHelper method createTagTypeEntity.
/**
* Creates and persists a new tag type entity.
*
* @param typeCode the tag type code
* @param displayName the display name
* @param orderNumber the sorting number
* @param description the description
*
* @return the newly created tag type entity.
*/
public TagTypeEntity createTagTypeEntity(String typeCode, String displayName, Integer orderNumber, String description) {
TagTypeEntity tagTypeEntity = new TagTypeEntity();
tagTypeEntity.setCode(typeCode);
tagTypeEntity.setOrderNumber(orderNumber);
tagTypeEntity.setDisplayName(displayName);
tagTypeEntity.setDescription(description);
return tagTypeDao.saveAndRefresh(tagTypeEntity);
}
Aggregations