Search in sources :

Example 6 with BusinessObjectDefinitionSubjectMatterExpertEntity

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

the class BusinessObjectDefinitionSubjectMatterExpertDaoTest method testGetBusinessObjectDefinitionSubjectMatterExpertByKey.

@Test
public void testGetBusinessObjectDefinitionSubjectMatterExpertByKey() {
    // Create a business object definition subject matter expert key.
    BusinessObjectDefinitionSubjectMatterExpertKey key = new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, BDEF_NAME, USER_ID);
    // Create a business object definition subject matter expert entity.
    BusinessObjectDefinitionSubjectMatterExpertEntity businessObjectDefinitionSubjectMatterExpertEntity = businessObjectDefinitionSubjectMatterExpertDaoTestHelper.createBusinessObjectDefinitionSubjectMatterExpertEntity(key);
    // Get business object definition subject matter expert.
    assertEquals(businessObjectDefinitionSubjectMatterExpertEntity, businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(key));
    // Get business object definition subject matter expert by passing all case-insensitive parameters in uppercase.
    assertEquals(businessObjectDefinitionSubjectMatterExpertEntity, businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), USER_ID.toUpperCase())));
    // Get business object definition subject matter expert by passing all case-insensitive parameters in lowercase.
    assertEquals(businessObjectDefinitionSubjectMatterExpertEntity, businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), USER_ID.toLowerCase())));
    // Try invalid values for all input parameters.
    assertNull(businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(new BusinessObjectDefinitionSubjectMatterExpertKey("I_DO_NOT_EXIST", BDEF_NAME, USER_ID)));
    assertNull(businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, "I_DO_NOT_EXIST", USER_ID)));
    assertNull(businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST")));
}
Also used : BusinessObjectDefinitionSubjectMatterExpertKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey) BusinessObjectDefinitionSubjectMatterExpertEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity) Test(org.junit.Test)

Example 7 with BusinessObjectDefinitionSubjectMatterExpertEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity 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"));
}
Also used : BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionSubjectMatterExpertEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity) Test(org.junit.Test)

Example 8 with BusinessObjectDefinitionSubjectMatterExpertEntity

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

the class BusinessObjectDefinitionSubjectMatterExpertDaoTestHelper method createBusinessObjectDefinitionSubjectMatterExpertEntity.

/**
 * Creates and persists a new business object definition subject matter expert entity.
 *
 * @param businessObjectDefinitionEntity the business object definition entity
 * @param userId the user id of the subject matter expert
 *
 * @return the newly created business object definition subject matter expert entity
 */
public BusinessObjectDefinitionSubjectMatterExpertEntity createBusinessObjectDefinitionSubjectMatterExpertEntity(BusinessObjectDefinitionEntity businessObjectDefinitionEntity, String userId) {
    BusinessObjectDefinitionSubjectMatterExpertEntity businessObjectDefinitionSubjectMatterExpertEntity = new BusinessObjectDefinitionSubjectMatterExpertEntity();
    businessObjectDefinitionSubjectMatterExpertEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity);
    businessObjectDefinitionSubjectMatterExpertEntity.setUserId(userId);
    return businessObjectDefinitionSubjectMatterExpertDao.saveAndRefresh(businessObjectDefinitionSubjectMatterExpertEntity);
}
Also used : BusinessObjectDefinitionSubjectMatterExpertEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity)

Example 9 with BusinessObjectDefinitionSubjectMatterExpertEntity

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

the class BusinessObjectDefinitionSubjectMatterExpertDaoImpl method getBusinessObjectDefinitionSubjectMatterExpert.

@Override
public BusinessObjectDefinitionSubjectMatterExpertEntity getBusinessObjectDefinitionSubjectMatterExpert(BusinessObjectDefinitionEntity businessObjectDefinitionEntity, String userId) {
    // Create the criteria builder and the criteria.
    CriteriaBuilder builder = entityManager.getCriteriaBuilder();
    CriteriaQuery<BusinessObjectDefinitionSubjectMatterExpertEntity> criteria = builder.createQuery(BusinessObjectDefinitionSubjectMatterExpertEntity.class);
    // The criteria root is the business object definition subject matter expert.
    Root<BusinessObjectDefinitionSubjectMatterExpertEntity> businessObjectDefinitionSubjectMatterExpertEntityRoot = criteria.from(BusinessObjectDefinitionSubjectMatterExpertEntity.class);
    // Create the standard restrictions (i.e. the standard where clauses).
    List<Predicate> predicates = new ArrayList<>();
    predicates.add(builder.equal(businessObjectDefinitionSubjectMatterExpertEntityRoot.get(BusinessObjectDefinitionSubjectMatterExpertEntity_.businessObjectDefinition), businessObjectDefinitionEntity));
    predicates.add(builder.equal(builder.upper(businessObjectDefinitionSubjectMatterExpertEntityRoot.get(BusinessObjectDefinitionSubjectMatterExpertEntity_.userId)), userId.toUpperCase()));
    // Add the clauses for the query.
    criteria.select(businessObjectDefinitionSubjectMatterExpertEntityRoot).where(builder.and(predicates.toArray(new Predicate[predicates.size()])));
    // Execute the query and return the results.
    return executeSingleResultQuery(criteria, String.format("Found more than one business object definition subject matter expert instance with parameters {namespace=\"%s\", " + "businessObjectDefinitionName=\"%s\", userId=\"%s\"}.", businessObjectDefinitionEntity.getNamespace().getCode(), businessObjectDefinitionEntity.getName(), userId));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) ArrayList(java.util.ArrayList) BusinessObjectDefinitionSubjectMatterExpertEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity) Predicate(javax.persistence.criteria.Predicate)

Example 10 with BusinessObjectDefinitionSubjectMatterExpertEntity

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

the class BusinessObjectDefinitionSubjectMatterExpertServiceTest method testDeleteBusinessObjectDefinitionSubjectMatterExpertUpperCaseParameters.

@Test
public void testDeleteBusinessObjectDefinitionSubjectMatterExpertUpperCaseParameters() {
    // Create a business object definition subject matter expert key.
    BusinessObjectDefinitionSubjectMatterExpertKey key = new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, BDEF_NAME, USER_ID);
    // Create and persist a business object definition subject matter expert.
    BusinessObjectDefinitionSubjectMatterExpertEntity businessObjectDefinitionSubjectMatterExpertEntity = businessObjectDefinitionSubjectMatterExpertDaoTestHelper.createBusinessObjectDefinitionSubjectMatterExpertEntity(key);
    // Validate that this business object definition subject matter expert exists.
    assertNotNull(businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(key));
    // Delete this business object definition subject matter expert using upper case parameter values.
    BusinessObjectDefinitionSubjectMatterExpert deletedBusinessObjectDefinitionSubjectMatterExpert = businessObjectDefinitionSubjectMatterExpertService.deleteBusinessObjectDefinitionSubjectMatterExpert(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), USER_ID.toUpperCase()));
    // Validate the returned object.
    assertEquals(new BusinessObjectDefinitionSubjectMatterExpert(businessObjectDefinitionSubjectMatterExpertEntity.getId(), key), deletedBusinessObjectDefinitionSubjectMatterExpert);
    // Ensure that this business object definition subject matter expert is no longer there.
    assertNull(businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(key));
}
Also used : BusinessObjectDefinitionSubjectMatterExpertKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey) BusinessObjectDefinitionSubjectMatterExpert(org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpert) BusinessObjectDefinitionSubjectMatterExpertEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity) Test(org.junit.Test)

Aggregations

BusinessObjectDefinitionSubjectMatterExpertEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity)13 Test (org.junit.Test)6 BusinessObjectDefinitionSubjectMatterExpertKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey)5 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)5 BusinessObjectDefinitionSubjectMatterExpert (org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpert)4 ArrayList (java.util.ArrayList)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2 Predicate (javax.persistence.criteria.Predicate)2 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)2 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)1 BusinessObjectDefinitionSubjectMatterExpertKeys (org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKeys)1 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)1