diff options
author | vasraz <vasyl.razinkov@est.tech> | 2021-03-23 17:19:24 +0000 |
---|---|---|
committer | Christophe Closset <christophe.closset@intl.att.com> | 2021-03-24 12:37:26 +0000 |
commit | 8a42713718e46751938a63ccdca4d16244416dd8 (patch) | |
tree | 980159a364ad4a43e07378837bb942766eee6812 /openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/test | |
parent | 3338ccfb38a060b7f2e0036c1b31e24eaa31756c (diff) |
Improve test coverage
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: I0ab217e32798f48a4d4463a90dd008a9fbcf64d3
Issue-ID: SDC-3428
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/test')
-rw-r--r-- | openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/test/java/org/openecomp/sdc/action/errors/ActionExceptionMapperTest.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/test/java/org/openecomp/sdc/action/errors/ActionExceptionMapperTest.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/test/java/org/openecomp/sdc/action/errors/ActionExceptionMapperTest.java new file mode 100644 index 0000000000..0c701b1d31 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/test/java/org/openecomp/sdc/action/errors/ActionExceptionMapperTest.java @@ -0,0 +1,53 @@ +package org.openecomp.sdc.action.errors; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_UPDATE_READ_ONLY; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_AUTHENTICATION_ERR_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_NOT_LOCKED_CODE; + +import javax.ws.rs.core.Response; +import org.junit.jupiter.api.Test; + +class ActionExceptionMapperTest { + + private ActionExceptionMapper createTestSubject() { + return new ActionExceptionMapper(); + } + + @Test + void toResponse_test() { + final ActionExceptionMapper testSubject = createTestSubject(); + ActionException actionException; + Response response; + + actionException = new ActionException(ACTION_NOT_LOCKED_CODE, "ACT1021"); + response = testSubject.toResponse(actionException); + assertNotNull(response); + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus()); + + actionException = new ActionException(ACTION_AUTHENTICATION_ERR_CODE, "ACT1000"); + response = testSubject.toResponse(actionException); + assertNotNull(response); + assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), response.getStatus()); + + actionException = new ActionException(ACTION_ARTIFACT_UPDATE_READ_ONLY, "ACT1026"); + response = testSubject.toResponse(actionException); + assertNotNull(response); + assertEquals(Response.Status.FORBIDDEN.getStatusCode(), response.getStatus()); + + actionException = new ActionException(ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE, "ACT1046"); + response = testSubject.toResponse(actionException); + assertNotNull(response); + assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus()); + + actionException = new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, "ACT1060"); + response = testSubject.toResponse(actionException); + assertNotNull(response); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus()); + + } + +} |