From 4f774eeef8c1797c7073754412535be47ea1a8d7 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max" Date: Tue, 28 Apr 2020 15:13:12 -0400 Subject: move aai-client into its own project move aai-client into its own project Issue-ID: SO-2837 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I20b700d160efbdf81ff22c9ca0fab73b28d3649b --- .../org/onap/so/bpmn/common/InjectionHelper.java | 6 - bpmn/pom.xml | 5 + .../so/client/helper/TasksInjectionHelper.java | 16 ++ .../orchestration/SDNOHealthCheckResources.java | 4 +- .../onap/so/client/sdno/SDNOHealthCheckClient.java | 167 +++++++++++++++++ .../org/onap/so/client/sdno/SDNOValidator.java | 55 ++++++ .../org/onap/so/client/sdno/SDNOValidatorImpl.java | 128 +++++++++++++ .../onap/so/client/sdno/beans/AAIParamList.java | 83 +++++++++ .../java/org/onap/so/client/sdno/beans/Body.java | 77 ++++++++ .../java/org/onap/so/client/sdno/beans/Input.java | 90 ++++++++++ .../onap/so/client/sdno/beans/RequestHdCustom.java | 183 +++++++++++++++++++ .../client/sdno/beans/RequestHealthDiagnostic.java | 197 +++++++++++++++++++++ .../org/onap/so/client/sdno/beans/ResultInfo.java | 112 ++++++++++++ .../java/org/onap/so/client/sdno/beans/SDNO.java | 128 +++++++++++++ .../SDNOHealthCheckResourcesTest.java | 7 +- .../so/client/sdno/SDNOHealthCheckClientTest.java | 94 ++++++++++ .../org/onap/so/client/sdno/SDNOValidatorIT.java | 124 +++++++++++++ .../onap/so/client/sdno/SDNOValidatorImplTest.java | 56 ++++++ .../src/test/resources/application-test.yaml | 10 +- .../custom-lport-mirror-post-check-request.json | 27 +++ .../custom-lport-mirror-pre-check-request.json | 27 +++ .../custom-port-mirror-post-check-request.json | 23 +++ .../custom-port-mirror-pre-check-request.json | 23 +++ .../org/onap/so/client/sdno/output-failure.json | 25 +++ .../org/onap/so/client/sdno/output-success.json | 22 +++ .../org/onap/so/client/sdno/response.json | 17 ++ 26 files changed, 1693 insertions(+), 13 deletions(-) create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/helper/TasksInjectionHelper.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java create mode 100644 bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json create mode 100644 bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json create mode 100644 bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json create mode 100644 bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json create mode 100644 bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-failure.json create mode 100644 bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-success.json create mode 100644 bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/response.json (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/InjectionHelper.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/InjectionHelper.java index 3791c5d461..5a9ef25c03 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/InjectionHelper.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/InjectionHelper.java @@ -27,8 +27,6 @@ import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.cds.CDSProcessingClient; import org.onap.so.client.cds.CDSProcessingListener; import org.onap.so.client.policy.PolicyClientImpl; -import org.onap.so.client.sdno.SDNOValidator; -import org.onap.so.client.sdno.SDNOValidatorImpl; import org.springframework.stereotype.Component; /* @@ -51,10 +49,6 @@ public class InjectionHelper { return new AAIQueryClient(); } - public SDNOValidator getSdnoValidator() { - return new SDNOValidatorImpl(); - } - public AAICommonObjectMapperProvider getAaiCommonObjectMapperProvider() { return new AAICommonObjectMapperProvider(); } diff --git a/bpmn/pom.xml b/bpmn/pom.xml index 4ef4eb74dd..36fb17c9b4 100644 --- a/bpmn/pom.xml +++ b/bpmn/pom.xml @@ -91,6 +91,11 @@ spring-boot-starter-data-jpa true + + org.onap.so + aai-client + ${project.version} + diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/helper/TasksInjectionHelper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/helper/TasksInjectionHelper.java new file mode 100644 index 0000000000..411bc73057 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/helper/TasksInjectionHelper.java @@ -0,0 +1,16 @@ +package org.onap.so.client.helper; + +import org.onap.so.client.sdno.SDNOValidator; +import org.onap.so.client.sdno.SDNOValidatorImpl; +import org.springframework.stereotype.Component; + +@Component +public class TasksInjectionHelper { + + + + public SDNOValidator getSdnoValidator() { + return new SDNOValidatorImpl(); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNOHealthCheckResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNOHealthCheckResources.java index e93b80c562..59f75b1d2f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNOHealthCheckResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNOHealthCheckResources.java @@ -21,16 +21,16 @@ package org.onap.so.client.orchestration; import java.util.UUID; -import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.helper.TasksInjectionHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class SDNOHealthCheckResources { @Autowired - private InjectionHelper injectionHelper; + private TasksInjectionHelper injectionHelper; /** * SDNO Call to Check Health Status diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java new file mode 100644 index 0000000000..9b857dc08c --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOHealthCheckClient.java @@ -0,0 +1,167 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.sdno; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import org.onap.so.client.dmaap.DmaapConsumer; +import org.onap.so.client.dmaap.DmaapPublisher; +import org.onap.so.client.sdno.beans.AAIParamList; +import org.onap.so.client.sdno.beans.Body; +import org.onap.so.client.sdno.beans.Input; +import org.onap.so.client.sdno.beans.RequestHdCustom; +import org.onap.so.client.sdno.beans.SDNO; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapPublisher; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class SDNOHealthCheckClient { + + private static final String NODE_TYPE = "VROUTER"; + private static final String API_OPERATION_TYPE = "health-diagnostic-custom"; + private static final String MIRRORING_CHECK = "mirroring_check"; + private static final String CLIENT_NAME = "MSO"; + private static final String PRE_CHECK_CODE = "VROUTER000003"; + private static final String POST_CHECK_CODE = "VROUTER000004"; + private static final String LPORT_MIRRORING_CHECK = "lport_mirroring_check"; + private static final String CONFIGURATION_ID = "configuration-id"; + + + public boolean lPortMirrorHealthPreCheck(String userId, String requestId, Optional clliCode, + String configurationId, String interfaceId) throws Exception { + String request = buildLPortMirrorCheckPreRequest(userId, requestId, clliCode, configurationId, interfaceId); + return this.execute(requestId, request); + } + + public boolean lPortMirrorHealthPostCheck(String userId, String requestId, Optional clliCode, + String configurationId, String interfaceId) throws Exception { + String request = buildLPortMirrorCheckPostRequest(userId, requestId, clliCode, configurationId, interfaceId); + return this.execute(requestId, request); + } + + public boolean portMirrorHealthPreCheck(String userId, String requestId, Optional clliCode, + String configurationId) throws Exception { + final String request = this.buildPortMirrorPreCheckRequest(userId, requestId, clliCode, configurationId); + return this.execute(requestId, request); + } + + public boolean portMirrorHealthPostCheck(String userId, String requestId, Optional clliCode, + String configurationId) throws Exception { + final String request = this.buildPortMirrorPostCheckRequest(userId, requestId, clliCode, configurationId); + return this.execute(requestId, request); + } + + protected String buildLPortMirrorCheckPreRequest(String userId, String requestId, Optional clliCode, + String configurationId, String interfaceId) throws JsonProcessingException { + return this.buildLPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, interfaceId, + PRE_CHECK_CODE); + } + + protected String buildLPortMirrorCheckPostRequest(String userId, String requestId, Optional clliCode, + String configurationId, String interfaceId) throws JsonProcessingException { + return this.buildLPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, interfaceId, + POST_CHECK_CODE); + } + + protected String buildPortMirrorPreCheckRequest(String userId, String requestId, Optional clliCode, + String configurationId) throws JsonProcessingException { + return this.buildPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, PRE_CHECK_CODE); + } + + protected String buildPortMirrorPostCheckRequest(String userId, String requestId, Optional clliCode, + String configurationId) throws JsonProcessingException { + return this.buildPortMirrorCheckRequest(userId, requestId, clliCode, configurationId, POST_CHECK_CODE); + } + + protected String buildPortMirrorCheckRequest(String userId, String requestId, Optional clliCode, + String configurationId, String diagnosticCode) throws JsonProcessingException { + final AAIParamList list = new AAIParamList(); + list.setKey(CONFIGURATION_ID); + list.setValue(configurationId); + + return this.buildRequest(userId, requestId, clliCode, diagnosticCode, MIRRORING_CHECK, + Collections.singletonList(list)); + } + + protected String buildLPortMirrorCheckRequest(String userId, String requestId, Optional clliCode, + String configurationId, String interfaceId, String diagnosticCode) throws JsonProcessingException { + + final AAIParamList configurationIdParam = new AAIParamList(); + configurationIdParam.setKey(CONFIGURATION_ID); + configurationIdParam.setValue(configurationId); + final AAIParamList interfaceIdParam = new AAIParamList(); + interfaceIdParam.setKey("interface-id"); + interfaceIdParam.setValue(interfaceId); + final List list = new ArrayList<>(); + list.add(configurationIdParam); + list.add(interfaceIdParam); + return this.buildRequest(userId, requestId, clliCode, diagnosticCode, LPORT_MIRRORING_CHECK, list); + } + + + protected String buildRequest(String userId, String requestId, Optional clliCode, String diagnosticCode, + String operationType, List paramList) throws JsonProcessingException { + + final RequestHdCustom hdCustom = new RequestHdCustom(); + hdCustom.withRequestUserId(userId).withRequestId(requestId).withRequestClientName(CLIENT_NAME) + .withHealthDiagnosticCode(diagnosticCode).withOperationType(operationType).withAaiParamList(paramList); + + final Input input = new Input(); + input.setRequestHdCustom(hdCustom); + final Body body = new Body(); + body.setInput(input); + final SDNO request = new SDNO(); + request.withBody(body).withOperation(API_OPERATION_TYPE).withNodeType(NODE_TYPE); + if (clliCode.isPresent()) { + request.setNodeLoc(clliCode.get()); + } + return this.getJson(request); + + } + + protected String getJson(SDNO obj) throws JsonProcessingException { + final ObjectMapper mapper = new ObjectMapper(); + return mapper.writeValueAsString(obj); + } + + protected DmaapPublisher getPublisher() throws FileNotFoundException, IOException { + return new SDNOHealthCheckDmaapPublisher(); + } + + protected DmaapConsumer getConsumer(String requestId) throws FileNotFoundException, IOException { + return new SDNOHealthCheckDmaapConsumer(requestId); + } + + protected boolean execute(String requestId, String request) throws Exception { + final DmaapPublisher publisher = this.getPublisher(); + publisher.send(request); + + final DmaapConsumer consumer = this.getConsumer(requestId); + + return consumer.consume(); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java new file mode 100644 index 0000000000..83624dec63 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidator.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.sdno; + +import java.io.IOException; +import java.util.UUID; +import org.onap.aai.domain.yang.GenericVnf; + +public interface SDNOValidator { + + /** + * Issues a health diagnostic request for a given vnf to SDN-O + * + * @param vnfId + * @param uuid + * @param requestingUserId + * @return diagnostic result + * @throws IOException + * @throws Exception + */ + public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception; + + + /** + * Issues a health diagnostic request for a given GenericVnf to SDN-O + * + * @param genericVnf + * @param uuid + * @param requestingUserId + * @return diagnostic result + * @throws IOException + * @throws Exception + */ + public boolean healthDiagnostic(GenericVnf genericVnf, UUID uuid, String requestingUserId) + throws IOException, Exception; + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java new file mode 100644 index 0000000000..8e674fb77b --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/SDNOValidatorImpl.java @@ -0,0 +1,128 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.sdno; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Optional; +import java.util.UUID; +import javax.ws.rs.NotFoundException; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.dmaap.DmaapConsumer; +import org.onap.so.client.dmaap.DmaapPublisher; +import org.onap.so.client.sdno.beans.Body; +import org.onap.so.client.sdno.beans.Input; +import org.onap.so.client.sdno.beans.RequestHealthDiagnostic; +import org.onap.so.client.sdno.beans.SDNO; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapPublisher; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class SDNOValidatorImpl implements SDNOValidator { + + private final static String clientName = "MSO"; + private final static String HEALTH_DIAGNOSTIC_CODE_DEFAULT = "default"; + + @Override + public boolean healthDiagnostic(String vnfId, UUID uuid, String requestingUserId) throws IOException, Exception { + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + AAIResourcesClient client = new AAIResourcesClient(); + GenericVnf vnf = client.get(GenericVnf.class, uri) + .orElseThrow(() -> new NotFoundException(vnfId + " not found in A&AI")); + + SDNO requestDiagnostic = buildRequestDiagnostic(vnf, uuid, requestingUserId); + ObjectMapper mapper = new ObjectMapper(); + String json = mapper.writeValueAsString(requestDiagnostic); + this.submitRequest(json); + boolean status = this.pollForResponse(uuid.toString()); + return status; + } + + @Override + public boolean healthDiagnostic(GenericVnf genericVnf, UUID uuid, String requestingUserId) + throws IOException, Exception { + + SDNO requestDiagnostic = buildRequestDiagnostic(genericVnf, uuid, requestingUserId); + ObjectMapper mapper = new ObjectMapper(); + String json = mapper.writeValueAsString(requestDiagnostic); + this.submitRequest(json); + boolean status = this.pollForResponse(uuid.toString()); + return status; + } + + protected SDNO buildRequestDiagnostic(GenericVnf vnf, UUID uuid, String requestingUserId) { + + Optional nfRole; + if (vnf.getNfRole() == null) { + nfRole = Optional.empty(); + } else { + nfRole = Optional.of(vnf.getNfRole()); + } + Input input = new Input(); + SDNO parentRequest = new SDNO(); + Body body = new Body(); + parentRequest.setBody(body); + parentRequest.setNodeType(nfRole.orElse("NONE").toUpperCase()); + parentRequest.setOperation("health-diagnostic"); + + body.setInput(input); + + RequestHealthDiagnostic request = new RequestHealthDiagnostic(); + + request.setRequestClientName(clientName); + request.setRequestNodeName(vnf.getVnfName()); + request.setRequestNodeUuid(vnf.getVnfId()); + request.setRequestNodeType(nfRole.orElse("NONE").toUpperCase()); + request.setRequestNodeIp(vnf.getIpv4OamAddress()); // generic-vnf oam ip + request.setRequestUserId(requestingUserId); // mech id? + request.setRequestId(uuid.toString()); // something to identify this request by for polling + request.setHealthDiagnosticCode(HEALTH_DIAGNOSTIC_CODE_DEFAULT); + + input.setRequestHealthDiagnostic(request); + + return parentRequest; + } + + protected void submitRequest(String json) throws FileNotFoundException, IOException, InterruptedException { + + DmaapPublisher publisher = new SDNOHealthCheckDmaapPublisher(); + publisher.send(json); + } + + protected boolean pollForResponse(String uuid) throws Exception { + DmaapConsumer consumer = this.getConsumer(uuid); + return consumer.consume(); + } + + + + protected DmaapConsumer getConsumer(String uuid) throws FileNotFoundException, IOException { + return new SDNOHealthCheckDmaapConsumer(uuid); + } + + + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java new file mode 100644 index 0000000000..7e98355b4d --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/AAIParamList.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.sdno.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"key", "value"}) +public class AAIParamList { + + @JsonProperty("key") + private String key; + @JsonProperty("value") + private String value; + + /** + * No args constructor for use in serialization + * + */ + public AAIParamList() {} + + /** + * + * @param value + * @param key + */ + public AAIParamList(String key, String value) { + super(); + this.key = key; + this.value = value; + } + + @JsonProperty("key") + public String getKey() { + return key; + } + + @JsonProperty("key") + public void setKey(String key) { + this.key = key; + } + + public AAIParamList withKey(String key) { + this.key = key; + return this; + } + + @JsonProperty("value") + public String getValue() { + return value; + } + + @JsonProperty("value") + public void setValue(String value) { + this.value = value; + } + + public AAIParamList withValue(String value) { + this.value = value; + return this; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java new file mode 100644 index 0000000000..8c40b749a6 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Body.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.sdno.beans; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"input"}) +public class Body implements Serializable { + + @JsonProperty("input") + private Input input; + @JsonIgnore + private Map additionalProperties = new HashMap<>(); + private static final long serialVersionUID = 9101706044452851559L; + + @JsonProperty("input") + public Input getInput() { + return input; + } + + @JsonProperty("input") + public void setInput(Input input) { + this.input = input; + } + + public Body withInput(Input input) { + this.input = input; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public void setAdditionalProperties(Map map) { + this.additionalProperties = map; + } + + public Body withAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + return this; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java new file mode 100644 index 0000000000..c8122c06f6 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/Input.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.sdno.beans; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"request-healthdiagnostic", "request-hd-custom"}) +public class Input implements Serializable { + + @JsonProperty("request-healthdiagnostic") + private RequestHealthDiagnostic RequestHealthDiagnostic; + @JsonProperty("request-hd-custom") + private RequestHdCustom requestHdCustom; + + @JsonIgnore + private Map additionalProperties = new HashMap<>(); + private final static long serialVersionUID = 7155546785389227528L; + + @JsonProperty("request-healthdiagnostic") + public RequestHealthDiagnostic getRequestHealthDiagnostic() { + return RequestHealthDiagnostic; + } + + @JsonProperty("request-healthdiagnostic") + public void setRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) { + this.RequestHealthDiagnostic = RequestHealthDiagnostic; + } + + @JsonProperty("request-hd-custom") + public RequestHdCustom getRequestHdCustom() { + return requestHdCustom; + } + + @JsonProperty("request-hd-custom") + public void setRequestHdCustom(RequestHdCustom requestHdCustom) { + this.requestHdCustom = requestHdCustom; + } + + public Input withRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) { + this.RequestHealthDiagnostic = RequestHealthDiagnostic; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public void setAdditionalProperties(Map map) { + this.additionalProperties = map; + } + + public Input withAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + return this; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java new file mode 100644 index 0000000000..485f64673f --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHdCustom.java @@ -0,0 +1,183 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.sdno.beans; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"request-client-name", "request-user-id", "request-id", "health-diagnostic-code", "operation-type", + "send-detailed-cmd-response", "aai-param-list"}) +public class RequestHdCustom implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -206110458275127710L; + @JsonProperty("request-client-name") + private String requestClientName; + @JsonProperty("request-user-id") + private String requestUserId; + @JsonProperty("request-id") + private String requestId; + @JsonProperty("health-diagnostic-code") + private String healthDiagnosticCode; + @JsonProperty("operation-type") + private String operationType; + @JsonProperty("send-detailed-cmd-response") + private String sendDetailedCmdResponse = "false"; + @JsonProperty("aai-param-list") + private List aaiParamList = new ArrayList<>(); + + /** + * No args constructor for use in serialization + * + */ + public RequestHdCustom() {} + + /** + * + * @param requestClientName + * @param operationType + * @param requestId + * @param healthDiagnosticCode + * @param aaiParamList + * @param requestUserId + */ + public RequestHdCustom(String requestClientName, String requestUserId, String requestId, + String healthDiagnosticCode, String operationType, List aaiParamList) { + super(); + this.requestClientName = requestClientName; + this.requestUserId = requestUserId; + this.requestId = requestId; + this.healthDiagnosticCode = healthDiagnosticCode; + this.operationType = operationType; + this.aaiParamList = aaiParamList; + } + + @JsonProperty("request-client-name") + public String getRequestClientName() { + return requestClientName; + } + + @JsonProperty("request-client-name") + public void setRequestClientName(String requestClientName) { + this.requestClientName = requestClientName; + } + + public RequestHdCustom withRequestClientName(String requestClientName) { + this.requestClientName = requestClientName; + return this; + } + + @JsonProperty("request-user-id") + public String getRequestUserId() { + return requestUserId; + } + + @JsonProperty("request-user-id") + public void setRequestUserId(String requestUserId) { + this.requestUserId = requestUserId; + } + + public RequestHdCustom withRequestUserId(String requestUserId) { + this.requestUserId = requestUserId; + return this; + } + + @JsonProperty("request-id") + public String getRequestId() { + return requestId; + } + + @JsonProperty("request-id") + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public RequestHdCustom withRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + @JsonProperty("health-diagnostic-code") + public String getHealthDiagnosticCode() { + return healthDiagnosticCode; + } + + @JsonProperty("health-diagnostic-code") + public void setHealthDiagnosticCode(String healthDiagnosticCode) { + this.healthDiagnosticCode = healthDiagnosticCode; + } + + public RequestHdCustom withHealthDiagnosticCode(String healthDiagnosticCode) { + this.healthDiagnosticCode = healthDiagnosticCode; + return this; + } + + @JsonProperty("operation-type") + public String getOperationType() { + return operationType; + } + + @JsonProperty("operation-type") + public void setOperationType(String operationType) { + this.operationType = operationType; + } + + public RequestHdCustom withOperationType(String operationType) { + this.operationType = operationType; + return this; + } + + public void setSendDetailedCmdResponse(String sendDetailedCmdResponse) { + this.sendDetailedCmdResponse = sendDetailedCmdResponse; + } + + public String getSendDetailedCmdResponse() { + return sendDetailedCmdResponse; + } + + public RequestHdCustom withSendDetailedCmdResponse(String sendDetailedCmdResponse) { + this.sendDetailedCmdResponse = sendDetailedCmdResponse; + return this; + } + + @JsonProperty("aai-param-list") + public List getAaiParamList() { + return aaiParamList; + } + + @JsonProperty("aai-param-list") + public void setAaiParamList(List aaiParamList) { + this.aaiParamList = aaiParamList; + } + + public RequestHdCustom withAaiParamList(List aaiParamList) { + this.aaiParamList = aaiParamList; + return this; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java new file mode 100644 index 0000000000..b1b75ab412 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/RequestHealthDiagnostic.java @@ -0,0 +1,197 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.sdno.beans; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"request-client-name", "request-node-name", "request-node-uuid", "request-node-ip", "request-id", + "request-user-id", "request-node-type", "health-diagnostic-code"}) +public class RequestHealthDiagnostic implements Serializable { + + @JsonProperty("request-client-name") + private String requestClientName; + @JsonProperty("request-node-name") + private String requestNodeName; + @JsonProperty("request-node-uuid") + private String requestNodeUuid; + @JsonProperty("request-node-ip") + private String requestNodeIp; + @JsonProperty("request-id") + private String requestId; + @JsonProperty("request-user-id") + private String requestUserId; + @JsonProperty("request-node-type") + private String requestNodeType; + @JsonProperty("health-diagnostic-code") + private String healthDiagnosticCode; + @JsonIgnore + private Map additionalProperties = new HashMap<>(); + private static final long serialVersionUID = 1166788526178388021L; + + @JsonProperty("request-client-name") + public String getRequestClientName() { + return requestClientName; + } + + @JsonProperty("request-client-name") + public void setRequestClientName(String requestClientName) { + this.requestClientName = requestClientName; + } + + public RequestHealthDiagnostic withRequestClientName(String requestClientName) { + this.requestClientName = requestClientName; + return this; + } + + @JsonProperty("request-node-name") + public String getRequestNodeName() { + return requestNodeName; + } + + @JsonProperty("request-node-name") + public void setRequestNodeName(String requestNodeName) { + this.requestNodeName = requestNodeName; + } + + public RequestHealthDiagnostic withRequestNodeName(String requestNodeName) { + this.requestNodeName = requestNodeName; + return this; + } + + @JsonProperty("request-node-uuid") + public String getRequestNodeUuid() { + return requestNodeUuid; + } + + @JsonProperty("request-node-uuid") + public void setRequestNodeUuid(String requestNodeUuid) { + this.requestNodeUuid = requestNodeUuid; + } + + public RequestHealthDiagnostic withRequestNodeUuid(String requestNodeUuid) { + this.requestNodeUuid = requestNodeUuid; + return this; + } + + @JsonProperty("request-node-ip") + public String getRequestNodeIp() { + return requestNodeIp; + } + + @JsonProperty("request-node-ip") + public void setRequestNodeIp(String requestNodeIp) { + this.requestNodeIp = requestNodeIp; + } + + public RequestHealthDiagnostic withRequestNodeIp(String requestNodeIp) { + this.requestNodeIp = requestNodeIp; + return this; + } + + @JsonProperty("request-id") + public String getRequestId() { + return requestId; + } + + @JsonProperty("request-id") + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public RequestHealthDiagnostic withRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + @JsonProperty("request-user-id") + public String getRequestUserId() { + return requestUserId; + } + + @JsonProperty("request-user-id") + public void setRequestUserId(String requestUserId) { + this.requestUserId = requestUserId; + } + + public RequestHealthDiagnostic withRequestUserId(String requestUserId) { + this.requestUserId = requestUserId; + return this; + } + + @JsonProperty("request-node-type") + public String getRequestNodeType() { + return requestNodeType; + } + + @JsonProperty("request-node-type") + public void setRequestNodeType(String requestNodeType) { + this.requestNodeType = requestNodeType; + } + + public RequestHealthDiagnostic withRequestNodeType(String requestNodeType) { + this.requestNodeType = requestNodeType; + return this; + } + + @JsonProperty("health-diagnostic-code") + public String getHealthDiagnosticCode() { + return healthDiagnosticCode; + } + + @JsonProperty("health-diagnostic-code") + public void setHealthDiagnosticCode(String healthDiagnosticCode) { + this.healthDiagnosticCode = healthDiagnosticCode; + } + + public RequestHealthDiagnostic withHealthDiagnosticCode(String healthDiagnosticCode) { + this.healthDiagnosticCode = healthDiagnosticCode; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public void setAdditionalProperties(Map map) { + this.additionalProperties = map; + } + + public RequestHealthDiagnostic withAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + return this; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java new file mode 100644 index 0000000000..8b84cf6659 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/ResultInfo.java @@ -0,0 +1,112 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.sdno.beans; + +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"client-name", "code", "processing-host", "request-id", "status"}) +public class ResultInfo { + + @JsonProperty("client-name") + private String clientName; + @JsonProperty("code") + private String code; + @JsonProperty("processing-host") + private String processingHost; + @JsonProperty("request-id") + private String requestId; + @JsonProperty("status") + private String status; + @JsonIgnore + private Map additionalProperties = new HashMap<>(); + + @JsonProperty("client-name") + public String getClientName() { + return clientName; + } + + @JsonProperty("client-name") + public void setClientName(String clientName) { + this.clientName = clientName; + } + + @JsonProperty("code") + public String getCode() { + return code; + } + + @JsonProperty("code") + public void setCode(String code) { + this.code = code; + } + + @JsonProperty("processing-host") + public String getProcessingHost() { + return processingHost; + } + + @JsonProperty("processing-host") + public void setProcessingHost(String processingHost) { + this.processingHost = processingHost; + } + + @JsonProperty("request-id") + public String getRequestId() { + return requestId; + } + + @JsonProperty("request-id") + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + @JsonProperty("status") + public String getStatus() { + return status; + } + + @JsonProperty("status") + public void setStatus(String status) { + this.status = status; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public void setAdditionalProperties(Map map) { + this.additionalProperties = map; + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java new file mode 100644 index 0000000000..46e2c1d1fc --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdno/beans/SDNO.java @@ -0,0 +1,128 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.sdno.beans; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"operation", "nodeLoc", "nodeType", "body"}) +public class SDNO implements Serializable { + + @JsonProperty("operation") + private String operation; + @JsonProperty("nodeLoc") + private String nodeLoc; + @JsonProperty("nodeType") + private String nodeType; + @JsonProperty("body") + private Body body; + @JsonIgnore + private Map additionalProperties = new HashMap<>(); + private static final long serialVersionUID = -5303297382564282650L; + + @JsonProperty("operation") + public String getOperation() { + return operation; + } + + @JsonProperty("operation") + public void setOperation(String operation) { + this.operation = operation; + } + + @JsonProperty("nodeLoc") + public String getNodeLoc() { + return nodeLoc; + } + + @JsonProperty("nodeLoc") + public void setNodeLoc(String nodeLoc) { + this.nodeLoc = nodeLoc; + } + + public SDNO withNodeLoc(String nodeLoc) { + this.nodeLoc = nodeLoc; + return this; + } + + public SDNO withOperation(String operation) { + this.operation = operation; + return this; + } + + @JsonProperty("nodeType") + public String getNodeType() { + return nodeType; + } + + @JsonProperty("nodeType") + public void setNodeType(String nodeType) { + this.nodeType = nodeType; + } + + public SDNO withNodeType(String nodeType) { + this.nodeType = nodeType; + return this; + } + + @JsonProperty("body") + public Body getBody() { + return body; + } + + @JsonProperty("body") + public void setBody(Body body) { + this.body = body; + } + + public SDNO withBody(Body body) { + this.body = body; + return this; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @JsonAnySetter + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } + + public void setAdditionalProperties(Map map) { + this.additionalProperties = map; + } + + public SDNO SDNO(String name, Object value) { + this.additionalProperties.put(name, value); + return this; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNOHealthCheckResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNOHealthCheckResourcesTest.java index 265bb5d3b5..a2a1c8a949 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNOHealthCheckResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNOHealthCheckResourcesTest.java @@ -21,9 +21,8 @@ package org.onap.so.client.orchestration; import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; import java.util.UUID; import org.junit.Before; import org.junit.Test; @@ -32,9 +31,9 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.bpmn.common.data.TestDataSetup; -import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.helper.TasksInjectionHelper; import org.onap.so.client.sdno.SDNOValidator; @RunWith(MockitoJUnitRunner.Silent.class) @@ -49,7 +48,7 @@ public class SDNOHealthCheckResourcesTest extends TestDataSetup { protected SDNOValidator MOCK_sdnoValidator; @Mock - protected InjectionHelper MOCK_injectionHelper; + protected TasksInjectionHelper MOCK_injectionHelper; @Before public void before() { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java new file mode 100644 index 0000000000..750e578558 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOHealthCheckClientTest.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.sdno; + +import static org.junit.Assert.assertEquals; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Optional; +import org.junit.Test; +import org.onap.so.client.sdno.beans.SDNO; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class SDNOHealthCheckClientTest { + + + + private final String fileLocation = "src/test/resources/org/onap/so/client/sdno/health-check/"; + private static final String userId = "test-user"; + private static final Optional clliCode = Optional.of("test-clli"); + private static final String requestId = "test-request-id"; + private static final String configurationId = "test-configuration-id"; + private static final String interfaceId = "test-interface-id"; + + @Test + public void verfyLPortMirrorPreCheckRequest() throws IOException { + String content = this.getJson("custom-lport-mirror-pre-check-request.json"); + ObjectMapper mapper = new ObjectMapper(); + SDNO expected = mapper.readValue(content, SDNO.class); + SDNOHealthCheckClient client = new SDNOHealthCheckClient(); + String actual = + client.buildLPortMirrorCheckPreRequest(userId, requestId, clliCode, configurationId, interfaceId); + assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); + } + + @Test + public void verfyLPortMirrorPostCheckRequest() throws IOException { + String content = this.getJson("custom-lport-mirror-post-check-request.json"); + ObjectMapper mapper = new ObjectMapper(); + SDNO expected = mapper.readValue(content, SDNO.class); + SDNOHealthCheckClient client = new SDNOHealthCheckClient(); + String actual = + client.buildLPortMirrorCheckPostRequest(userId, requestId, clliCode, configurationId, interfaceId); + assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); + } + + + @Test + public void verifyPortMirrorPostCheckRequest() throws IOException { + String content = this.getJson("custom-port-mirror-post-check-request.json"); + ObjectMapper mapper = new ObjectMapper(); + SDNO expected = mapper.readValue(content, SDNO.class); + SDNOHealthCheckClient client = new SDNOHealthCheckClient(); + String actual = client.buildPortMirrorPostCheckRequest(userId, requestId, clliCode, configurationId); + + assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); + + } + + @Test + public void verifyPortMirrorPreCheckRequest() throws IOException { + String content = this.getJson("custom-port-mirror-pre-check-request.json"); + ObjectMapper mapper = new ObjectMapper(); + SDNO expected = mapper.readValue(content, SDNO.class); + SDNOHealthCheckClient client = new SDNOHealthCheckClient(); + String actual = client.buildPortMirrorPreCheckRequest(userId, requestId, clliCode, configurationId); + + assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); + + } + + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java new file mode 100644 index 0000000000..b91f83c1b7 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorIT.java @@ -0,0 +1,124 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.sdno; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.UUID; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.BaseIntegrationTest; +import org.onap.so.client.dmaap.Consumer; +import org.onap.so.client.dmaap.exceptions.DMaaPConsumerFailure; +import org.onap.so.client.exceptions.SDNOException; +import org.onap.so.client.sdno.beans.SDNO; +import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; +import com.fasterxml.jackson.databind.ObjectMapper; + + + +public class SDNOValidatorIT extends BaseIntegrationTest { + + + @Mock + private Consumer mrConsumer; + private SDNOHealthCheckDmaapConsumer dmaapConsumer; + private final String fileLocation = "src/test/resources/org/onap/so/client/sdno/"; + private final String uuid = "xyz123"; + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Before + public void setUpTests() { + MockitoAnnotations.initMocks(this); + + } + + @Test + public void success() throws IOException, Exception { + dmaapConsumer = spy(new SDNOHealthCheckDmaapConsumer()); + when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer); + when(mrConsumer.fetch()) + .thenReturn(Arrays.asList(new String[] {getJson("response.json"), getJson("output-success.json")})); + + SDNOValidatorImpl validator = new SDNOValidatorImpl(); + SDNOValidatorImpl spy = spy(validator); + when(dmaapConsumer.getRequestId()).thenReturn("xyz123"); + doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class)); + boolean result = spy.pollForResponse("xyz123"); + assertEquals("result is true", result, true); + } + + @Test + public void failure() throws IOException, Exception { + dmaapConsumer = spy(new SDNOHealthCheckDmaapConsumer()); + + when(dmaapConsumer.getConsumer()).thenReturn(mrConsumer); + when(mrConsumer.fetch()) + .thenReturn(Arrays.asList(new String[] {getJson("response.json"), getJson("output-failure.json")})); + + SDNOValidatorImpl validator = new SDNOValidatorImpl(); + SDNOValidatorImpl spy = spy(validator); + when(dmaapConsumer.getRequestId()).thenReturn("xyz123"); + doReturn(dmaapConsumer).when(spy).getConsumer(any(String.class)); + thrown.expect(SDNOException.class); + thrown.expectMessage(containsString("my error message")); + boolean result = spy.pollForResponse("xyz123"); + + } + + @Ignore + @Test + public void run() throws Exception { + SDNOValidatorImpl validator = new SDNOValidatorImpl(); + UUID uuid = UUID.randomUUID(); + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("test"); + vnf.setIpv4OamAddress("1.2.3.4"); + vnf.setNfRole("VPE"); + SDNO request = validator.buildRequestDiagnostic(vnf, uuid, "mechid"); + ObjectMapper mapper = new ObjectMapper(); + String json = mapper.writeValueAsString(request); + validator.submitRequest(json); + thrown.expect(DMaaPConsumerFailure.class); + boolean result = validator.pollForResponse(uuid.toString()); + System.out.println(json); + + } + + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java new file mode 100644 index 0000000000..c2278c26f9 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdno/SDNOValidatorImplTest.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.sdno; + +import static org.junit.Assert.assertEquals; +import java.util.UUID; +import org.junit.Test; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.client.sdno.beans.RequestHealthDiagnostic; +import org.onap.so.client.sdno.beans.SDNO; + +public class SDNOValidatorImplTest { + + @Test + public void buildRequestDiagnosticTest() throws Exception { + SDNOValidatorImpl validator = new SDNOValidatorImpl(); + UUID uuid = UUID.randomUUID(); + GenericVnf vnf = new GenericVnf(); + vnf.setVnfName("VNFNAME"); + vnf.setVnfId("test"); + vnf.setIpv4OamAddress("1.2.3.4"); + vnf.setNfRole("VPE"); + SDNO request = validator.buildRequestDiagnostic(vnf, uuid, "mechid"); + assertEquals(request.getNodeType(), "VPE"); + assertEquals(request.getOperation(), "health-diagnostic"); + + RequestHealthDiagnostic innerRequest = request.getBody().getInput().getRequestHealthDiagnostic(); + assertEquals(innerRequest.getRequestClientName(), "MSO"); + assertEquals(innerRequest.getRequestNodeName(), "VNFNAME"); + assertEquals(innerRequest.getRequestNodeUuid(), "test"); + assertEquals(innerRequest.getRequestNodeType(), "VPE"); + assertEquals(innerRequest.getRequestNodeIp(), "1.2.3.4"); + assertEquals(innerRequest.getRequestUserId(), "mechid"); + assertEquals(innerRequest.getRequestId(), uuid.toString()); + assertEquals(innerRequest.getHealthDiagnosticCode(), "default"); + + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml index 199274e94c..b64fc3318b 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml +++ b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml @@ -205,7 +205,15 @@ spring: naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy enable-lazy-load-no-trans: true database-platform: org.hibernate.dialect.MySQL5InnoDBDialect - +sdno: + health-check: + dmaap: + password: password + publisher: + topic: sdno.test-health-diagnostic-v02 + subscriber: + topic: sdno.test-health-diagnostic-v02 + username: username mariaDB4j: dataDir: port: 3307 diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json new file mode 100644 index 0000000000..2c46b5a8cb --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-post-check-request.json @@ -0,0 +1,27 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000004", + "operation-type": "lport_mirroring_check", + "send-detailed-cmd-response": "false", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + }, + { + "key": "interface-id", + "value": "test-interface-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json new file mode 100644 index 0000000000..bf168b0028 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-lport-mirror-pre-check-request.json @@ -0,0 +1,27 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000003", + "operation-type": "lport_mirroring_check", + "send-detailed-cmd-response": "false", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + }, + { + "key": "interface-id", + "value": "test-interface-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json new file mode 100644 index 0000000000..89e505e7d0 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-post-check-request.json @@ -0,0 +1,23 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000004", + "operation-type": "mirroring_check", + "send-detailed-cmd-response": "false", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json new file mode 100644 index 0000000000..86897c8a1f --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/health-check/custom-port-mirror-pre-check-request.json @@ -0,0 +1,23 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000003", + "operation-type": "mirroring_check", + "send-detailed-cmd-response": "false", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-failure.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-failure.json new file mode 100644 index 0000000000..8cf0a820cd --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-failure.json @@ -0,0 +1,25 @@ +{ + "body": { + "output": { + "response-hd-custom": { + "response-status": "Failure", + "cached-data": "false", + "response-interface-type": "ansible", + "response-id": "191bf423-8473-4f7c-9fbb-e5dcbb40a12b", + "remote_end_time": "2017-10-13T14:51:53.490+0000", + "response-client-name": "MSO", + "user_id": "xxxxxx", + "remote_start_time": "2017-10-13T14:51:53.173+0000", + "error-message": "my error message", + "connection-failure-msg": "SDNO was unable to connect to an Ansible REST API server; Please ensure Ansible REST server is running" + } + } + }, + "result-info": { + "code": "200", + "status": "SUCCESS", + "request-id": "xyz123", + "client-name": "MSO", + "processing-host": "sdno-sdno-mtsnjv9sdno01" + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-success.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-success.json new file mode 100644 index 0000000000..a6794327d8 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/output-success.json @@ -0,0 +1,22 @@ +{ + "body": { + "output": { + "response-healthdiagnostic": { + "response-node-ip": "192.20.127.76", + "response-id": "xyz123", + "response-node-name": "mtvnjv9aads11", + "response-status": "Success", + "response-interface-type": "ssh", + "response-details-json": "result", + "cached-data": "false" + } + } + }, + "result-info": { + "client-name": "MSO", + "code": "200", + "processing-host": "sdno1-host01", + "request-id": "xyz123", + "status": "SUCCESS" + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/response.json b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/response.json new file mode 100644 index 0000000000..2355e86938 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/org/onap/so/client/sdno/response.json @@ -0,0 +1,17 @@ +{ + + "result-info": { + + "client-name": "MSO", + + "code": "202", + + "processing-host": "sdno1-host01", + + "request-id": "xyz123", + + "status": "ACCEPTED" + + } + +} \ No newline at end of file -- cgit 1.2.3-korg