blob: 0c701b1d315091ef54cce9e7311c7ce33dabd9fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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());
}
}
|