use of org.finra.herd.model.api.xml.AttributeValueListKey in project herd by FINRAOS.
the class AttributeValueListDaoTest method testGetAttributeValueListByKey.
@Test
public void testGetAttributeValueListByKey() {
// Create and persist a attribute value list entity.
AttributeValueListEntity attributeValueListEntity = attributeValueListDaoTestHelper.createAttributeValueListEntity(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME);
// Retrieve a attribute value list entity.
assertEquals(attributeValueListEntity, attributeValueListDao.getAttributeValueListByKey(new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME)));
// Test case insensitivity.
assertEquals(attributeValueListEntity, attributeValueListDao.getAttributeValueListByKey(new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE.toUpperCase(), ATTRIBUTE_VALUE_LIST_NAME.toUpperCase())));
assertEquals(attributeValueListEntity, attributeValueListDao.getAttributeValueListByKey(new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE.toLowerCase(), ATTRIBUTE_VALUE_LIST_NAME.toLowerCase())));
// Confirm negative results when using invalid values.
assertNull(attributeValueListDao.getAttributeValueListByKey(new AttributeValueListKey(I_DO_NOT_EXIST, ATTRIBUTE_VALUE_LIST_NAME)));
assertNull(attributeValueListDao.getAttributeValueListByKey(new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, I_DO_NOT_EXIST)));
}
use of org.finra.herd.model.api.xml.AttributeValueListKey in project herd by FINRAOS.
the class AttributeValueListRestControllerTest method testGetAttributeValueList.
@Test
public void testGetAttributeValueList() {
// Create an attribute value list key.
AttributeValueListKey attributeValueListKey = new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME);
// Create an attribute value list.
AttributeValueList attributeValueList = new AttributeValueList(ATTRIBUTE_VALUE_LIST_ID, attributeValueListKey);
// Mock calls to external methods.
when(attributeValueListService.getAttributeValueList(attributeValueListKey)).thenReturn(attributeValueList);
// Call the method under test.
AttributeValueList result = attributeValueListRestController.getAttributeValueList(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME);
// Verify the external calls.
verify(attributeValueListService).getAttributeValueList(attributeValueListKey);
verifyNoMoreInteractions(attributeValueListService);
// Validate the result.
assertEquals(attributeValueList, result);
}
use of org.finra.herd.model.api.xml.AttributeValueListKey in project herd by FINRAOS.
the class AttributeValueListDaoHelperTest method testGetAttributeValueListEntityAttributeValueListEntityNoExists.
@Test
public void testGetAttributeValueListEntityAttributeValueListEntityNoExists() {
// Create an attribute value list key.
AttributeValueListKey attributeValueListKey = new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME);
// Mock calls to external methods.
when(attributeValueListDao.getAttributeValueListByKey(attributeValueListKey)).thenReturn(null);
// Try to call the method under test.
try {
attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey);
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Attribute value list with name \"%s\" doesn't exist for namespace \"%s\".", ATTRIBUTE_VALUE_LIST_NAME, ATTRIBUTE_VALUE_LIST_NAMESPACE), e.getMessage());
}
// Verify the external calls.
verify(attributeValueListDao).getAttributeValueListByKey(attributeValueListKey);
verifyNoMoreInteractions(attributeValueListDao);
}
use of org.finra.herd.model.api.xml.AttributeValueListKey in project herd by FINRAOS.
the class AttributeValueListDaoHelperTest method testGetAttributeValueListEntity.
@Test
public void testGetAttributeValueListEntity() {
// Create an attribute value list key.
AttributeValueListKey attributeValueListKey = new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME);
// Create an attribute value list entity.
AttributeValueListEntity attributeValueListEntity = new AttributeValueListEntity();
// Mock calls to external methods.
when(attributeValueListDao.getAttributeValueListByKey(attributeValueListKey)).thenReturn(attributeValueListEntity);
// Call the method under test.
AttributeValueListEntity result = attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey);
// Verify the external calls.
verify(attributeValueListDao).getAttributeValueListByKey(attributeValueListKey);
verifyNoMoreInteractions(attributeValueListDao);
// Validate the result.
assertEquals(attributeValueListEntity, result);
}
use of org.finra.herd.model.api.xml.AttributeValueListKey in project herd by FINRAOS.
the class AllowedAttributeValueServiceTest method testDeleteAllowedAttributeValuesDuplicateAttributeValues.
@Test
public void testDeleteAllowedAttributeValuesDuplicateAttributeValues() {
// Create attribute value list key.
AttributeValueListKey attributeValueListKey = new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME);
// Create the allowed attribute values delete request.
AllowedAttributeValuesDeleteRequest request = new AllowedAttributeValuesDeleteRequest(attributeValueListKey, Arrays.asList(ALLOWED_ATTRIBUTE_VALUE, ALLOWED_ATTRIBUTE_VALUE));
// Mock calls to external methods.
when(alternateKeyHelper.validateStringParameter("An", "allowed attribute value", ALLOWED_ATTRIBUTE_VALUE)).thenReturn(ALLOWED_ATTRIBUTE_VALUE);
// Try to call method under test.
try {
allowedAttributeValueService.deleteAllowedAttributeValues(request);
fail();
} catch (IllegalArgumentException e) {
assertEquals(String.format("Duplicate allowed attribute value \"%s\" found.", ALLOWED_ATTRIBUTE_VALUE), e.getMessage());
}
// Verify the external calls.
verify(alternateKeyHelper, times(2)).validateStringParameter("An", "allowed attribute value", ALLOWED_ATTRIBUTE_VALUE);
verify(attributeValueListHelper).validateAttributeValueListKey(attributeValueListKey);
verifyNoMoreInteractionsHelper();
}
Aggregations