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"))));
}
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);
}
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));
}
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)));
}
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);
}
Aggregations