Search in sources :

Example 1 with CustomDdlKey

use of org.finra.herd.model.api.xml.CustomDdlKey in project herd by FINRAOS.

the class CustomDdlServiceTest method testDeleteCustomDdlMissingRequiredParameters.

@Test
public void testDeleteCustomDdlMissingRequiredParameters() {
    // Try to delete a custom DDL instance when business object definition name is not specified.
    try {
        customDdlService.deleteCustomDdl(new CustomDdlKey(NAMESPACE, BLANK_TEXT, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME));
        fail("Should throw an IllegalArgumentException when business object definition name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition name must be specified.", e.getMessage());
    }
    // Try to delete a custom DDL instance when business object format usage is not specified.
    try {
        customDdlService.deleteCustomDdl(new CustomDdlKey(NAMESPACE, BDEF_NAME, BLANK_TEXT, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME));
        fail("Should throw an IllegalArgumentException when business object format usage is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format usage must be specified.", e.getMessage());
    }
    // Try to delete a custom DDL instance when business object format file type is not specified.
    try {
        customDdlService.deleteCustomDdl(new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, BLANK_TEXT, FORMAT_VERSION, CUSTOM_DDL_NAME));
        fail("Should throw an IllegalArgumentException when business object format file type is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format file type must be specified.", e.getMessage());
    }
    // Try to delete a custom DDL instance when business object format version is not specified.
    try {
        customDdlService.deleteCustomDdl(new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null, CUSTOM_DDL_NAME));
        fail("Should throw an IllegalArgumentException when business object format version is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format version must be specified.", e.getMessage());
    }
    // Try to delete a custom DDL instance when custom DDL name is not specified.
    try {
        customDdlService.deleteCustomDdl(new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, BLANK_TEXT));
        fail("Should throw an IllegalArgumentException when custom DDL name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A custom DDL name must be specified.", e.getMessage());
    }
}
Also used : CustomDdlKey(org.finra.herd.model.api.xml.CustomDdlKey) Test(org.junit.Test)

Example 2 with CustomDdlKey

use of org.finra.herd.model.api.xml.CustomDdlKey in project herd by FINRAOS.

the class CustomDdlServiceTest method testUpdateCustomDdlCustomDdlNoExists.

@Test
public void testUpdateCustomDdlCustomDdlNoExists() {
    // Try to update a non-existing custom DDL.
    try {
        customDdlService.updateCustomDdl(new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME), customDdlServiceTestHelper.createCustomDdlUpdateRequest(TEST_DDL));
        fail("Should throw an ObjectNotFoundException when custom DDL does not exist.");
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Custom DDL with name \"%s\" does not exist for business object format with namespace \"%s\", " + "business object definition name \"%s\", format usage \"%s\", format file type \"%s\", and format version \"%d\".", CUSTOM_DDL_NAME, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION), e.getMessage());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) CustomDdlKey(org.finra.herd.model.api.xml.CustomDdlKey) Test(org.junit.Test)

Example 3 with CustomDdlKey

use of org.finra.herd.model.api.xml.CustomDdlKey in project herd by FINRAOS.

the class CustomDdlServiceTest method testUpdateCustomDdl.

@Test
public void testUpdateCustomDdl() {
    // Create and persist a custom DDL entity.
    CustomDdlEntity customDdlEntity = customDdlDaoTestHelper.createCustomDdlEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME, TEST_DDL);
    // Update the custom DDL.
    CustomDdl updatedCustomDdl = customDdlService.updateCustomDdl(new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME), customDdlServiceTestHelper.createCustomDdlUpdateRequest(TEST_DDL_2));
    // Validate the returned object.
    customDdlServiceTestHelper.validateCustomDdl(customDdlEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME, TEST_DDL_2, updatedCustomDdl);
}
Also used : CustomDdlEntity(org.finra.herd.model.jpa.CustomDdlEntity) CustomDdl(org.finra.herd.model.api.xml.CustomDdl) CustomDdlKey(org.finra.herd.model.api.xml.CustomDdlKey) Test(org.junit.Test)

Example 4 with CustomDdlKey

use of org.finra.herd.model.api.xml.CustomDdlKey in project herd by FINRAOS.

the class CustomDdlServiceTest method testUpdateCustomDdlMissingRequiredParameters.

@Test
public void testUpdateCustomDdlMissingRequiredParameters() {
    // Try to update a custom DDL instance when business object definition name is not specified.
    try {
        customDdlService.updateCustomDdl(new CustomDdlKey(NAMESPACE, BLANK_TEXT, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME), customDdlServiceTestHelper.createCustomDdlUpdateRequest(TEST_DDL));
        fail("Should throw an IllegalArgumentException when business object definition name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition name must be specified.", e.getMessage());
    }
    // Try to update a custom DDL instance when business object format usage is not specified.
    try {
        customDdlService.updateCustomDdl(new CustomDdlKey(NAMESPACE, BDEF_NAME, BLANK_TEXT, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME), customDdlServiceTestHelper.createCustomDdlUpdateRequest(TEST_DDL));
        fail("Should throw an IllegalArgumentException when business object format usage is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format usage must be specified.", e.getMessage());
    }
    // Try to update a custom DDL instance when business object format file type is not specified.
    try {
        customDdlService.updateCustomDdl(new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, BLANK_TEXT, FORMAT_VERSION, CUSTOM_DDL_NAME), customDdlServiceTestHelper.createCustomDdlUpdateRequest(TEST_DDL));
        fail("Should throw an IllegalArgumentException when business object format file type is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format file type must be specified.", e.getMessage());
    }
    // Try to update a custom DDL instance when business object format version is not specified.
    try {
        customDdlService.updateCustomDdl(new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null, CUSTOM_DDL_NAME), customDdlServiceTestHelper.createCustomDdlUpdateRequest(TEST_DDL));
        fail("Should throw an IllegalArgumentException when business object format version is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object format version must be specified.", e.getMessage());
    }
    // Try to update a custom DDL instance when custom DDL name is not specified.
    try {
        customDdlService.updateCustomDdl(new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, BLANK_TEXT), customDdlServiceTestHelper.createCustomDdlUpdateRequest(TEST_DDL));
        fail("Should throw an IllegalArgumentException when custom DDL name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A custom DDL name must be specified.", e.getMessage());
    }
    // Try to update a custom DDL instance when custom DDL is not specified.
    try {
        customDdlService.updateCustomDdl(new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME), customDdlServiceTestHelper.createCustomDdlUpdateRequest(BLANK_TEXT));
        fail("Should throw an IllegalArgumentException when custom DDL is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("DDL must be specified.", e.getMessage());
    }
}
Also used : CustomDdlKey(org.finra.herd.model.api.xml.CustomDdlKey) Test(org.junit.Test)

Example 5 with CustomDdlKey

use of org.finra.herd.model.api.xml.CustomDdlKey in project herd by FINRAOS.

the class CustomDdlServiceTest method testGetCustomDdls.

@Test
public void testGetCustomDdls() {
    // List of test custom DDL names.
    List<String> testCustomDdlNames = Arrays.asList(CUSTOM_DDL_NAME, CUSTOM_DDL_NAME_2);
    // Create and persist a custom DDL entities.
    for (String customDdlName : testCustomDdlNames) {
        customDdlDaoTestHelper.createCustomDdlEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, customDdlName, TEST_DDL);
    }
    // Retrieve a list of custom DDL keys.
    CustomDdlKeys resultCustomDdlKeys = customDdlService.getCustomDdls(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION));
    // Validate the returned object.
    assertNotNull(resultCustomDdlKeys);
    assertEquals(testCustomDdlNames.size(), resultCustomDdlKeys.getCustomDdlKeys().size());
    for (int i = 0; i < testCustomDdlNames.size(); i++) {
        assertEquals(new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, testCustomDdlNames.get(i)), resultCustomDdlKeys.getCustomDdlKeys().get(i));
    }
}
Also used : CustomDdlKeys(org.finra.herd.model.api.xml.CustomDdlKeys) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) CustomDdlKey(org.finra.herd.model.api.xml.CustomDdlKey) Test(org.junit.Test)

Aggregations

CustomDdlKey (org.finra.herd.model.api.xml.CustomDdlKey)35 Test (org.junit.Test)29 CustomDdl (org.finra.herd.model.api.xml.CustomDdl)17 CustomDdlEntity (org.finra.herd.model.jpa.CustomDdlEntity)16 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)8 CustomDdlKeys (org.finra.herd.model.api.xml.CustomDdlKeys)5 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)3 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)3 ArrayList (java.util.ArrayList)2 CustomDdlCreateRequest (org.finra.herd.model.api.xml.CustomDdlCreateRequest)2 HashMap (java.util.HashMap)1 Tuple (javax.persistence.Tuple)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Predicate (javax.persistence.criteria.Predicate)1 BusinessObjectDataDdl (org.finra.herd.model.api.xml.BusinessObjectDataDdl)1 BusinessObjectFormatDdl (org.finra.herd.model.api.xml.BusinessObjectFormatDdl)1 CustomDdlUpdateRequest (org.finra.herd.model.api.xml.CustomDdlUpdateRequest)1 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)1 FileTypeEntity (org.finra.herd.model.jpa.FileTypeEntity)1 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)1