use of org.finra.herd.model.api.xml.AttributeValueListKey in project herd by FINRAOS.
the class AllowedAttributeValueRestControllerTest method testGetAllowedAttributeValue.
@Test
public void testGetAllowedAttributeValue() {
// Create attribute value list key.
AttributeValueListKey attributeValueListKey = new AttributeValueListKey(NAMESPACE_CODE, ATTRIBUTE_VALUE_LIST_NAME);
// Create the allowed attribute values information.
AllowedAttributeValuesInformation allowedAttributeValuesInformation = new AllowedAttributeValuesInformation();
allowedAttributeValuesInformation.setAttributeValueListKey(attributeValueListKey);
allowedAttributeValuesInformation.setAllowedAttributeValues(Arrays.asList(ALLOWED_ATTRIBUTE_VALUE));
// Mock calls to external method.
when(allowedAttributeValueService.getAllowedAttributeValues(attributeValueListKey)).thenReturn(allowedAttributeValuesInformation);
// Call the method under test.
AllowedAttributeValuesInformation response = allowedAttributeValueRestController.getAllowedAttributeValues(NAMESPACE_CODE, ATTRIBUTE_VALUE_LIST_NAME);
// Verify the external calls.
verify(allowedAttributeValueService).getAllowedAttributeValues(attributeValueListKey);
verifyNoMoreInteractions(allowedAttributeValueService);
// Validate the response.
assertEquals(allowedAttributeValuesInformation, response);
}
use of org.finra.herd.model.api.xml.AttributeValueListKey in project herd by FINRAOS.
the class AttributeValueListDaoTest method testGetAttributeValueListKeys.
@Test
public void testGetAttributeValueListKeys() {
// Create several attribute value list keys in random order.
List<AttributeValueListKey> attributeValueListKeys = Arrays.asList(new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME_2), new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE_2, ATTRIBUTE_VALUE_LIST_NAME_2), new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE_2, ATTRIBUTE_VALUE_LIST_NAME), new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME));
// Create and persist attribute value list entities.
for (AttributeValueListKey attributeValueListKey : attributeValueListKeys) {
attributeValueListDaoTestHelper.createAttributeValueListEntity(attributeValueListKey.getNamespace(), attributeValueListKey.getAttributeValueListName());
}
// Retrieve a list of attribute value list keys.
assertEquals(Arrays.asList(attributeValueListKeys.get(3), attributeValueListKeys.get(0)), attributeValueListDao.getAttributeValueLists(Arrays.asList(ATTRIBUTE_VALUE_LIST_NAMESPACE)));
// Test case sensitivity.
assertEquals(new ArrayList<>(), attributeValueListDao.getAttributeValueLists(Arrays.asList(ATTRIBUTE_VALUE_LIST_NAMESPACE.toUpperCase())));
assertEquals(new ArrayList<>(), attributeValueListDao.getAttributeValueLists(Arrays.asList(ATTRIBUTE_VALUE_LIST_NAMESPACE.toLowerCase())));
// Retrieve the list of keys for all attribute value lists registered in the system.
assertEquals(Arrays.asList(attributeValueListKeys.get(3), attributeValueListKeys.get(0), attributeValueListKeys.get(2), attributeValueListKeys.get(1)), attributeValueListDao.getAttributeValueLists(null));
}
use of org.finra.herd.model.api.xml.AttributeValueListKey in project herd by FINRAOS.
the class AttributeValueListHelperTest method createValidateAttributeValueListCreateRequest.
@Test
public void createValidateAttributeValueListCreateRequest() {
// Create an attribute value list key.
AttributeValueListKey attributeValueListKey = new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME);
// Create an attribute value list create request.
AttributeValueListCreateRequest request = new AttributeValueListCreateRequest(attributeValueListKey);
// Mock calls to external methods.
when(alternateKeyHelper.validateStringParameter("namespace", ATTRIBUTE_VALUE_LIST_NAMESPACE)).thenReturn(ATTRIBUTE_VALUE_LIST_NAMESPACE);
when(alternateKeyHelper.validateStringParameter("An", "attribute value list name", ATTRIBUTE_VALUE_LIST_NAME)).thenReturn(ATTRIBUTE_VALUE_LIST_NAME);
// Call the method under test.
attributeValueListHelper.validateAttributeValueListCreateRequest(request);
// Verify the external calls.
verify(alternateKeyHelper).validateStringParameter("namespace", ATTRIBUTE_VALUE_LIST_NAMESPACE);
verify(alternateKeyHelper).validateStringParameter("An", "attribute value list name", ATTRIBUTE_VALUE_LIST_NAME);
verifyNoMoreInteractions(alternateKeyHelper);
// Validate the result.
assertEquals(new AttributeValueListCreateRequest(attributeValueListKey), request);
}
use of org.finra.herd.model.api.xml.AttributeValueListKey in project herd by FINRAOS.
the class AttributeValueListHelperTest method createValidateAttributeValueListKey.
@Test
public void createValidateAttributeValueListKey() {
// Create an attribute value list key.
AttributeValueListKey attributeValueListKey = new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME);
// Mock calls to external methods.
when(alternateKeyHelper.validateStringParameter("namespace", ATTRIBUTE_VALUE_LIST_NAMESPACE)).thenReturn(ATTRIBUTE_VALUE_LIST_NAMESPACE);
when(alternateKeyHelper.validateStringParameter("An", "attribute value list name", ATTRIBUTE_VALUE_LIST_NAME)).thenReturn(ATTRIBUTE_VALUE_LIST_NAME);
// Call the method under test.
attributeValueListHelper.validateAttributeValueListKey(attributeValueListKey);
// Verify the external calls.
verify(alternateKeyHelper).validateStringParameter("namespace", ATTRIBUTE_VALUE_LIST_NAMESPACE);
verify(alternateKeyHelper).validateStringParameter("An", "attribute value list name", ATTRIBUTE_VALUE_LIST_NAME);
verifyNoMoreInteractions(alternateKeyHelper);
// Validate the result.
assertEquals(new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME), attributeValueListKey);
}
use of org.finra.herd.model.api.xml.AttributeValueListKey in project herd by FINRAOS.
the class AllowedAttributeValueDaoTest method testGetAllowedAttributeValues.
@Test
public void testGetAllowedAttributeValues() {
// Create attribute value list key.
AttributeValueListKey attributeValueListKey = new AttributeValueListKey(NAMESPACE_CODE, ATTRIBUTE_VALUE_LIST_NAME);
List<String> allowedAttributeValueList = allowedAttributeValueDaoTestHelper.getTestUnsortedAllowedAttributeValues();
// Create and persist a attribute value list key entity.
attributeValueListDaoTestHelper.createAttributeValueListEntity(NAMESPACE_CODE, ATTRIBUTE_VALUE_LIST_NAME);
// Create and persist a list of allowed attribute values.
allowedAttributeValueDaoTestHelper.createAllowedAttributeValueEntities(attributeValueListKey, allowedAttributeValueList);
// Get the allowed attribute values for the specified key.
List<AllowedAttributeValueEntity> responseEntities = allowedAttributeValueDao.getAllowedAttributeValuesByAttributeValueListKey(attributeValueListKey);
// Create a list of allowed attribute values.
List<String> allowedAttributesResponse = new ArrayList<>();
responseEntities.forEach((responseEntity) -> {
allowedAttributesResponse.add(responseEntity.getAllowedAttributeValue());
});
// Validate the response is sorted by allowed attribute values.
Collections.sort(allowedAttributeValueList);
assertEquals(allowedAttributeValueList, allowedAttributesResponse);
}
Aggregations