Search in sources :

Example 26 with AttributeValueListKey

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)));
}
Also used : AttributeValueListEntity(org.finra.herd.model.jpa.AttributeValueListEntity) AttributeValueListKey(org.finra.herd.model.api.xml.AttributeValueListKey) Test(org.junit.Test)

Example 27 with AttributeValueListKey

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);
}
Also used : AttributeValueList(org.finra.herd.model.api.xml.AttributeValueList) AttributeValueListKey(org.finra.herd.model.api.xml.AttributeValueListKey) Test(org.junit.Test)

Example 28 with AttributeValueListKey

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);
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) AttributeValueListKey(org.finra.herd.model.api.xml.AttributeValueListKey) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 29 with AttributeValueListKey

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);
}
Also used : AttributeValueListEntity(org.finra.herd.model.jpa.AttributeValueListEntity) AttributeValueListKey(org.finra.herd.model.api.xml.AttributeValueListKey) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 30 with AttributeValueListKey

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();
}
Also used : AllowedAttributeValuesDeleteRequest(org.finra.herd.model.api.xml.AllowedAttributeValuesDeleteRequest) AttributeValueListKey(org.finra.herd.model.api.xml.AttributeValueListKey) Test(org.junit.Test)

Aggregations

AttributeValueListKey (org.finra.herd.model.api.xml.AttributeValueListKey)32 Test (org.junit.Test)27 AttributeValueListEntity (org.finra.herd.model.jpa.AttributeValueListEntity)14 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)11 AllowedAttributeValuesInformation (org.finra.herd.model.api.xml.AllowedAttributeValuesInformation)7 AttributeValueList (org.finra.herd.model.api.xml.AttributeValueList)7 AllowedAttributeValueEntity (org.finra.herd.model.jpa.AllowedAttributeValueEntity)7 ArrayList (java.util.ArrayList)6 AllowedAttributeValuesDeleteRequest (org.finra.herd.model.api.xml.AllowedAttributeValuesDeleteRequest)5 AllowedAttributeValuesCreateRequest (org.finra.herd.model.api.xml.AllowedAttributeValuesCreateRequest)4 AttributeValueListCreateRequest (org.finra.herd.model.api.xml.AttributeValueListCreateRequest)4 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)4 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)3 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)2 AttributeValueListKeys (org.finra.herd.model.api.xml.AttributeValueListKeys)2 HashSet (java.util.HashSet)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Order (javax.persistence.criteria.Order)1 Predicate (javax.persistence.criteria.Predicate)1 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)1