From 8a42713718e46751938a63ccdca4d16244416dd8 Mon Sep 17 00:00:00 2001 From: vasraz Date: Tue, 23 Mar 2021 17:19:24 +0000 Subject: Improve test coverage Signed-off-by: Vasyl Razinkov Change-Id: I0ab217e32798f48a4d4463a90dd008a9fbcf64d3 Issue-ID: SDC-3428 --- .../action/errors/ActionExceptionMapperTest.java | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/test/java/org/openecomp/sdc/action/errors/ActionExceptionMapperTest.java (limited to 'openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/test/java') 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()); + + } + +} -- cgit 1.2.3-korg