Search in sources :

Example 1 with BusinessObjectDefinitionColumnSearchKey

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

the class BusinessObjectDefinitionColumnServiceImpl method validateBusinessObjectDefinitionColumnSearchRequest.

/**
 * Validates the business object definition column search request.
 *
 * @param request the business object definition column search request
 *
 * @throws IllegalArgumentException if any validation errors were found
 */
private void validateBusinessObjectDefinitionColumnSearchRequest(BusinessObjectDefinitionColumnSearchRequest request) throws IllegalArgumentException {
    // Validate the request
    Assert.notNull(request, "A business object definition column search request must be specified.");
    // Validate the search filters
    List<BusinessObjectDefinitionColumnSearchFilter> businessObjectDefinitionColumnSearchFilters = request.getBusinessObjectDefinitionColumnSearchFilters();
    Assert.isTrue(CollectionUtils.size(businessObjectDefinitionColumnSearchFilters) == 1 && businessObjectDefinitionColumnSearchFilters.get(0) != null, "Exactly one business object definition column search filter must be specified.");
    // Validate the search keys
    List<BusinessObjectDefinitionColumnSearchKey> businessObjectDefinitionColumnSearchKeys = businessObjectDefinitionColumnSearchFilters.get(0).getBusinessObjectDefinitionColumnSearchKeys();
    Assert.isTrue(CollectionUtils.size(businessObjectDefinitionColumnSearchKeys) == 1 && businessObjectDefinitionColumnSearchKeys.get(0) != null, "Exactly one business object definition column search key must be specified.");
    // Get the search key
    BusinessObjectDefinitionColumnSearchKey businessObjectDefinitionColumnSearchKey = businessObjectDefinitionColumnSearchKeys.get(0);
    // Validate the namespace and the business object definition
    businessObjectDefinitionColumnSearchKey.setNamespace(alternateKeyHelper.validateStringParameter("namespace", businessObjectDefinitionColumnSearchKey.getNamespace()));
    businessObjectDefinitionColumnSearchKey.setBusinessObjectDefinitionName(alternateKeyHelper.validateStringParameter("business object definition name", businessObjectDefinitionColumnSearchKey.getBusinessObjectDefinitionName()));
}
Also used : BusinessObjectDefinitionColumnSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchFilter) BusinessObjectDefinitionColumnSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchKey)

Example 2 with BusinessObjectDefinitionColumnSearchKey

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

the class BusinessObjectDefinitionColumnServiceTest method testSearchBusinessObjectDefinitionColumnsMissingOptionalParameters.

@Test
public void testSearchBusinessObjectDefinitionColumnsMissingOptionalParameters() {
    createDatabaseEntitiesForBusinessObjectDefinitionColumnSearchTesting();
    // Search business object definition columns without specifying optional parameters except for the description field option.
    assertEquals(new BusinessObjectDefinitionColumnSearchResponse(Lists.newArrayList(new BusinessObjectDefinitionColumn(NO_ID, new BusinessObjectDefinitionColumnKey(BDEF_NAMESPACE, BDEF_NAME, BDEF_COLUMN_NAME), COLUMN_NAME, null, NO_BUSINESS_OBJECT_DEFINITION_COLUMN_CHANGE_EVENTS), new BusinessObjectDefinitionColumn(NO_ID, new BusinessObjectDefinitionColumnKey(BDEF_NAMESPACE, BDEF_NAME, BDEF_COLUMN_NAME_2), COLUMN_NAME_2, null, NO_BUSINESS_OBJECT_DEFINITION_COLUMN_CHANGE_EVENTS))), businessObjectDefinitionColumnService.searchBusinessObjectDefinitionColumns(new BusinessObjectDefinitionColumnSearchRequest(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchFilter(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchKey(BDEF_NAMESPACE, BDEF_NAME))))), Sets.newHashSet(SCHEMA_COLUMN_NAME_FIELD)));
    // Search business object definition columns without specifying optional parameters except for the schema column name field option.
    assertEquals(new BusinessObjectDefinitionColumnSearchResponse(Lists.newArrayList(new BusinessObjectDefinitionColumn(NO_ID, new BusinessObjectDefinitionColumnKey(BDEF_NAMESPACE, BDEF_NAME, BDEF_COLUMN_NAME), null, BDEF_COLUMN_DESCRIPTION, NO_BUSINESS_OBJECT_DEFINITION_COLUMN_CHANGE_EVENTS), new BusinessObjectDefinitionColumn(NO_ID, new BusinessObjectDefinitionColumnKey(BDEF_NAMESPACE, BDEF_NAME, BDEF_COLUMN_NAME_2), null, BDEF_COLUMN_DESCRIPTION_2, NO_BUSINESS_OBJECT_DEFINITION_COLUMN_CHANGE_EVENTS))), businessObjectDefinitionColumnService.searchBusinessObjectDefinitionColumns(new BusinessObjectDefinitionColumnSearchRequest(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchFilter(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchKey(BDEF_NAMESPACE, BDEF_NAME))))), Sets.newHashSet(DESCRIPTION_FIELD)));
    // Search business object definition columns without specifying optional parameters.
    assertEquals(new BusinessObjectDefinitionColumnSearchResponse(Lists.newArrayList(new BusinessObjectDefinitionColumn(NO_ID, new BusinessObjectDefinitionColumnKey(BDEF_NAMESPACE, BDEF_NAME, BDEF_COLUMN_NAME), null, null, NO_BUSINESS_OBJECT_DEFINITION_COLUMN_CHANGE_EVENTS), new BusinessObjectDefinitionColumn(NO_ID, new BusinessObjectDefinitionColumnKey(BDEF_NAMESPACE, BDEF_NAME, BDEF_COLUMN_NAME_2), null, null, NO_BUSINESS_OBJECT_DEFINITION_COLUMN_CHANGE_EVENTS))), businessObjectDefinitionColumnService.searchBusinessObjectDefinitionColumns(new BusinessObjectDefinitionColumnSearchRequest(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchFilter(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchKey(BDEF_NAMESPACE, BDEF_NAME))))), Sets.newHashSet()));
}
Also used : BusinessObjectDefinitionColumnSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchFilter) BusinessObjectDefinitionColumnSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchKey) BusinessObjectDefinitionColumnSearchResponse(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchResponse) BusinessObjectDefinitionColumnKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnKey) BusinessObjectDefinitionColumnSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchRequest) BusinessObjectDefinitionColumn(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumn) Test(org.junit.Test)

Example 3 with BusinessObjectDefinitionColumnSearchKey

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

the class BusinessObjectDefinitionColumnServiceTest method testSearchBusinessObjectDefinitionColumnsMissingRequiredParameters.

@Test
public void testSearchBusinessObjectDefinitionColumnsMissingRequiredParameters() {
    // Try to search business object definition columns when a search request is not specified.
    try {
        businessObjectDefinitionColumnService.searchBusinessObjectDefinitionColumns(null, NO_SEARCH_RESPONSE_FIELDS);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition column search request must be specified.", e.getMessage());
    }
    // Try to search business object definition columns when a search filter is not specified.
    try {
        businessObjectDefinitionColumnService.searchBusinessObjectDefinitionColumns(new BusinessObjectDefinitionColumnSearchRequest(), NO_SEARCH_RESPONSE_FIELDS);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Exactly one business object definition column search filter must be specified.", e.getMessage());
    }
    // Try to search business object definition columns when a search filter is set to null.
    try {
        List<BusinessObjectDefinitionColumnSearchFilter> businessObjectDefinitionColumnSearchFilters = new ArrayList<>();
        businessObjectDefinitionColumnSearchFilters.add(null);
        businessObjectDefinitionColumnService.searchBusinessObjectDefinitionColumns(new BusinessObjectDefinitionColumnSearchRequest(businessObjectDefinitionColumnSearchFilters), NO_SEARCH_RESPONSE_FIELDS);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Exactly one business object definition column search filter must be specified.", e.getMessage());
    }
    // Try to search business object definition columns when a search key is not specified.
    try {
        businessObjectDefinitionColumnService.searchBusinessObjectDefinitionColumns(new BusinessObjectDefinitionColumnSearchRequest(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchFilter())), NO_SEARCH_RESPONSE_FIELDS);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Exactly one business object definition column search key must be specified.", e.getMessage());
    }
    // Try to search business object definition columns when a search key is set to null.
    try {
        List<BusinessObjectDefinitionColumnSearchKey> businessObjectDefinitionColumnSearchKeys = new ArrayList<>();
        businessObjectDefinitionColumnSearchKeys.add(null);
        businessObjectDefinitionColumnService.searchBusinessObjectDefinitionColumns(new BusinessObjectDefinitionColumnSearchRequest(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchFilter(businessObjectDefinitionColumnSearchKeys))), NO_SEARCH_RESPONSE_FIELDS);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Exactly one business object definition column search key must be specified.", e.getMessage());
    }
    // Try to search business object definition columns when namespace is not specified.
    try {
        businessObjectDefinitionColumnService.searchBusinessObjectDefinitionColumns(new BusinessObjectDefinitionColumnSearchRequest(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchFilter(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchKey(NO_NAMESPACE, BDEF_NAME))))), Sets.newHashSet(SCHEMA_COLUMN_NAME_FIELD, DESCRIPTION_FIELD));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    // Try to search business object definition columns when business object definition name is not specified.
    try {
        businessObjectDefinitionColumnService.searchBusinessObjectDefinitionColumns(new BusinessObjectDefinitionColumnSearchRequest(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchFilter(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchKey(BDEF_NAMESPACE, NO_BDEF_NAME))))), Sets.newHashSet(SCHEMA_COLUMN_NAME_FIELD, DESCRIPTION_FIELD));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition name must be specified.", e.getMessage());
    }
}
Also used : BusinessObjectDefinitionColumnSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchFilter) ArrayList(java.util.ArrayList) BusinessObjectDefinitionColumnSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchKey) BusinessObjectDefinitionColumnSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchRequest) Test(org.junit.Test)

Example 4 with BusinessObjectDefinitionColumnSearchKey

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

the class BusinessObjectDefinitionColumnServiceTest method testSearchBusinessObjectDefinitionColumns.

@Test
public void testSearchBusinessObjectDefinitionColumns() {
    createDatabaseEntitiesForBusinessObjectDefinitionColumnSearchTesting();
    // Search the business object definition columns using all field parameters.
    BusinessObjectDefinitionColumnSearchResponse businessObjectDefinitionColumnSearchResponse = businessObjectDefinitionColumnService.searchBusinessObjectDefinitionColumns(new BusinessObjectDefinitionColumnSearchRequest(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchFilter(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchKey(BDEF_NAMESPACE, BDEF_NAME))))), Sets.newHashSet(SCHEMA_COLUMN_NAME_FIELD, DESCRIPTION_FIELD));
    // Validate the response object.
    assertEquals(new BusinessObjectDefinitionColumnSearchResponse(Lists.newArrayList(new BusinessObjectDefinitionColumn(NO_ID, new BusinessObjectDefinitionColumnKey(BDEF_NAMESPACE, BDEF_NAME, BDEF_COLUMN_NAME), COLUMN_NAME, BDEF_COLUMN_DESCRIPTION, NO_BUSINESS_OBJECT_DEFINITION_COLUMN_CHANGE_EVENTS), new BusinessObjectDefinitionColumn(NO_ID, new BusinessObjectDefinitionColumnKey(BDEF_NAMESPACE, BDEF_NAME, BDEF_COLUMN_NAME_2), COLUMN_NAME_2, BDEF_COLUMN_DESCRIPTION_2, NO_BUSINESS_OBJECT_DEFINITION_COLUMN_CHANGE_EVENTS))), businessObjectDefinitionColumnSearchResponse);
}
Also used : BusinessObjectDefinitionColumnSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchFilter) BusinessObjectDefinitionColumnSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchKey) BusinessObjectDefinitionColumnSearchResponse(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchResponse) BusinessObjectDefinitionColumnSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchRequest) BusinessObjectDefinitionColumnKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnKey) BusinessObjectDefinitionColumn(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumn) Test(org.junit.Test)

Example 5 with BusinessObjectDefinitionColumnSearchKey

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

the class BusinessObjectDefinitionColumnRestControllerTest method testSearchBusinessObjectDefinitionColumns.

@Test
public void testSearchBusinessObjectDefinitionColumns() {
    // Create business object definition change event
    List<BusinessObjectDefinitionColumnChangeEvent> businessObjectDefinitionColumnChangeEvents = Lists.newArrayList(new BusinessObjectDefinitionColumnChangeEvent(BDEF_COLUMN_DESCRIPTION, CREATED_ON, CREATED_BY));
    BusinessObjectDefinitionColumnSearchRequest request = new BusinessObjectDefinitionColumnSearchRequest(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchFilter(Lists.newArrayList(new BusinessObjectDefinitionColumnSearchKey(BDEF_NAMESPACE, BDEF_NAME)))));
    BusinessObjectDefinitionColumnSearchResponse businessObjectDefinitionColumnSearchResponse = new BusinessObjectDefinitionColumnSearchResponse(Arrays.asList(new BusinessObjectDefinitionColumn(NO_ID, new BusinessObjectDefinitionColumnKey(BDEF_NAMESPACE, BDEF_NAME, BDEF_COLUMN_NAME), COLUMN_NAME, BDEF_COLUMN_DESCRIPTION, businessObjectDefinitionColumnChangeEvents), new BusinessObjectDefinitionColumn(NO_ID, new BusinessObjectDefinitionColumnKey(BDEF_NAMESPACE, BDEF_NAME, BDEF_COLUMN_NAME_2), COLUMN_NAME_2, BDEF_COLUMN_DESCRIPTION_2, businessObjectDefinitionColumnChangeEvents)));
    Set<String> set = Sets.newHashSet(SCHEMA_COLUMN_NAME_FIELD, DESCRIPTION_FIELD);
    when(businessObjectDefinitionColumnService.searchBusinessObjectDefinitionColumns(request, set)).thenReturn(businessObjectDefinitionColumnSearchResponse);
    // Search the business object definition columns.
    BusinessObjectDefinitionColumnSearchResponse resultSearchResponse = businessObjectDefinitionColumnRestController.searchBusinessObjectDefinitionColumns(set, request);
    // Verify the external calls.
    verify(businessObjectDefinitionColumnService).searchBusinessObjectDefinitionColumns(request, set);
    verifyNoMoreInteractions(businessObjectDefinitionColumnService);
    // Validate the returned object.
    assertEquals(businessObjectDefinitionColumnSearchResponse, resultSearchResponse);
}
Also used : BusinessObjectDefinitionColumnSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchFilter) BusinessObjectDefinitionColumnSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchKey) BusinessObjectDefinitionColumnSearchResponse(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchResponse) BusinessObjectDefinitionColumnChangeEvent(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnChangeEvent) BusinessObjectDefinitionColumnSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchRequest) BusinessObjectDefinitionColumnKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnKey) BusinessObjectDefinitionColumn(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumn) Test(org.junit.Test)

Aggregations

BusinessObjectDefinitionColumnSearchFilter (org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchFilter)9 BusinessObjectDefinitionColumnSearchKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchKey)9 BusinessObjectDefinitionColumnSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchRequest)8 Test (org.junit.Test)8 BusinessObjectDefinitionColumn (org.finra.herd.model.api.xml.BusinessObjectDefinitionColumn)6 BusinessObjectDefinitionColumnKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnKey)6 BusinessObjectDefinitionColumnSearchResponse (org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnSearchResponse)6 ArrayList (java.util.ArrayList)1 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1 BusinessObjectDefinitionColumnChangeEvent (org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnChangeEvent)1