diff options
author | Gary Wu <gary.i.wu@huawei.com> | 2017-04-08 14:36:17 -0700 |
---|---|---|
committer | Gary Wu <gary.i.wu@huawei.com> | 2017-04-19 01:20:39 +0000 |
commit | c9373d8f5809fe650c30832e9409282cb34688f8 (patch) | |
tree | 5a45528f254e3347328e3fe6ce1851cf51e98012 /appc-dispatcher/appc-request-handler/appc-request-handler-core/src | |
parent | a8d6915645c780c9e0eef189fb72d45635b581a0 (diff) |
Refactor Status to be immutable
Change Status class to be immutable.
Add convenience method to convert from a LCMCommandStatus to
a Status object.
Change-Id: I9e47750d15b5ee0f5649b2fabf6387aa12ff9c9d
Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
Diffstat (limited to 'appc-dispatcher/appc-request-handler/appc-request-handler-core/src')
4 files changed, 12 insertions, 20 deletions
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java index d1303605d..0259ec452 100644 --- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java +++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java @@ -175,11 +175,11 @@ public class RequestHandlerImpl implements RequestHandler { runtimeContext.setRpcName(input.getRpcName()); final ResponseContext responseContext = new ResponseContext(); - responseContext.setStatus(new Status()); + responseContext.setStatus(new Status(0, null)); responseContext.setAdditionalContext(new HashMap<String, String>(4)); responseContext.setCommonHeader(input.getRequestContext().getCommonHeader()); runtimeContext.setResponseContext(responseContext); - runtimeContext.getResponseContext().setStatus(new Status()); + runtimeContext.getResponseContext().setStatus(new Status(0, null)); vnfId = runtimeContext.getRequestContext().getActionIdentifiers().getVnfId(); @@ -402,8 +402,7 @@ public class RequestHandlerImpl implements RequestHandler { } private void fillStatus(RuntimeContext runtimeContext, LCMCommandStatus lcmCommandStatus, Params params) { - runtimeContext.getResponseContext().getStatus().setCode(lcmCommandStatus.getResponseCode()); - runtimeContext.getResponseContext().getStatus().setMessage(lcmCommandStatus.getFormattedMessage(params)); + runtimeContext.getResponseContext().setStatus(lcmCommandStatus.toStatus(params)); } /* @@ -414,7 +413,7 @@ public class RequestHandlerImpl implements RequestHandler { RuntimeContext other = new RuntimeContext(); other.setRequestContext(runtimeContext.getRequestContext()); other.setResponseContext(new ResponseContext()); - other.getResponseContext().setStatus(new Status()); + other.getResponseContext().setStatus(new Status(0, null)); other.getResponseContext().setCommonHeader(runtimeContext.getRequestContext().getCommonHeader()); other.setVnfContext(runtimeContext.getVnfContext()); other.setRpcName(runtimeContext.getRpcName()); @@ -569,10 +568,7 @@ public class RequestHandlerImpl implements RequestHandler { private static RequestHandlerOutput buildRequestHandlerOutput(LCMCommandStatus response, Params params) { RequestHandlerOutput output = new RequestHandlerOutput(); ResponseContext responseContext = new ResponseContext(); - org.openecomp.appc.domainmodel.lcm.Status status = new org.openecomp.appc.domainmodel.lcm.Status(); - status.setCode(response.getResponseCode()); - status.setMessage(response.getFormattedMessage(params)); - responseContext.setStatus(status); + responseContext.setStatus(response.toStatus(params)); output.setResponseContext(responseContext); return output; } diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestConverter.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestConverter.java index 46875a269..aaf17fba9 100644 --- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestConverter.java +++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestConverter.java @@ -324,8 +324,7 @@ public class TestConverter { private ResponseContext buildAsyncResponse() { ResponseContext asyncResponse = createResponseContextWithSubObjects(); - asyncResponse.getStatus().setCode(LCMCommandStatus.SUCCESS.getResponseCode()); - asyncResponse.getStatus().setMessage(LCMCommandStatus.SUCCESS.getResponseMessage()); + asyncResponse.setStatus(LCMCommandStatus.SUCCESS.toStatus(null)); asyncResponse.getCommonHeader().setOriginatorId("oid"); asyncResponse.getCommonHeader().setApiVer("2.0.0"); asyncResponse.getCommonHeader().setRequestId("reqid"); @@ -339,9 +338,8 @@ public class TestConverter { ResponseContext responseContext = new ResponseContext(); CommonHeader commonHeader = new CommonHeader(); Flags flags = new Flags(); - Status status = new Status(); responseContext.setCommonHeader(commonHeader); - responseContext.setStatus(status); + responseContext.setStatus(new Status(0, null)); commonHeader.setFlags(flags); return responseContext; } diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestHandler.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestHandler.java index e4c1e92d3..e060775ce 100644 --- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestHandler.java +++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestHandler.java @@ -302,12 +302,12 @@ public class TestRequestHandler { ResponseContext responseContext = new ResponseContext(); - responseContext.setStatus(new Status()); + responseContext.setStatus(new Status(0, null)); responseContext.setAdditionalContext(new HashMap<String, String>(4)); responseContext.setCommonHeader(input1.getRequestContext().getCommonHeader()); runtimeContext.setResponseContext(responseContext); when(runtimeContext.getResponseContext()).thenReturn(responseContext); - responseContext.setStatus(new Status()); + responseContext.setStatus(new Status(0, null)); runtimeContext.setResponseContext(responseContext); PowerMockito.whenNew(RuntimeContext.class).withAnyArguments().thenReturn(runtimeContext); @@ -451,7 +451,7 @@ public class TestRequestHandler { output.getVnfContext().setId(vnfId); output.getResponseContext().getCommonHeader().setApiVer("2.0.0"); output.getResponseContext().getCommonHeader().setTimestamp(new Date()); - output.getResponseContext().getStatus().setCode(LCMCommandStatus.SUCCESS.getResponseCode()); + output.getResponseContext().setStatus(LCMCommandStatus.SUCCESS.toStatus(null)); output.setTimeStart(new Date()); output.getResponseContext().getCommonHeader().setOriginatorId(originatorId); output.getResponseContext().getCommonHeader().setRequestId(requestId); @@ -566,9 +566,8 @@ public class TestRequestHandler { ResponseContext responseContext = new ResponseContext(); CommonHeader commonHeader = new CommonHeader(); Flags flags = new Flags(); - Status status = new Status(); responseContext.setCommonHeader(commonHeader); - responseContext.setStatus(status); + responseContext.setStatus(new Status(0, null)); commonHeader.setFlags(flags); return responseContext; } diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestValidator.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestValidator.java index 344f20478..becd95d46 100644 --- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestValidator.java +++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestValidator.java @@ -601,9 +601,8 @@ public class TestRequestValidator { ResponseContext responseContext = new ResponseContext(); CommonHeader commonHeader = new CommonHeader(); Flags flags = new Flags(); - Status status = new Status(); responseContext.setCommonHeader(commonHeader); - responseContext.setStatus(status); + responseContext.setStatus(new Status(0, null)); commonHeader.setFlags(flags); return responseContext; } |