diff options
author | sheetalm <sheetal.mudholkar@amdocs.com> | 2018-04-02 18:12:54 +0530 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2018-04-10 14:37:17 +0000 |
commit | 40bd5b855df62e257e4cc2810a95248bc3426302 (patch) | |
tree | 518cff1b6aaf972a3f06066f8e47ac1a5e65bfee /services/activity-spec/activity-spec-web/activity-spec-service/src/test | |
parent | 7a9073719da3db83024e66a1da9ba14546cfd175 (diff) |
Activity Spec - Change Error Response Structure
1 Added ActivitySpecNotFoundException to map to 404 Not Found response code
2 404 Not Found response code will only be returned in case activity spec
does not exists irrespective of GET or PUT used in REST
3 Update flow test to check error messages
4 Error Response to have only "message" now
5 Use proper response code instead of EXPECTATION_FAILED
Change-Id: I82fb3c0970f4e9416d9fe2577174dcaf0a4fef92
Issue-ID: SDC-1048
Signed-off-by: sheetalm <sheetal.mudholkar@amdocs.com>
Diffstat (limited to 'services/activity-spec/activity-spec-web/activity-spec-service/src/test')
-rw-r--r-- | services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImplTest.java | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImplTest.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImplTest.java index ac44b031bf..e930dd9454 100644 --- a/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImplTest.java +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/test/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImplTest.java @@ -26,6 +26,7 @@ import org.openecomp.activityspec.api.rest.types.ActivitySpecAction; import org.openecomp.activityspec.be.dao.ActivitySpecDao; import org.openecomp.activityspec.be.dao.types.ActivitySpecEntity; import org.openecomp.activityspec.be.datatypes.ActivitySpecParameter; +import org.openecomp.activityspec.errors.ActivitySpecNotFoundException; import org.openecomp.core.dao.UniqueValueDao; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.SdcRuntimeException; @@ -47,14 +48,14 @@ import static org.mockito.Matchers.anyObject; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.verify; +import static org.openecomp.activityspec.utils.ActivitySpecConstant.ACTIVITY_SPEC_NOT_FOUND; +import static org.openecomp.activityspec.utils.ActivitySpecConstant.INVALID_STATE; import static org.openecomp.activityspec.utils.ActivitySpecConstant.VERSION_ID_DEFAULT_VALUE; public class ActivitySpecManagerImplTest { private static final String STRING_TYPE = "String"; - private static final String ACTIVITYSPEC_NOT_FOUND = "ACTIVITYSPEC_NOT_FOUND"; private static final String TEST_ERROR_MSG = "Test Error"; - private static final String ERROR_MSG_PREFIX = "STATUS_NOT_"; private ActivitySpecEntity input; private static final Version VERSION01 = new Version("12345"); private static final String ID = "ID1"; @@ -188,8 +189,8 @@ public class ActivitySpecManagerImplTest { try { activitySpecManager.get(input); Assert.fail(); - } catch (CoreException exception) { - Assert.assertEquals(exception.code().id(), ACTIVITYSPEC_NOT_FOUND); + } catch (ActivitySpecNotFoundException exception) { + Assert.assertEquals(exception.getMessage(), ACTIVITY_SPEC_NOT_FOUND); } } @@ -203,8 +204,8 @@ public class ActivitySpecManagerImplTest { try { activitySpecManager.get(input); Assert.fail(); - } catch (CoreException exception) { - Assert.assertEquals(exception.code().id(), ACTIVITYSPEC_NOT_FOUND); + } catch (ActivitySpecNotFoundException exception) { + Assert.assertEquals(exception.getMessage(), ACTIVITY_SPEC_NOT_FOUND); } } @@ -215,8 +216,7 @@ public class ActivitySpecManagerImplTest { VERSION01.getId(), ActivitySpecAction.DEPRECATE); } catch (CoreException exception) { - Assert.assertEquals(exception.code().id(), ERROR_MSG_PREFIX +VersionStatus.Certified.name() - .toUpperCase()); + Assert.assertEquals(exception.getMessage(), INVALID_STATE); } } @@ -227,8 +227,7 @@ public class ActivitySpecManagerImplTest { VERSION01.getId(), ActivitySpecAction.DELETE); } catch (CoreException exception) { - Assert.assertEquals(exception.code().id(), ERROR_MSG_PREFIX+VersionStatus.Deprecated.name() - .toUpperCase()); + Assert.assertEquals(exception.getMessage(), INVALID_STATE); } } @@ -252,8 +251,7 @@ public class ActivitySpecManagerImplTest { VERSION01.getId(), ActivitySpecAction.CERTIFY); } catch (CoreException exception) { - Assert.assertEquals(exception.code().id(), ERROR_MSG_PREFIX+VersionStatus.Draft.name() - .toUpperCase()); + Assert.assertEquals(exception.getMessage(), INVALID_STATE); } } @@ -265,8 +263,8 @@ public class ActivitySpecManagerImplTest { activitySpecManager.actOnAction(ID, VERSION01.getId(), ActivitySpecAction.CERTIFY); Assert.fail(); - } catch (CoreException exception) { - Assert.assertEquals(exception.code().id(), ACTIVITYSPEC_NOT_FOUND); + } catch (ActivitySpecNotFoundException exception) { + Assert.assertEquals(exception.getMessage(), ACTIVITY_SPEC_NOT_FOUND); } } |