Search in sources :

Example 6 with BusinessObjectDefinitionTagEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity in project herd by FINRAOS.

the class BusinessObjectDefinitionTagDaoTest method testGetBusinessObjectDefinitionTagByKey.

@Test
public void testGetBusinessObjectDefinitionTagByKey() {
    // Create a business object definition tag key.
    BusinessObjectDefinitionTagKey businessObjectDefinitionTagKey = new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE, TAG_CODE));
    // Create and persist a business object definition tag entity.
    BusinessObjectDefinitionTagEntity businessObjectDefinitionTagEntity = businessObjectDefinitionTagDaoTestHelper.createBusinessObjectDefinitionTagEntity(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE, TAG_CODE));
    // Get the business object definition tag.
    assertEquals(businessObjectDefinitionTagEntity, businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagByKey(businessObjectDefinitionTagKey));
    // Get business object definition tag by passing all case-insensitive parameters in uppercase.
    assertEquals(businessObjectDefinitionTagEntity, businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagByKey(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase()), new TagKey(TAG_TYPE.toUpperCase(), TAG_CODE.toUpperCase()))));
    // Get business object definition tag by passing all case-insensitive parameters in lowercase.
    assertEquals(businessObjectDefinitionTagEntity, businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagByKey(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase()), new TagKey(TAG_TYPE.toLowerCase(), TAG_CODE.toLowerCase()))));
    // Try invalid values for all input parameters.
    assertNull(businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagByKey(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey("I_DO_NOT_EXIST", BDEF_NAME), new TagKey(TAG_TYPE, TAG_CODE))));
    assertNull(businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagByKey(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, "I_DO_NOT_EXIST"), new TagKey(TAG_TYPE, TAG_CODE))));
    assertNull(businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagByKey(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey("I_DO_NOT_EXIST", TAG_CODE))));
    assertNull(businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagByKey(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE, "I_DO_NOT_EXIST"))));
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) BusinessObjectDefinitionTagEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity) Test(org.junit.Test)

Example 7 with BusinessObjectDefinitionTagEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity in project herd by FINRAOS.

the class BusinessObjectDefinitionTagDaoTestHelper method createBusinessObjectDefinitionTagEntity.

/**
 * Creates and persists a new business object definition tag entity.
 *
 * @param businessObjectDefinitionEntity the business object definition entity
 * @param tagEntity the tag entity
 *
 * @return the newly created business object definition tag entity
 */
public BusinessObjectDefinitionTagEntity createBusinessObjectDefinitionTagEntity(BusinessObjectDefinitionEntity businessObjectDefinitionEntity, TagEntity tagEntity) {
    // Create a business object definition tag entity.
    BusinessObjectDefinitionTagEntity businessObjectDefinitionTagEntity = new BusinessObjectDefinitionTagEntity();
    businessObjectDefinitionTagEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity);
    businessObjectDefinitionTagEntity.setTag(tagEntity);
    // Persist and return the newly created entity.
    return businessObjectDefinitionDao.saveAndRefresh(businessObjectDefinitionTagEntity);
}
Also used : BusinessObjectDefinitionTagEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity)

Example 8 with BusinessObjectDefinitionTagEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity in project herd by FINRAOS.

the class BusinessObjectDefinitionHelperTest method testProcessTagSearchScoreMultiplier.

@Test
public void testProcessTagSearchScoreMultiplier() {
    // Create a business object definition entity
    final BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes2());
    // Create two tag entities
    TagEntity tagEntity1 = tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, null);
    TagEntity tagEntity2 = tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER_NULL, TAG_DESCRIPTION, null);
    // Assocaite tag entities with business object definition entity
    List<BusinessObjectDefinitionTagEntity> businessObjectDefinitionTagEntities = Arrays.asList(businessObjectDefinitionTagDaoTestHelper.createBusinessObjectDefinitionTagEntity(businessObjectDefinitionEntity, tagEntity1), businessObjectDefinitionTagDaoTestHelper.createBusinessObjectDefinitionTagEntity(businessObjectDefinitionEntity, tagEntity2));
    businessObjectDefinitionEntity.setBusinessObjectDefinitionTags(businessObjectDefinitionTagEntities);
    // Call the method under test
    businessObjectDefinitionHelper.processTagSearchScoreMultiplier(businessObjectDefinitionEntity);
    // Validate the result
    assertEquals(businessObjectDefinitionEntity.getTagSearchScoreMultiplier(), TAG_SEARCH_SCORE_MULTIPLIER.setScale(3, RoundingMode.HALF_UP));
}
Also used : BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) TagEntity(org.finra.herd.model.jpa.TagEntity) BusinessObjectDefinitionTagEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity) BusinessObjectDefinitionTagEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 9 with BusinessObjectDefinitionTagEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity in project herd by FINRAOS.

the class BusinessObjectDefinitionTagDaoTest method testGetBusinessObjectDefinitionTagByParentEntities.

@Test
public void testGetBusinessObjectDefinitionTagByParentEntities() {
    // Create and persist two business object definition entities.
    List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntities = Arrays.asList(businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), DATA_PROVIDER_NAME, DESCRIPTION), businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(new BusinessObjectDefinitionKey(BDEF_NAMESPACE_2, BDEF_NAME_2), DATA_PROVIDER_NAME, DESCRIPTION));
    // Create and persist two tag entities.
    List<TagEntity> tagEntities = Arrays.asList(tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME, TAG_DESCRIPTION), tagDaoTestHelper.createTagEntity(TAG_TYPE_2, TAG_CODE_2, TAG_DISPLAY_NAME, TAG_DESCRIPTION));
    // Create and persist a business object definition tag entity.
    BusinessObjectDefinitionTagEntity businessObjectDefinitionTagEntity = businessObjectDefinitionTagDaoTestHelper.createBusinessObjectDefinitionTagEntity(businessObjectDefinitionEntities.get(0), tagEntities.get(0));
    // Get the business object definition tag by it's parent entities.
    assertEquals(businessObjectDefinitionTagEntity, businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagByParentEntities(businessObjectDefinitionEntities.get(0), tagEntities.get(0)));
    // Try invalid values for all input parameters.
    assertNull(businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagByParentEntities(businessObjectDefinitionEntities.get(1), tagEntities.get(0)));
    assertNull(businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagByParentEntities(businessObjectDefinitionEntities.get(0), tagEntities.get(1)));
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) TagEntity(org.finra.herd.model.jpa.TagEntity) BusinessObjectDefinitionTagEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity) BusinessObjectDefinitionTagEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity) Test(org.junit.Test)

Example 10 with BusinessObjectDefinitionTagEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity in project herd by FINRAOS.

the class BusinessObjectDefinitionTagDaoTestHelper method createBusinessObjectDefinitionTagEntity.

/**
 * Creates and persists a new business object definition tag entity.
 *
 * @param businessObjectDefinitionKey the business object definition key
 * @param tagKey the tag key
 *
 * @return the newly created business object definition tag entity
 */
public BusinessObjectDefinitionTagEntity createBusinessObjectDefinitionTagEntity(BusinessObjectDefinitionKey businessObjectDefinitionKey, TagKey tagKey) {
    // Create a business object definition entity if needed.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(businessObjectDefinitionKey);
    if (businessObjectDefinitionEntity == null) {
        businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(businessObjectDefinitionKey, AbstractDaoTest.DATA_PROVIDER_NAME, AbstractDaoTest.DESCRIPTION);
    }
    // Create a tag entity if needed.
    TagEntity tagEntity = tagDao.getTagByKey(tagKey);
    if (tagEntity == null) {
        tagEntity = tagDaoTestHelper.createTagEntity(tagKey.getTagTypeCode(), tagKey.getTagCode(), AbstractDaoTest.TAG_DISPLAY_NAME, AbstractDaoTest.TAG_DESCRIPTION);
    }
    return createBusinessObjectDefinitionTagEntity(businessObjectDefinitionEntity, tagEntity);
}
Also used : BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) TagEntity(org.finra.herd.model.jpa.TagEntity) BusinessObjectDefinitionTagEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity)

Aggregations

BusinessObjectDefinitionTagEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity)18 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)9 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)8 Test (org.junit.Test)8 BusinessObjectDefinitionTagKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey)7 TagKey (org.finra.herd.model.api.xml.TagKey)7 TagEntity (org.finra.herd.model.jpa.TagEntity)7 ArrayList (java.util.ArrayList)5 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)5 Predicate (javax.persistence.criteria.Predicate)5 BusinessObjectDefinitionTag (org.finra.herd.model.api.xml.BusinessObjectDefinitionTag)4 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)3 TagTypeEntity (org.finra.herd.model.jpa.TagTypeEntity)3 Tuple (javax.persistence.Tuple)2 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)2 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)2 Order (javax.persistence.criteria.Order)1 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1