use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionDaoTest method testGetMostRecentBusinessObjectDefinitions.
@Test
public void testGetMostRecentBusinessObjectDefinitions() {
// Create and persist two business object definition entities.
List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntities = new ArrayList<>();
businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(AbstractDaoTest.NAMESPACE, AbstractDaoTest.BDEF_NAME, AbstractDaoTest.DATA_PROVIDER_NAME, AbstractDaoTest.BDEF_DESCRIPTION);
BusinessObjectDefinitionEntity businessObjectDefinitionEntityTwo = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(AbstractDaoTest.NAMESPACE_2, AbstractDaoTest.BDEF_NAME_2, AbstractDaoTest.DATA_PROVIDER_NAME_2, AbstractDaoTest.BDEF_DESCRIPTION_2);
// Only add the most recent 1 to the list
businessObjectDefinitionEntities.add(businessObjectDefinitionEntityTwo);
// Get the list of most recent 1 business object definitions
assertEquals(businessObjectDefinitionEntities, businessObjectDefinitionDao.getMostRecentBusinessObjectDefinitions(1));
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionDaoTestHelper method createBusinessObjectDefinition.
/**
* Creates and persists a new business object definition.
*
* @return the newly created business object definition.
*/
public BusinessObjectDefinitionEntity createBusinessObjectDefinition() {
String businessObjectDefinitionName = "BusObjDefTest" + AbstractDaoTest.getRandomSuffix();
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = new BusinessObjectDefinitionEntity();
businessObjectDefinitionEntity.setNamespace(namespaceDaoTestHelper.createNamespaceEntity());
businessObjectDefinitionEntity.setDataProvider(dataProviderDaoTestHelper.createDataProviderEntity());
businessObjectDefinitionEntity.setName(businessObjectDefinitionName);
businessObjectDefinitionEntity.setDescription("test");
return businessObjectDefinitionDao.saveAndRefresh(businessObjectDefinitionEntity);
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionSubjectMatterExpertDaoTest method testGetBusinessObjectDefinitionSubjectMatterExpertByKeyDuplicateSubjectMatterExperts.
@Test
public void testGetBusinessObjectDefinitionSubjectMatterExpertByKeyDuplicateSubjectMatterExperts() 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 subject matter experts.
businessObjectDefinitionSubjectMatterExpertDaoTestHelper.createBusinessObjectDefinitionSubjectMatterExpertEntity(businessObjectDefinitionEntity, USER_ID.toUpperCase());
businessObjectDefinitionSubjectMatterExpertDaoTestHelper.createBusinessObjectDefinitionSubjectMatterExpertEntity(businessObjectDefinitionEntity, USER_ID.toLowerCase());
// Try to get business object definition subject matter expert when business object definition has duplicate subject matter experts.
try {
businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, BDEF_NAME, USER_ID));
fail();
} catch (IllegalArgumentException e) {
assertEquals(String.format("Found more than one business object definition subject matter expert instance with parameters {namespace=\"%s\", " + "businessObjectDefinitionName=\"%s\", userId=\"%s\"}.", BDEF_NAMESPACE, BDEF_NAME, USER_ID), e.getMessage());
}
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionSubjectMatterExpertDaoTest method testGetBusinessObjectDefinitionSubjectMatterExpert.
@Test
public void testGetBusinessObjectDefinitionSubjectMatterExpert() {
// Create a business object definition entity.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, DESCRIPTION);
// Create a business object definition subject matter expert entity.
BusinessObjectDefinitionSubjectMatterExpertEntity businessObjectDefinitionSubjectMatterExpertEntity = businessObjectDefinitionSubjectMatterExpertDaoTestHelper.createBusinessObjectDefinitionSubjectMatterExpertEntity(businessObjectDefinitionEntity, USER_ID);
// Get business object definition subject matter expert.
assertEquals(businessObjectDefinitionSubjectMatterExpertEntity, businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpert(businessObjectDefinitionEntity, USER_ID));
// Get business object definition subject matter expert by passing all case-insensitive parameters in uppercase.
assertEquals(businessObjectDefinitionSubjectMatterExpertEntity, businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpert(businessObjectDefinitionEntity, USER_ID.toUpperCase()));
// Get business object definition subject matter expert by passing all case-insensitive parameters in lowercase.
assertEquals(businessObjectDefinitionSubjectMatterExpertEntity, businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpert(businessObjectDefinitionEntity, USER_ID.toLowerCase()));
// Try invalid values for all input parameters.
assertNull(businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpert(businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME_2, DATA_PROVIDER_NAME, DESCRIPTION), USER_ID));
assertNull(businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpert(businessObjectDefinitionEntity, "I_DO_NOT_EXIST"));
}
use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.
the class BusinessObjectDefinitionSubjectMatterExpertDaoTestHelper method createBusinessObjectDefinitionSubjectMatterExpertEntity.
/**
* Creates and persists a new business object definition subject matter expert entity.
*
* @param key the business object definition subject matter expert key
*
* @return the newly created business object definition subject matter expert entity
*/
public BusinessObjectDefinitionSubjectMatterExpertEntity createBusinessObjectDefinitionSubjectMatterExpertEntity(BusinessObjectDefinitionSubjectMatterExpertKey key) {
// Get a business object definition key.
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(key.getNamespace(), key.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 createBusinessObjectDefinitionSubjectMatterExpertEntity(businessObjectDefinitionEntity, key.getUserId());
}
Aggregations