summaryrefslogtreecommitdiffstats
path: root/common/src/main/java/org/onap
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-08-24 09:02:47 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-08-24 09:03:14 -0400
commitcb067ee35bfba82cb686cdfce8207fe3060380c8 (patch)
tree8f02572bb85460780f82c4c0a2ab943642de107d /common/src/main/java/org/onap
parent969cde43a1c52fc5a0131cd94713a3c4ba3d1564 (diff)
aairesultwrapper is now actually serializable
added in a proper serialization and deserialization test addressed any comments from pull added in a serialization test for AAIResultWrapper and updated one of the null returns change jsonBody in AAIResultWrapper back to String Change-Id: Iffa5661f129cc26d69dfaa966cd265c67903cf21 Issue-ID: SO-899 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'common/src/main/java/org/onap')
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java b/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java
index 9087995f97..36e67e2e09 100644
--- a/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java
+++ b/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java
@@ -35,19 +35,19 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class AAIResultWrapper implements Serializable {
private static final long serialVersionUID = 5895841925807816737L;
- private final Optional<String> jsonBody;
+ private final String jsonBody;
private final ObjectMapper mapper;
public AAIResultWrapper(String json) {
- this.jsonBody = Optional.ofNullable(json);
+ this.jsonBody = json;
this.mapper = new AAICommonObjectMapperProvider().getMapper();
}
public Optional<Relationships> getRelationships() {
final String path = "$.relationship-list";
- if (!jsonBody.isPresent()) {
+ if (isEmpty()) {
return Optional.empty();
}
- Optional<String> result = JsonPathUtil.getInstance().locateResult(jsonBody.get(), path);
+ Optional<String> result = JsonPathUtil.getInstance().locateResult(jsonBody, path);
if (result.isPresent()) {
return Optional.of(new Relationships(result.get()));
} else {
@@ -56,33 +56,37 @@ public class AAIResultWrapper implements Serializable {
}
public String getJson() {
- return jsonBody.orElse("{}");
+ if(jsonBody == null) {
+ return "{}";
+ } else {
+ return jsonBody;
+ }
}
public Map<String, Object> asMap() {
- if (!this.jsonBody.isPresent()) {
+ if (isEmpty()) {
return new HashMap<>();
}
try {
- return mapper.readValue(this.jsonBody.get(), new TypeReference<Map<String, Object>>(){});
+ return mapper.readValue(this.jsonBody, new TypeReference<Map<String, Object>>(){});
} catch (IOException e) {
return new HashMap<>();
}
}
public <T> Optional<T> asBean(Class<T> clazz) {
- if (!this.jsonBody.isPresent()) {
+ if (isEmpty()) {
return Optional.empty();
}
try {
- return Optional.of(mapper.readValue(this.jsonBody.get(), clazz));
+ return Optional.of(mapper.readValue(this.jsonBody, clazz));
} catch (IOException e) {
return Optional.empty();
}
}
public boolean isEmpty() {
- return !this.jsonBody.isPresent();
+ return jsonBody == null;
}
@Override
public String toString() {