2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.appc.requesthandler.impl;
26 import org.onap.appc.domainmodel.lcm.ActionIdentifiers;
27 import org.onap.appc.domainmodel.lcm.ActionLevel;
28 import org.onap.appc.domainmodel.lcm.CommonHeader;
29 import org.onap.appc.domainmodel.lcm.RequestContext;
30 import org.onap.appc.domainmodel.lcm.ResponseContext;
31 import org.onap.appc.domainmodel.lcm.RuntimeContext;
32 import org.onap.appc.domainmodel.lcm.VNFOperation;
34 import java.util.Date;
37 * Creates RequestContextInput for ActionStatus JUnits
39 public interface LocalRequestHanlderTestHelper {
40 default RuntimeContext createRequestHandlerRuntimeContext(String vnfId, String payload) {
41 RuntimeContext context = new RuntimeContext();
43 RequestContext requestContext = createRequestContext(VNFOperation.ActionStatus, "requestId1",
44 vnfId, ActionLevel.MGMT, payload);
45 context.setRequestContext(requestContext);
47 ResponseContext resContext = new ResponseContext();
48 resContext.setCommonHeader(context.getRequestContext().getCommonHeader());
49 context.setResponseContext(resContext);
54 default RequestContext createRequestContext(VNFOperation operation, String requestId, String vnfId,
55 ActionLevel level, String payload) {
56 RequestContext reqContext = new RequestContext();
57 reqContext.setCommonHeader(getCommonHeader(requestId, "2.0.0", "originatorId"));
58 reqContext.setActionLevel(level);
59 reqContext.setAction(operation);
60 reqContext.setPayload(payload);
61 reqContext.setActionIdentifiers(getActionIdentifiers(vnfId, null, null));
66 default ActionIdentifiers getActionIdentifiers(String vnfId, String vnfcId, String vserverId) {
67 ActionIdentifiers builder = new ActionIdentifiers();
68 builder.setVnfId(vnfId);
69 builder.setVnfcName(vnfcId);
70 builder.setvServerId(vserverId);
74 default CommonHeader getCommonHeader(String requestId, String apiVer, String originatorId) {
75 CommonHeader builder = new CommonHeader();
76 builder.setRequestId(requestId);
77 builder.setApiVer(apiVer);
78 builder.setOriginatorId(originatorId);
79 builder.setTimestamp(new Date(System.currentTimeMillis()));