Search in sources :

Example 76 with BusinessObjectDefinitionEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity 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 77 with BusinessObjectDefinitionEntity

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

the class BusinessObjectDefinitionTagDaoTest method testGetBusinessObjectDefinitionTagsByBusinessObjectDefinitionEntity.

@Test
public void testGetBusinessObjectDefinitionTagsByBusinessObjectDefinitionEntity() {
    // 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 with display names in reverse order.
    List<TagEntity> tagEntities = Arrays.asList(tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME_2, TAG_DESCRIPTION), tagDaoTestHelper.createTagEntity(TAG_TYPE_2, TAG_CODE_2, TAG_DISPLAY_NAME, TAG_DESCRIPTION));
    // Create and persist two business object definition tag entities for the first business object definition entity.
    for (TagEntity tagEntity : tagEntities) {
        businessObjectDefinitionTagDaoTestHelper.createBusinessObjectDefinitionTagEntity(businessObjectDefinitionEntities.get(0), tagEntity);
    }
    // Get business object definition tags by business object definition entity.
    assertEquals(Arrays.asList(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE_2, TAG_CODE_2)), new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE, TAG_CODE))), businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagsByBusinessObjectDefinitionEntity(businessObjectDefinitionEntities.get(0)));
    // Try invalid values for all input parameters.
    assertTrue(businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagsByBusinessObjectDefinitionEntity(businessObjectDefinitionEntities.get(1)).isEmpty());
}
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) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) Test(org.junit.Test)

Example 78 with BusinessObjectDefinitionEntity

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

the class BusinessObjectDefinitionTagDaoTest method testGetBusinessObjectDefinitionTagByKeyDuplicateTags.

@Test
public void testGetBusinessObjectDefinitionTagByKeyDuplicateTags() 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 tags.
    businessObjectDefinitionTagDaoTestHelper.createBusinessObjectDefinitionTagEntity(businessObjectDefinitionEntity, tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE.toUpperCase(), TAG_DISPLAY_NAME, DESCRIPTION));
    businessObjectDefinitionTagDaoTestHelper.createBusinessObjectDefinitionTagEntity(businessObjectDefinitionEntity, tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE.toLowerCase(), TAG_DISPLAY_NAME, DESCRIPTION));
    // Try to get business object definition tag when business object definition tags are duplicate.
    try {
        businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagByKey(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE, TAG_CODE)));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Found more than one business object definition tag instance with parameters {namespace=\"%s\", " + "businessObjectDefinitionName=\"%s\", tagType=\"%s\", tagCode=\"%s\"}.", BDEF_NAMESPACE, BDEF_NAME, TAG_TYPE, TAG_CODE), e.getMessage());
    }
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) Test(org.junit.Test)

Example 79 with BusinessObjectDefinitionEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity 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)

Example 80 with BusinessObjectDefinitionEntity

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

the class BusinessObjectDefinitionDaoTest method testGetBusinessObjectDefinitionByKey.

@Test
public void testGetBusinessObjectDefinitionByKey() {
    // Create two business object definitions having the same business object definition name.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION);
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE_2, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION);
    // Get the business object definition by key.
    BusinessObjectDefinitionEntity resultBusinessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME));
    // Validate the returned object.
    assertEquals(businessObjectDefinitionEntity, resultBusinessObjectDefinitionEntity);
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) Test(org.junit.Test)

Aggregations

BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)164 Test (org.junit.Test)78 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)75 ArrayList (java.util.ArrayList)54 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)40 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)39 FileTypeEntity (org.finra.herd.model.jpa.FileTypeEntity)38 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)33 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)32 Predicate (javax.persistence.criteria.Predicate)31 StorageEntity (org.finra.herd.model.jpa.StorageEntity)23 Attribute (org.finra.herd.model.api.xml.Attribute)19 BusinessObjectDefinitionCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest)15 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)15 TagEntity (org.finra.herd.model.jpa.TagEntity)15 SearchIndexUpdateDto (org.finra.herd.model.dto.SearchIndexUpdateDto)13 BusinessObjectDataStatusEntity (org.finra.herd.model.jpa.BusinessObjectDataStatusEntity)12 BusinessObjectDefinitionTagEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity)12 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)12 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)10