summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus G K Williams <marcus.williams@intel.com>2019-04-05 09:33:02 -0700
committerMarcus Williams <marcus.williams@intel.com>2019-04-05 19:05:46 +0000
commit0fee038584a0e66db618d24eada8ba6e0da05001 (patch)
tree1640cbe58463a19006c09df1708d84f56fcfc674
parent2a7d8aac072fc47beedd3eaebaefe88aaa7860ee (diff)
Fix Java OOF Client
Update IT tests to check correct post and update client to correct post behavior. Issue-ID: SO-1469 Change-Id: I8339cbff944587df5663d1fbff7f0cc41b7f2fe6 Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java9
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java135
10 files changed, 135 insertions, 59 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java
index 8e136e9f18..f5fb87503a 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java
@@ -24,7 +24,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-import org.apache.commons.lang.builder.ToStringBuilder;
import java.io.Serializable;
@@ -115,9 +114,4 @@ public class ModelInfo implements Serializable {
this.modelCustomizationName = modelCustomizationName;
}
- @Override
- public String toString() {
- return new ToStringBuilder(this).append("modelType", modelType).append("modelInvariantId", modelInvariantId).append("modelVersionId", modelVersionId).append("modelName", modelName).append("modelVersion", modelVersion).append("modelCustomizationName", modelCustomizationName).toString();
- }
-
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java
index 7dfd6849a6..58f0bfc9cc 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java
@@ -23,7 +23,6 @@ package org.onap.so.client.oof.beans;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRawValue;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import org.slf4j.Logger;
@@ -37,16 +36,16 @@ public class OofRequest implements Serializable{
private static final long serialVersionUID = -1541132882892163132L;
private static final Logger logger = LoggerFactory.getLogger(OofRequest.class);
- @JsonRawValue
+
@JsonProperty("requestInfo")
private RequestInfo requestInformation;
- @JsonRawValue
+
@JsonProperty("serviceInfo")
private ServiceInfo serviceInformation;
- @JsonRawValue
+
@JsonProperty("placementInfo")
private PlacementInfo placementInformation;
- @JsonRawValue
+
@JsonProperty("licenseInfo")
private String licenseInformation;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java
index 34b05e2f0f..621f5652a3 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java
@@ -24,7 +24,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-import org.apache.commons.lang.builder.ToStringBuilder;
import java.io.Serializable;
@@ -77,9 +76,4 @@ public class OofRequestParameters implements Serializable {
this.customerName = customerName;
}
- @Override
- public String toString() {
- return new ToStringBuilder(this).append("customerLatitude", customerLatitude).append("customerLongitude", customerLongitude).append("customerName", customerName).toString();
- }
-
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java
index a213723f76..38728efcfb 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java
@@ -24,7 +24,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-import org.apache.commons.lang.builder.ToStringBuilder;
import java.io.Serializable;
@@ -89,9 +88,4 @@ public class PlacementDemand implements Serializable {
this.resourceModelInfo = resourceModelInfo;
}
- @Override
- public String toString() {
- return new ToStringBuilder(this).append("resourceModuleName", resourceModuleName).append("serviceResourceId", serviceResourceId).append("tenantId", tenantId).append("resourceModelInfo", resourceModelInfo).toString();
- }
-
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java
index 5bda42fefe..2a7dc9decb 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java
@@ -26,7 +26,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-import org.apache.commons.lang.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
@@ -76,9 +75,4 @@ public class PlacementInfo implements Serializable {
this.placementDemands = placementDemands;
}
- @Override
- public String toString() {
- return new ToStringBuilder(this).append("requestParameters", requestParameters).append("subscriberInfo", subscriberInfo).append("placementDemands", placementDemands).toString();
- }
-
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java
index ea33a26672..6831fe54e9 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java
@@ -26,7 +26,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-import org.apache.commons.lang.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
@@ -141,9 +140,4 @@ public class RequestInfo implements Serializable {
this.timeout = timeout;
}
- @Override
- public String toString() {
- return new ToStringBuilder(this).append("transactionId", transactionId).append("requestId", requestId).append("callbackUrl", callbackUrl).append("sourceId", sourceId).append("requestType", requestType).append("numSolutions", numSolutions).append("optimizers", optimizers).append("timeout", timeout).toString();
- }
-
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java
index 63aec130ba..e9257bcb0c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java
@@ -22,9 +22,7 @@ package org.onap.so.client.oof.beans;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-import org.apache.commons.lang.builder.ToStringBuilder;
import java.io.Serializable;
@@ -107,9 +105,4 @@ public class ResourceModelInfo extends ModelInfo implements Serializable {
this.modelCustomizationName = modelCustomizationName;
}
- @Override
- public String toString() {
- return new ToStringBuilder(this).append("modelInvariantId", modelInvariantId).append("modelVersionId", modelVersionId).append("modelName", modelName).append("modelType", modelType).append("modelVersion", modelVersion).append("modelCustomizationName", modelCustomizationName).toString();
- }
-
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java
index 90443ce379..0cfffbbff6 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java
@@ -24,7 +24,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-import org.apache.commons.lang.builder.ToStringBuilder;
import java.io.Serializable;
@@ -76,9 +75,4 @@ public class ServiceInfo implements Serializable {
this.modelInfo = modelInfo;
}
- @Override
- public String toString() {
- return new ToStringBuilder(this).append("serviceInstanceId", serviceInstanceId).append("serviceName", serviceName).append("modelInfo", modelInfo).toString();
- }
-
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java
index bc283c803c..3218975095 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java
@@ -24,7 +24,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-import org.apache.commons.lang.builder.ToStringBuilder;
import java.io.Serializable;
@@ -75,10 +74,4 @@ public class SubscriberInfo implements Serializable {
public void setSubscriberCommonSiteId(String subscriberCommonSiteId) {
this.subscriberCommonSiteId = subscriberCommonSiteId;
}
-
- @Override
- public String toString() {
- return new ToStringBuilder(this).append("globalSubscriberId", globalSubscriberId).append("subscriberName", subscriberName).append("subscriberCommonSiteId", subscriberCommonSiteId).toString();
- }
-
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java
index 05ba512c9d..c4e50412a9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/oof/OofClientTestIT.java
@@ -23,35 +23,162 @@ package org.onap.so.client.oof;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.onap.so.BaseIntegrationTest;
import org.onap.so.client.exception.BadResponseException;
+import org.onap.so.client.oof.beans.ModelInfo;
import org.onap.so.client.oof.beans.OofRequest;
+import org.onap.so.client.oof.beans.OofRequestParameters;
+import org.onap.so.client.oof.beans.PlacementDemand;
+import org.onap.so.client.oof.beans.PlacementInfo;
+import org.onap.so.client.oof.beans.RequestInfo;
+import org.onap.so.client.oof.beans.ResourceModelInfo;
+import org.onap.so.client.oof.beans.ServiceInfo;
+import org.onap.so.client.oof.beans.SubscriberInfo;
import org.springframework.beans.factory.annotation.Autowired;
import com.fasterxml.jackson.core.JsonProcessingException;
+import java.util.ArrayList;
+import java.util.List;
+
public class OofClientTestIT extends BaseIntegrationTest {
@Autowired
private OofClient client;
-
- @Test(expected = Test.None.class)
+ @Test
public void testPostDemands_success() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationName("modelCustomizationName-Service");
+ modelInfo.setModelInvariantId("modelInvariantId-Service");
+ modelInfo.setModelName("modelName-Service");
+ modelInfo.setModelType("modelType-Service");
+ modelInfo.setModelVersion("modelVersion-Service");
+ modelInfo.setModelVersionId("modelVersionId-Service");
+
+ ServiceInfo serviceInfo = new ServiceInfo();
+ serviceInfo.setModelInfo(modelInfo);
+ serviceInfo.setServiceInstanceId("serviceInstanceId");
+ serviceInfo.setServiceName("serviceName");
+
+ SubscriberInfo subscriberInfo = new SubscriberInfo();
+ subscriberInfo.setGlobalSubscriberId("globalSubscriberId");
+ subscriberInfo.setSubscriberCommonSiteId("subscriberCommonSiteId");
+ subscriberInfo.setSubscriberName("subscriberName");
+
+ ResourceModelInfo resourceModelInfo = new ResourceModelInfo();
+ resourceModelInfo.setModelType("modelType");
+ resourceModelInfo.setModelCustomizationName("modelCustomizationName");
+ resourceModelInfo.setModelInvariantId("invarianteId");
+ resourceModelInfo.setModelName("modelName");
+ resourceModelInfo.setModelVersion("version");
+ resourceModelInfo.setModelVersionId("versionId");
+
+ PlacementDemand placementDemand = new PlacementDemand();
+ placementDemand.setResourceModelInfo(resourceModelInfo);
+ placementDemand.setResourceModuleName("resourceModuleName");
+ placementDemand.setServiceResourceId("serviceResourceId");
+ placementDemand.setTenantId("tenantId");
+
+ OofRequestParameters oofRequestParameters = new OofRequestParameters();
+ oofRequestParameters.setCustomerLatitude("customerLatitude");
+ oofRequestParameters.setCustomerLongitude("customerLongitude");
+ oofRequestParameters.setCustomerName("customerName");
+
+ ArrayList<PlacementDemand> placementDemands = new ArrayList<>();
+ placementDemands.add(placementDemand);
+
+ PlacementInfo placementInfo = new PlacementInfo();
+ placementInfo.setPlacementDemands(placementDemands);
+ placementInfo.setRequestParameters(oofRequestParameters);
+ placementInfo.setSubscriberInfo(subscriberInfo);
+
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setTransactionId("transactionId");
+ List<String> optimizer = new ArrayList<>();
+ optimizer.add("optimizer1");
+ optimizer.add("optimizer2");
+ requestInfo.setOptimizers(optimizer);
+ requestInfo.setCallbackUrl("callBackUrl");
+ requestInfo.setNumSolutions(1);
+ requestInfo.setRequestId("requestId");
+ requestInfo.setSourceId("sourceId");
+ requestInfo.setTimeout(30L);
+ requestInfo.setRequestType("requestType");
+
+ OofRequest oofRequest = new OofRequest();
+ oofRequest.setRequestInformation(requestInfo);
+ oofRequest.setPlacementInformation(placementInfo);
+ oofRequest.setServiceInformation(serviceInfo);
+ oofRequest.setLicenseInformation("");
+
wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
.willReturn(aResponse().withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(mockResponse)));
- client.postDemands(new OofRequest());
+ client.postDemands(oofRequest);
+
+ String oofRequestOutput = oofRequest.toJsonString();
+ assertEquals("{\n" +
+ " \"requestInfo\" : {\n" +
+ " \"transactionId\" : \"transactionId\",\n" +
+ " \"requestId\" : \"requestId\",\n" +
+ " \"callbackUrl\" : \"callBackUrl\",\n" +
+ " \"sourceId\" : \"sourceId\",\n" +
+ " \"requestType\" : \"requestType\",\n" +
+ " \"numSolutions\" : 1,\n" +
+ " \"optimizers\" : [ \"optimizer1\", \"optimizer2\" ],\n" +
+ " \"timeout\" : 30\n" +
+ " },\n" +
+ " \"serviceInfo\" : {\n" +
+ " \"serviceInstanceId\" : \"serviceInstanceId\",\n" +
+ " \"serviceName\" : \"serviceName\",\n" +
+ " \"modelInfo\" : {\n" +
+ " \"modelType\" : \"modelType-Service\",\n" +
+ " \"modelInvariantId\" : \"modelInvariantId-Service\",\n" +
+ " \"modelVersionId\" : \"modelVersionId-Service\",\n" +
+ " \"modelName\" : \"modelName-Service\",\n" +
+ " \"modelVersion\" : \"modelVersion-Service\",\n" +
+ " \"modelCustomizationName\" : \"modelCustomizationName-Service\"\n" +
+ " }\n" +
+ " },\n" +
+ " \"placementInfo\" : {\n" +
+ " \"requestParameters\" : {\n" +
+ " \"customerLatitude\" : \"customerLatitude\",\n" +
+ " \"customerLongitude\" : \"customerLongitude\",\n" +
+ " \"customerName\" : \"customerName\"\n" +
+ " },\n" +
+ " \"subscriberInfo\" : {\n" +
+ " \"globalSubscriberId\" : \"globalSubscriberId\",\n" +
+ " \"subscriberName\" : \"subscriberName\",\n" +
+ " \"subscriberCommonSiteId\" : \"subscriberCommonSiteId\"\n" +
+ " },\n" +
+ " \"placementDemands\" : [ {\n" +
+ " \"resourceModuleName\" : \"resourceModuleName\",\n" +
+ " \"serviceResourceId\" : \"serviceResourceId\",\n" +
+ " \"tenantId\" : \"tenantId\",\n" +
+ " \"resourceModelInfo\" : {\n" +
+ " \"modelType\" : \"modelType\",\n" +
+ " \"modelInvariantId\" : \"invarianteId\",\n" +
+ " \"modelVersionId\" : \"versionId\",\n" +
+ " \"modelName\" : \"modelName\",\n" +
+ " \"modelVersion\" : \"version\",\n" +
+ " \"modelCustomizationName\" : \"modelCustomizationName\"\n" +
+ " }\n" +
+ " } ]\n" +
+ " },\n" +
+ " \"licenseInfo\" : \"\"\n" +
+ "}", oofRequestOutput);
}
- @Test(expected = Test.None.class)
+ @Test
public void testAsyncResponse_success() throws BadResponseException, JsonProcessingException {
String mockResponse = "{\"transactionId\": \"123456789\", \"requestId\": \"1234\", \"statusMessage\": \"status\", \"requestStatus\": \"accepted\"}";