@NamespacePermission(fields = "#attributeValueListKey.namespace", permissions = NamespacePermissionEnum.READ) @Override public AttributeValueList getAttributeValueList(AttributeValueListKey attributeValueListKey) { // Perform validation and trim. attributeValueListHelper.validateAttributeValueListKey(attributeValueListKey); // Retrieve and ensure that an attribute value list already exists with the specified key. AttributeValueListEntity attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey); // Create and return the attribute value list object from the deleted entity. return attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity); }
@NamespacePermission(fields = "#attributeValueListKey.namespace", permissions = NamespacePermissionEnum.READ) @Override public AttributeValueList getAttributeValueList(AttributeValueListKey attributeValueListKey) { // Perform validation and trim. attributeValueListHelper.validateAttributeValueListKey(attributeValueListKey); // Retrieve and ensure that an attribute value list already exists with the specified key. AttributeValueListEntity attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey); // Create and return the attribute value list object from the deleted entity. return attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity); }
@NamespacePermission(fields = "#attributeValueListKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override public AttributeValueList deleteAttributeValueList(AttributeValueListKey attributeValueListKey) { // Perform validation and trim. attributeValueListHelper.validateAttributeValueListKey(attributeValueListKey); // Retrieve and ensure that an attribute value list already exists with the specified key. AttributeValueListEntity attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey); // Delete the attribute value list. attributeValueListDao.delete(attributeValueListEntity); // Create and return the attribute value list object from the deleted entity. return attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity); }
@NamespacePermission(fields = "#attributeValueListKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override public AttributeValueList deleteAttributeValueList(AttributeValueListKey attributeValueListKey) { // Perform validation and trim. attributeValueListHelper.validateAttributeValueListKey(attributeValueListKey); // Retrieve and ensure that an attribute value list already exists with the specified key. AttributeValueListEntity attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey); // Delete the attribute value list. attributeValueListDao.delete(attributeValueListEntity); // Create and return the attribute value list object from the deleted entity. return attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity); }
/** * Retrieves existing allowed attribute values based on the specified key * * @param attributeValueListKey the attribute value list key * * @return the allowed attribute values information */ @NamespacePermission(fields = "#attributeValueListKey.namespace", permissions = NamespacePermissionEnum.READ) @Override public AllowedAttributeValuesInformation getAllowedAttributeValues(AttributeValueListKey attributeValueListKey) { // Perform validation and trim of the input parameters. attributeValueListHelper.validateAttributeValueListKey(attributeValueListKey); // Retrieve and ensure that a attribute value list exists with the specified name. AttributeValueListEntity attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey); // Retrieve a list of allowed attribute values. List<AllowedAttributeValueEntity> allowedAttributeValueEntities = allowedAttributeValueDao.getAllowedAttributeValuesByAttributeValueListKey(attributeValueListKey); return createAllowedAttributeValuesInformationFromEntities(attributeValueListEntity, allowedAttributeValueEntities); }
/** * Retrieves existing allowed attribute values based on the specified key * * @param attributeValueListKey the attribute value list key * * @return the allowed attribute values information */ @NamespacePermission(fields = "#attributeValueListKey.namespace", permissions = NamespacePermissionEnum.READ) @Override public AllowedAttributeValuesInformation getAllowedAttributeValues(AttributeValueListKey attributeValueListKey) { // Perform validation and trim of the input parameters. attributeValueListHelper.validateAttributeValueListKey(attributeValueListKey); // Retrieve and ensure that a attribute value list exists with the specified name. AttributeValueListEntity attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey); // Retrieve a list of allowed attribute values. List<AllowedAttributeValueEntity> allowedAttributeValueEntities = allowedAttributeValueDao.getAllowedAttributeValuesByAttributeValueListKey(attributeValueListKey); return createAllowedAttributeValuesInformationFromEntities(attributeValueListEntity, allowedAttributeValueEntities); }
AttributeValueListEntity attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(request.getAttributeValueListKey());
AttributeValueListEntity attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(request.getAttributeValueListKey());
@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); }
@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); } }
AttributeValueListEntity attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(request.getAttributeValueListKey());
AttributeValueListEntity attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(request.getAttributeValueListKey());
when(attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey)).thenReturn(attributeValueListEntity); when(allowedAttributeValueDao.saveAndRefresh(any(AllowedAttributeValueEntity.class))).thenReturn(allowedAttributeValueEntity); when(alternateKeyHelper.validateStringParameter("An", "allowed attribute value", ALLOWED_ATTRIBUTE_VALUE)).thenReturn(ALLOWED_ATTRIBUTE_VALUE); verify(attributeValueListDaoHelper).getAttributeValueListEntity(attributeValueListKey); verify(allowedAttributeValueDao, times(1)).saveAndRefresh(any(AllowedAttributeValueEntity.class)); verify(allowedAttributeValueDao, times(1)).saveAndRefresh(any(AttributeValueListEntity.class));
@Test public void testDeleteAttributeValueList() { // Create an attribute value list key. AttributeValueListKey attributeValueListKey = new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME); // Create a namespace entity. NamespaceEntity namespaceEntity = new NamespaceEntity(); namespaceEntity.setCode(ATTRIBUTE_VALUE_LIST_NAMESPACE); // Create an attribute value list entity. AttributeValueListEntity attributeValueListEntity = new AttributeValueListEntity(); attributeValueListEntity.setId(ATTRIBUTE_VALUE_LIST_ID); attributeValueListEntity.setNamespace(namespaceEntity); attributeValueListEntity.setName(ATTRIBUTE_VALUE_LIST_NAME); // Mock calls to external methods. when(attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey)).thenReturn(attributeValueListEntity); when(attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity)).thenCallRealMethod(); // Call the method under test. AttributeValueList result = attributeValueListService.deleteAttributeValueList(attributeValueListKey); // Verify the external calls. verify(attributeValueListHelper).validateAttributeValueListKey(attributeValueListKey); verify(attributeValueListDaoHelper).getAttributeValueListEntity(attributeValueListKey); verify(attributeValueListDao).delete(attributeValueListEntity); verify(attributeValueListDaoHelper).createAttributeValueListFromEntity(attributeValueListEntity); verifyNoMoreInteractionsHelper(); // Validate the result. assertEquals(new AttributeValueList(ATTRIBUTE_VALUE_LIST_ID, attributeValueListKey), result); }
when(attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey)).thenReturn(attributeValueListEntity); when(allowedAttributeValueDao.getAllowedAttributeValuesByAttributeValueListKey(attributeValueListKey)).thenReturn(allowedAttributeValueEntities); verify(attributeValueListDaoHelper).getAttributeValueListEntity(attributeValueListKey); verify(allowedAttributeValueDao).getAllowedAttributeValuesByAttributeValueListKey(attributeValueListKey); verify(attributeValueListHelper).validateAttributeValueListKey(attributeValueListKey);
@Test public void testGetAttributeValueList() { // Create an attribute value list key. AttributeValueListKey attributeValueListKey = new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME); // Create a namespace entity. NamespaceEntity namespaceEntity = new NamespaceEntity(); namespaceEntity.setCode(ATTRIBUTE_VALUE_LIST_NAMESPACE); // Create an attribute value list entity. AttributeValueListEntity attributeValueListEntity = new AttributeValueListEntity(); attributeValueListEntity.setId(ATTRIBUTE_VALUE_LIST_ID); attributeValueListEntity.setNamespace(namespaceEntity); attributeValueListEntity.setName(ATTRIBUTE_VALUE_LIST_NAME); // Mock calls to external methods. when(attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey)).thenReturn(attributeValueListEntity); when(attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity)).thenCallRealMethod(); // Call the method under test. AttributeValueList result = attributeValueListService.getAttributeValueList(attributeValueListKey); // Verify the external calls. verify(attributeValueListHelper).validateAttributeValueListKey(attributeValueListKey); verify(attributeValueListDaoHelper).getAttributeValueListEntity(attributeValueListKey); verify(attributeValueListDaoHelper).createAttributeValueListFromEntity(attributeValueListEntity); verifyNoMoreInteractionsHelper(); // Validate the result. assertEquals(new AttributeValueList(ATTRIBUTE_VALUE_LIST_ID, attributeValueListKey), result); }
when(attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey)).thenReturn(attributeValueListEntity); when(allowedAttributeValueDao.saveAndRefresh(any(AllowedAttributeValueEntity.class))).thenReturn(allowedAttributeValueEntity); when(alternateKeyHelper.validateStringParameter("An", "allowed attribute value", ALLOWED_ATTRIBUTE_VALUE)).thenReturn(ALLOWED_ATTRIBUTE_VALUE); verify(attributeValueListDaoHelper).getAttributeValueListEntity(attributeValueListKey); verify(allowedAttributeValueDao).saveAndRefresh(any(AttributeValueListEntity.class)); verify(alternateKeyHelper).validateStringParameter("An", "allowed attribute value", ALLOWED_ATTRIBUTE_VALUE);
when(attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey)).thenReturn(attributeValueListEntity); when(alternateKeyHelper.validateStringParameter("An", "allowed attribute value", ALLOWED_ATTRIBUTE_VALUE)).thenReturn(ALLOWED_ATTRIBUTE_VALUE); verify(attributeValueListDaoHelper).getAttributeValueListEntity(attributeValueListKey); verify(alternateKeyHelper).validateStringParameter("An", "allowed attribute value", ALLOWED_ATTRIBUTE_VALUE); verify(attributeValueListHelper).validateAttributeValueListKey(attributeValueListKey);
@Override public GlobalAttributeDefinition createGlobalAttributeDefinition(GlobalAttributeDefinitionCreateRequest request) { // Validate and trim the request parameters. validateGlobalAttributeDefinitionCreateRequest(request); // Validate the global Attribute Definition entity does not already exist in the database. globalAttributeDefinitionDaoHelper.validateGlobalAttributeDefinitionNoExists(request.getGlobalAttributeDefinitionKey()); //Get the existing global Attribute Definition level entity GlobalAttributeDefinitionLevelEntity globalAttributeDefinitionLevelEntity = globalAttributeDefinitionLevelDao.getGlobalAttributeDefinitionLevel(request.getGlobalAttributeDefinitionKey().getGlobalAttributeDefinitionLevel()); AttributeValueListEntity attributeValueListEntity = null; //Get the attribute value list if the attribute value key exists if (request.getAttributeValueListKey() != null) { //Get the existing attribute list and ensure it exists attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(request.getAttributeValueListKey()); } // Create and persist a new global Attribute Definition entity from the request information. GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = createGlobalAttributeDefinitionEntity(request.getGlobalAttributeDefinitionKey(), globalAttributeDefinitionLevelEntity, attributeValueListEntity); // Create and return the global Attribute Definition object from the persisted entity. return createGlobalAttributeDefinitionFromEntity(globalAttributeDefinitionEntity); }
@Override public GlobalAttributeDefinition createGlobalAttributeDefinition(GlobalAttributeDefinitionCreateRequest request) { // Validate and trim the request parameters. validateGlobalAttributeDefinitionCreateRequest(request); // Validate the global Attribute Definition entity does not already exist in the database. globalAttributeDefinitionDaoHelper.validateGlobalAttributeDefinitionNoExists(request.getGlobalAttributeDefinitionKey()); //Get the existing global Attribute Definition level entity GlobalAttributeDefinitionLevelEntity globalAttributeDefinitionLevelEntity = globalAttributeDefinitionLevelDao.getGlobalAttributeDefinitionLevel(request.getGlobalAttributeDefinitionKey().getGlobalAttributeDefinitionLevel()); AttributeValueListEntity attributeValueListEntity = null; //Get the attribute value list if the attribute value key exists if (request.getAttributeValueListKey() != null) { //Get the existing attribute list and ensure it exists attributeValueListEntity = attributeValueListDaoHelper.getAttributeValueListEntity(request.getAttributeValueListKey()); } // Create and persist a new global Attribute Definition entity from the request information. GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = createGlobalAttributeDefinitionEntity(request.getGlobalAttributeDefinitionKey(), globalAttributeDefinitionLevelEntity, attributeValueListEntity); // Create and return the global Attribute Definition object from the persisted entity. return createGlobalAttributeDefinitionFromEntity(globalAttributeDefinitionEntity); }