use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionColumnDaoTest method testGetBusinessObjectDefinitionColumnByBusinessObjectDefinitionColumnNameDuplicateColumns.
@Test
public void testGetBusinessObjectDefinitionColumnByBusinessObjectDefinitionColumnNameDuplicateColumns() throws Exception {
// Create a business object definition entity.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION);
// Create duplicate business object definition columns.
businessObjectDefinitionColumnDaoTestHelper.createBusinessObjectDefinitionColumnEntity(businessObjectDefinitionEntity, BDEF_COLUMN_NAME.toUpperCase(), DESCRIPTION);
businessObjectDefinitionColumnDaoTestHelper.createBusinessObjectDefinitionColumnEntity(businessObjectDefinitionEntity, BDEF_COLUMN_NAME.toLowerCase(), DESCRIPTION_2);
// Try to get business object definition column when business object definition has duplicate columns.
try {
businessObjectDefinitionColumnDao.getBusinessObjectDefinitionColumnByBusinessObjectDefinitionColumnName(businessObjectDefinitionEntity, BDEF_COLUMN_NAME);
fail("Should throw an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Found more than one business object definition column instance with parameters {namespace=\"%s\", " + "businessObjectDefinitionName=\"%s\", businessObjectDefinitionColumnName=\"%s\"}.", BDEF_NAMESPACE, BDEF_NAME, BDEF_COLUMN_NAME), e.getMessage());
}
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionColumnDaoTest method testGetBusinessObjectDefinitionColumnByKeyDuplicateColumns.
@Test
public void testGetBusinessObjectDefinitionColumnByKeyDuplicateColumns() throws Exception {
// Create a business object definition entity.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION);
// Create duplicate business object definition columns.
businessObjectDefinitionColumnDaoTestHelper.createBusinessObjectDefinitionColumnEntity(businessObjectDefinitionEntity, BDEF_COLUMN_NAME.toUpperCase(), DESCRIPTION);
businessObjectDefinitionColumnDaoTestHelper.createBusinessObjectDefinitionColumnEntity(businessObjectDefinitionEntity, BDEF_COLUMN_NAME.toLowerCase(), DESCRIPTION_2);
// Try to get business object definition column when business object definition has duplicate columns.
try {
businessObjectDefinitionColumnDao.getBusinessObjectDefinitionColumnByKey(new BusinessObjectDefinitionColumnKey(BDEF_NAMESPACE, BDEF_NAME, BDEF_COLUMN_NAME));
fail("Should throw an IllegalArgumentException.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Found more than one business object definition column instance with parameters {namespace=\"%s\", " + "businessObjectDefinitionName=\"%s\", businessObjectDefinitionColumnName=\"%s\"}.", BDEF_NAMESPACE, BDEF_NAME, BDEF_COLUMN_NAME), e.getMessage());
}
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionColumnDaoTest method testGetBusinessObjectDefinitionColumnByBusinessObjectDefinitionColumnName.
@Test
public void testGetBusinessObjectDefinitionColumnByBusinessObjectDefinitionColumnName() {
// Create a business object definition column key.
BusinessObjectDefinitionColumnKey businessObjectDefinitionColumnKey = new BusinessObjectDefinitionColumnKey(BDEF_NAMESPACE, BDEF_NAME, BDEF_COLUMN_NAME);
// Create a business object definition column entity.
BusinessObjectDefinitionColumnEntity businessObjectDefinitionColumnEntity = businessObjectDefinitionColumnDaoTestHelper.createBusinessObjectDefinitionColumnEntity(businessObjectDefinitionColumnKey, BDEF_COLUMN_DESCRIPTION);
// Get the business object definition entity.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionColumnEntity.getBusinessObjectDefinition();
// Get business object definition column.
assertEquals(businessObjectDefinitionColumnEntity, businessObjectDefinitionColumnDao.getBusinessObjectDefinitionColumnByBusinessObjectDefinitionColumnName(businessObjectDefinitionEntity, BDEF_COLUMN_NAME));
// Get business object definition column by passing all case-insensitive parameters in uppercase.
assertEquals(businessObjectDefinitionColumnEntity, businessObjectDefinitionColumnDao.getBusinessObjectDefinitionColumnByBusinessObjectDefinitionColumnName(businessObjectDefinitionEntity, BDEF_COLUMN_NAME.toUpperCase()));
// Get business object definition column by passing all case-insensitive parameters in lowercase.
assertEquals(businessObjectDefinitionColumnEntity, businessObjectDefinitionColumnDao.getBusinessObjectDefinitionColumnByBusinessObjectDefinitionColumnName(businessObjectDefinitionEntity, BDEF_COLUMN_NAME.toLowerCase()));
// Try invalid values for all input parameters.
assertNull(businessObjectDefinitionColumnDao.getBusinessObjectDefinitionColumnByBusinessObjectDefinitionColumnName(businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME_2, DATA_PROVIDER_NAME, DESCRIPTION), BDEF_COLUMN_NAME));
assertNull(businessObjectDefinitionColumnDao.getBusinessObjectDefinitionColumnByBusinessObjectDefinitionColumnName(businessObjectDefinitionEntity, "I_DO_NOT_EXIST"));
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionColumnDaoTestHelper method createBusinessObjectDefinitionColumnEntity.
/**
* Creates and persists a new business object definition column entity.
*
* @param businessObjectDefinitionColumnKey the business object definition column key
* @param businessObjectDefinitionColumnDescription the description of the business object definition column
*
* @return the newly created business object definition column entity
*/
public BusinessObjectDefinitionColumnEntity createBusinessObjectDefinitionColumnEntity(BusinessObjectDefinitionColumnKey businessObjectDefinitionColumnKey, String businessObjectDefinitionColumnDescription) {
// Create a business object definition column.
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(businessObjectDefinitionColumnKey.getNamespace(), businessObjectDefinitionColumnKey.getBusinessObjectDefinitionName());
// 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);
}
return createBusinessObjectDefinitionColumnEntity(businessObjectDefinitionEntity, businessObjectDefinitionColumnKey.getBusinessObjectDefinitionColumnName(), businessObjectDefinitionColumnDescription);
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionDaoTest method testGetBusinessObjectDefinitions.
@Test
public void testGetBusinessObjectDefinitions() {
// Create and persist two business object definition entities.
List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntities = businessObjectDefinitionDaoTestHelper.createExpectedBusinessObjectDefinitionEntities();
// Get the list of business object definitions when tag entities is empty.
assertEquals(ImmutableSet.copyOf(businessObjectDefinitionEntities), ImmutableSet.copyOf(businessObjectDefinitionDao.getBusinessObjectDefinitions(new ArrayList<>())));
// Create and persist root tag entity.
TagEntity parentTagEntity = tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, null);
// Create two children for the root tag.
List<TagEntity> tagEntities = Arrays.asList(parentTagEntity, tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE_3, TAG_DISPLAY_NAME_4, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, parentTagEntity), tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE_4, TAG_DISPLAY_NAME_3, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, parentTagEntity));
// Create and persist two business object definition tag entities for the child tag entities.
for (BusinessObjectDefinitionEntity businessObjectDefinitionEntity : businessObjectDefinitionEntities) {
for (TagEntity tagEntity : tagEntities) {
businessObjectDefinitionTagDaoTestHelper.createBusinessObjectDefinitionTagEntity(businessObjectDefinitionEntity, tagEntity);
}
}
// Filter duplicates and validate the result.
assertEquals(ImmutableSet.copyOf(businessObjectDefinitionEntities), ImmutableSet.copyOf(businessObjectDefinitionDao.getBusinessObjectDefinitions(tagEntities)));
}
Aggregations