* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdc.be.components.impl;
import org.mockito.Mockito;
import org.openecomp.sdc.ElementOperationMock;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
+import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.impl.generic.GenericTypeBusinessLogic;
import org.openecomp.sdc.be.components.validation.UserValidations;
assertResponse(createResponse.right().value(), expectedStatus, variables);
}
- private void assertComponentException(ComponentException e, ActionStatus expectedStatus, String... variables) {
- ResponseFormat actualResponse = e.getResponseFormat() != null ?
- e.getResponseFormat() : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ private void assertComponentException(ByActionStatusComponentException e, ActionStatus expectedStatus, String... variables) {
+ ResponseFormat actualResponse = componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ assertResponse(actualResponse, expectedStatus, variables);
+ }
+
+ private void assertComponentException(ByResponseFormatComponentException e, ActionStatus expectedStatus, String... variables) {
+ ResponseFormat actualResponse = e.getResponseFormat();
assertResponse(actualResponse, expectedStatus, variables);
}
serviceExccedsNameLimit.setName(null);
try{
bl.createService(serviceExccedsNameLimit, user);
- } catch(ComponentException e){
+ } catch(ByActionStatusComponentException e){
assertComponentException(e, ActionStatus.MISSING_COMPONENT_NAME, ComponentTypeEnum.SERVICE.getValue());
}
}
service.setName(nameWrongFormat);
try{
bl.createService(service, user);
- } catch(ComponentException e){
+ } catch(ByActionStatusComponentException e){
assertComponentException(e, ActionStatus.INVALID_COMPONENT_NAME, ComponentTypeEnum.SERVICE.getValue());
}
}
serviceExist.setDescription("");
try{
bl.createService(serviceExist, user);
- } catch(ComponentException e){
+ } catch(ByActionStatusComponentException e){
assertComponentException(e, ActionStatus.COMPONENT_MISSING_DESCRIPTION, ComponentTypeEnum.SERVICE.getValue());
}
}
serviceExist.setDescription(null);
try{
bl.createService(serviceExist, user);
- } catch(ComponentException e){
+ } catch(ByActionStatusComponentException e){
assertComponentException(e, ActionStatus.COMPONENT_MISSING_DESCRIPTION, ComponentTypeEnum.SERVICE.getValue());
}
}
serviceExccedsDescLimit.setDescription(tooLongServiceDesc);
try{
bl.createService(serviceExccedsDescLimit, user);
- } catch(ComponentException e){
+ } catch(ByActionStatusComponentException e){
assertComponentException(e, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT, ComponentTypeEnum.SERVICE.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
}
}
notEnglish.setDescription(tooLongServiceDesc);
try{
bl.createService(notEnglish, user);
- } catch(ComponentException e){
+ } catch(ByActionStatusComponentException e){
assertComponentException(e, ActionStatus.COMPONENT_INVALID_DESCRIPTION, ComponentTypeEnum.SERVICE.getValue());
}
}
serviceExist.setIcon("");
try{
bl.createService(serviceExist, user);
- } catch(ComponentException e) {
+ } catch(ByActionStatusComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_MISSING_ICON, ComponentTypeEnum.SERVICE.getValue());
}
}
serviceExist.setIcon(null);
try{
bl.createService(serviceExist, user);
- } catch(ComponentException e) {
+ } catch(ByActionStatusComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_MISSING_ICON, ComponentTypeEnum.SERVICE.getValue());
}
}
resourceExist.setIcon("kjk3453^&");
try{
bl.createService(resourceExist, user);
- } catch(ComponentException e) {
+ } catch(ByActionStatusComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_ICON, ComponentTypeEnum.SERVICE.getValue());
}
}
resourceExist.setIcon("dsjfhskdfhskjdhfskjdhkjdhfkshdfksjsdkfhsdfsdfsdfsfsdfsf");
try{
bl.createService(resourceExist, user);
- } catch(ComponentException e) {
+ } catch(ByActionStatusComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT, "Service", "25");
}
}
serviceExccedsNameLimit.setTags(tagsList);
try{
bl.createService(serviceExccedsNameLimit, user);
- } catch(ComponentException e) {
+ } catch(ByActionStatusComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME);
}
}
serviceExccedsNameLimit.setTags(tagsList);
try{
bl.createService(serviceExccedsNameLimit, user);
- } catch(ComponentException e) {
+ } catch(ByActionStatusComponentException e) {
assertComponentException(e, ActionStatus.INVALID_FIELD_FORMAT, "Service", "tag");
}
}
serviceExist.setTags(null);
try{
bl.createService(serviceExist, user);
- } catch(ComponentException e) {
+ } catch(ByActionStatusComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_MISSING_TAGS);
}
}
serviceExist.setTags(new ArrayList<>());
try{
bl.createService(serviceExist, user);
- } catch(ComponentException e) {
+ } catch(ByActionStatusComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_MISSING_TAGS);
}
}
serviceContactId.setContactId(contactIdTooLong);
try{
bl.createService(serviceContactId, user);
- } catch(ComponentException e) {
+ } catch(ByActionStatusComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.SERVICE.getValue());
}
}
serviceContactId.setContactId(contactIdTooLong);
try{
bl.createService(serviceContactId, user);
- } catch(ComponentException e) {
+ } catch(ByActionStatusComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.SERVICE.getValue());
}
}
resourceExist.setContactId(null);
try{
bl.createService(resourceExist, user);
- } catch(ComponentException e) {
+ } catch(ByActionStatusComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_MISSING_CONTACT, ComponentTypeEnum.SERVICE.getValue());
}
}
serviceExist.setCategories(null);
try{
bl.createService(serviceExist, user);
- } catch(ComponentException e) {
+ } catch(ByActionStatusComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.SERVICE.getValue());
}
}
serviceExist.setCategories(categories);
try{
bl.createService(serviceExist, user);
- } catch(ComponentException e) {
+ } catch(ByActionStatusComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_CATEGORY, ComponentTypeEnum.SERVICE.getValue());
}
}
serviceExist.setProjectCode(null);
try{
bl.createService(serviceExist, user);
- } catch(ComponentException e) {
+ } catch(ByActionStatusComponentException e) {
assertComponentException(e, ActionStatus.MISSING_PROJECT_CODE);
}
}