aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2019-08-12 15:32:49 +0000
committerWaqas Ikram <waqas.ikram@est.tech>2019-08-12 15:33:12 +0000
commit557e61e2aac64d97ad185748592e638283e87950 (patch)
treee0e8c6f771739c72ac027a48177d810217f6479a
parent022419083f175e50112e60effc8e490f02cfd57d (diff)
Fixing minor bugs
Change-Id: Ic6a555135fdefd03cd720ab4eb87cc8fff20029e Issue-ID: SO-1953 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/NodesController.java12
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/OwningEntityController.java7
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ProjectController.java7
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/models/Results.java (renamed from plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/models/Result.java)13
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java8
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java8
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java8
7 files changed, 30 insertions, 33 deletions
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/NodesController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/NodesController.java
index 4e660c90..9e93cc3b 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/NodesController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/NodesController.java
@@ -23,7 +23,7 @@ import static org.onap.so.aaisimulator.utils.Constants.NODES_URL;
import static org.onap.so.aaisimulator.utils.Constants.RESOURCE_LINK;
import static org.onap.so.aaisimulator.utils.Constants.RESOURCE_TYPE;
import static org.onap.so.aaisimulator.utils.Utils.getRequestErrorResponseEntity;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
@@ -31,7 +31,7 @@ import javax.ws.rs.core.MediaType;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.so.aaisimulator.models.Format;
import org.onap.so.aaisimulator.models.NodeServiceInstance;
-import org.onap.so.aaisimulator.models.Result;
+import org.onap.so.aaisimulator.models.Results;
import org.onap.so.aaisimulator.service.providers.CustomerCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.NodesCacheServiceProvider;
import org.slf4j.Logger;
@@ -67,7 +67,6 @@ public class NodesController {
}
@GetMapping(value = "/service-instances/service-instance/{service-instance-id}",
- consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> getProject(@PathVariable(name = "service-instance-id") final String serviceInstanceId,
@RequestParam(name = "format", required = false) final String format, final HttpServletRequest request) {
@@ -85,10 +84,10 @@ public class NodesController {
switch (value) {
case PATHED:
LOGGER.info("found project {} in cache", nodeServiceInstance);
- final Map<String, Object> map = new HashMap<>();
+ final Map<String, Object> map = new LinkedHashMap<>();
map.put(RESOURCE_TYPE, nodeServiceInstance.getResourceType());
map.put(RESOURCE_LINK, nodeServiceInstance.getResourceLink());
- return ResponseEntity.ok(new Result(map));
+ return ResponseEntity.ok(new Results(map));
case RAW:
final Optional<ServiceInstance> serviceInstance =
customerCacheServiceProvider.getServiceInstance(nodeServiceInstance.getGlobalCustomerId(),
@@ -103,8 +102,5 @@ public class NodesController {
}
LOGGER.error("invalid format type :{}", format);
return getRequestErrorResponseEntity(request);
-
-
}
-
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/OwningEntityController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/OwningEntityController.java
index cd7c4001..ec6412c2 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/OwningEntityController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/OwningEntityController.java
@@ -31,7 +31,7 @@ import javax.ws.rs.core.MediaType;
import org.onap.aai.domain.yang.OwningEntity;
import org.onap.aai.domain.yang.Relationship;
import org.onap.so.aaisimulator.models.Format;
-import org.onap.so.aaisimulator.models.Result;
+import org.onap.so.aaisimulator.models.Results;
import org.onap.so.aaisimulator.service.providers.OwnEntityCacheServiceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -78,8 +78,7 @@ public class OwningEntityController {
return ResponseEntity.accepted().build();
}
- @GetMapping(value = "{owning-entity-id}", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
- produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @GetMapping(value = "{owning-entity-id}", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> getOwningEntity(@PathVariable("owning-entity-id") final String owningEntityId,
@RequestParam(name = "resultIndex", required = false) final Integer resultIndex,
@RequestParam(name = "resultSize", required = false) final Integer resultSize,
@@ -101,7 +100,7 @@ public class OwningEntityController {
case COUNT:
final Map<String, Object> map = new HashMap<>();
map.put(OWNING_ENTITY, 1);
- return ResponseEntity.ok(new Result(map));
+ return ResponseEntity.ok(new Results(map));
default:
break;
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ProjectController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ProjectController.java
index bf1770ef..8a7c1b8a 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ProjectController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/ProjectController.java
@@ -31,7 +31,7 @@ import javax.ws.rs.core.MediaType;
import org.onap.aai.domain.yang.Project;
import org.onap.aai.domain.yang.Relationship;
import org.onap.so.aaisimulator.models.Format;
-import org.onap.so.aaisimulator.models.Result;
+import org.onap.so.aaisimulator.models.Results;
import org.onap.so.aaisimulator.service.providers.ProjectCacheServiceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -76,8 +76,7 @@ public class ProjectController {
}
- @GetMapping(value = "/{project-name}", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
- produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @GetMapping(value = "/{project-name}", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> getProject(@PathVariable("project-name") final String projectName,
@RequestParam(name = "resultIndex", required = false) final Integer resultIndex,
@RequestParam(name = "resultSize", required = false) final Integer resultSize,
@@ -99,7 +98,7 @@ public class ProjectController {
case COUNT:
final Map<String, Object> map = new HashMap<>();
map.put(PROJECT, 1);
- return ResponseEntity.ok(new Result(map));
+ return ResponseEntity.ok(new Results(map));
default:
break;
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/models/Result.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/models/Results.java
index 437aaf06..8dc20242 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/models/Result.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/models/Results.java
@@ -19,24 +19,27 @@
*/
package org.onap.so.aaisimulator.models;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonRootName;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author waqas.ikram@ericsson.com
*
*/
-@JsonRootName(value = "result")
-public class Result {
+public class Results implements Serializable {
+ private static final long serialVersionUID = 3967660859271162759L;
+
+ @JsonProperty("results")
private List<Map<String, Object>> values = new ArrayList<>();
- public Result() {}
+ public Results() {}
- public Result(final Map<String, Object> value) {
+ public Results(final Map<String, Object> value) {
this.values.add(value);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java
index 50ab04c6..e67d0987 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java
@@ -39,7 +39,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.so.aaisimulator.models.Format;
-import org.onap.so.aaisimulator.models.Result;
+import org.onap.so.aaisimulator.models.Results;
import org.onap.so.aaisimulator.service.providers.CustomerCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.NodesCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
@@ -130,14 +130,14 @@ public class NodesControllerTest {
final ResponseEntity<Void> response2 = invokeHttpPut(url, getServiceInstance());
assertEquals(HttpStatus.ACCEPTED, response2.getStatusCode());
- final ResponseEntity<Result> actual = restTemplate.exchange(
+ final ResponseEntity<Results> actual = restTemplate.exchange(
getNodesEndPointUrl() + SERVICE_INSTANCE_URL + "?format=" + Format.PATHED.getValue(), HttpMethod.GET,
- new HttpEntity<>(getHttpHeaders()), Result.class);
+ new HttpEntity<>(getHttpHeaders()), Results.class);
assertEquals(HttpStatus.OK, actual.getStatusCode());
assertTrue(actual.hasBody());
- final Result result = actual.getBody();
+ final Results result = actual.getBody();
assertNotNull(result.getValues());
assertFalse(result.getValues().isEmpty());
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java
index 7f825db8..7aabc665 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java
@@ -34,7 +34,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.domain.yang.OwningEntity;
import org.onap.so.aaisimulator.models.Format;
-import org.onap.so.aaisimulator.models.Result;
+import org.onap.so.aaisimulator.models.Results;
import org.onap.so.aaisimulator.service.providers.OwnEntityCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
import org.onap.so.aaisimulator.utils.TestUtils;
@@ -112,12 +112,12 @@ public class OwningEntityControllerTest {
assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
- final ResponseEntity<Result> actualResponse =
- invokeHttpGet(url + "?resultIndex=0&resultSize=1&format=" + Format.COUNT.getValue(), Result.class);
+ final ResponseEntity<Results> actualResponse =
+ invokeHttpGet(url + "?resultIndex=0&resultSize=1&format=" + Format.COUNT.getValue(), Results.class);
assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
assertTrue(actualResponse.hasBody());
- final Result result = actualResponse.getBody();
+ final Results result = actualResponse.getBody();
assertNotNull(result.getValues());
assertFalse(result.getValues().isEmpty());
assertEquals(1, result.getValues().get(0).get(Constants.OWNING_ENTITY));
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java
index e7b067db..d4f686db 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java
@@ -32,7 +32,7 @@ import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.domain.yang.Project;
-import org.onap.so.aaisimulator.models.Result;
+import org.onap.so.aaisimulator.models.Results;
import org.onap.so.aaisimulator.service.providers.ProjectCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
import org.onap.so.aaisimulator.utils.TestUtils;
@@ -135,12 +135,12 @@ public class ProjectControllerTest {
assertEquals(HttpStatus.ACCEPTED, actual.getStatusCode());
- final ResponseEntity<Result> actualResponse =
- invokeHttpGet(url + "?resultIndex=0&resultSize=1&format=count", Result.class);
+ final ResponseEntity<Results> actualResponse =
+ invokeHttpGet(url + "?resultIndex=0&resultSize=1&format=count", Results.class);
assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
assertTrue(actualResponse.hasBody());
- final Result result = actualResponse.getBody();
+ final Results result = actualResponse.getBody();
assertNotNull(result.getValues());
assertFalse(result.getValues().isEmpty());
assertEquals(1, result.getValues().get(0).get(Constants.PROJECT));