Search in sources :

Example 1 with TagTypeEntity

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));
}
Also used : TagEntity(org.finra.herd.model.jpa.TagEntity) TagTypeEntity(org.finra.herd.model.jpa.TagTypeEntity) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with TagTypeEntity

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());
}
Also used : TagEntity(org.finra.herd.model.jpa.TagEntity) TagTypeEntity(org.finra.herd.model.jpa.TagTypeEntity) Test(org.junit.Test)

Example 3 with TagTypeEntity

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));
}
Also used : TagEntity(org.finra.herd.model.jpa.TagEntity) ArrayList(java.util.ArrayList) TagTypeEntity(org.finra.herd.model.jpa.TagTypeEntity) Ignore(org.junit.Ignore)

Example 4 with TagTypeEntity

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());
}
Also used : TagTypeEntity(org.finra.herd.model.jpa.TagTypeEntity) Test(org.junit.Test)

Example 5 with TagTypeEntity

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);
}
Also used : TagTypeEntity(org.finra.herd.model.jpa.TagTypeEntity)

Aggregations

TagTypeEntity (org.finra.herd.model.jpa.TagTypeEntity)48 TagEntity (org.finra.herd.model.jpa.TagEntity)32 Test (org.junit.Test)25 ArrayList (java.util.ArrayList)18 TagKey (org.finra.herd.model.api.xml.TagKey)12 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)11 Predicate (javax.persistence.criteria.Predicate)8 TagChild (org.finra.herd.model.api.xml.TagChild)6 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)5 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)5 TagListResponse (org.finra.herd.model.api.xml.TagListResponse)4 BusinessObjectDefinitionTagEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity)4 Order (javax.persistence.criteria.Order)3 BusinessObjectDefinitionTagKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey)3 IndexSearchFilter (org.finra.herd.model.api.xml.IndexSearchFilter)3 IndexSearchKey (org.finra.herd.model.api.xml.IndexSearchKey)3 IndexSearchRequest (org.finra.herd.model.api.xml.IndexSearchRequest)3 IndexSearchResultTypeKey (org.finra.herd.model.api.xml.IndexSearchResultTypeKey)3 TagTypeKey (org.finra.herd.model.api.xml.TagTypeKey)3 JsonLocation (com.fasterxml.jackson.core.JsonLocation)2