summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src
diff options
context:
space:
mode:
authorgrabinsk <maciej.grabinski@nokia.com>2019-04-05 10:13:48 +0200
committergrabinsk <maciej.grabinski@nokia.com>2019-05-22 15:36:41 +0200
commit41216decc9e167ee85aff6391f67dcf4b94f489c (patch)
tree4aceeba43aef18bb58121b20acf6dad34bc814cd /prh-app-server/src
parent2cf649dda43c7fc7650b5d0047ccc57108918724 (diff)
replace generated model classes with immutables
Change-Id: I5a1330e356522d2e315f7e243a2e65b90e4f6ddd Issue-ID: DCAEGEN2-1391 Signed-off-by: grabinsk <maciej.grabinski@nokia.com>
Diffstat (limited to 'prh-app-server/src')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java8
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java4
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiQueryTaskImplTest.java24
3 files changed, 23 insertions, 13 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java
index 0d20c39c..c4566888 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java
@@ -23,6 +23,7 @@ package org.onap.dcaegen2.services.prh.configuration;
import org.onap.dcaegen2.services.prh.model.AaiJsonBodyBuilderImpl;
import org.onap.dcaegen2.services.prh.model.AaiPnfResultModel;
import org.onap.dcaegen2.services.prh.model.AaiServiceInstanceResultModel;
+import org.onap.dcaegen2.services.prh.model.utils.PrhModelAwareGsonBuilder;
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.AaiClientConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.AaiHttpClientFactory;
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.http.AaiHttpClient;
@@ -37,6 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import java.nio.charset.StandardCharsets;
import java.util.function.BiFunction;
@Configuration
@@ -54,14 +56,16 @@ public class AaiHttpClientConfig {
public AaiHttpClient<AaiServiceInstanceQueryModel, AaiServiceInstanceResultModel> getServiceInstanceClient() {
return createLazyConfigClient(
(config, client) -> new AaiGetServiceInstanceClient(config, client)
- .map(x -> x.bodyAsJson(AaiServiceInstanceResultModel.class)));
+ .map(httpResponse -> httpResponse.bodyAsJson(StandardCharsets.UTF_8,
+ PrhModelAwareGsonBuilder.createGson(), AaiServiceInstanceResultModel.class)));
}
@Bean
public AaiHttpClient<AaiModel, AaiPnfResultModel> getGetClient() {
return createLazyConfigClient(
(config, client) -> new AaiHttpGetClient(config, client)
- .map(x -> x.bodyAsJson(AaiPnfResultModel.class)));
+ .map(httpResponse -> httpResponse.bodyAsJson(StandardCharsets.UTF_8,
+ PrhModelAwareGsonBuilder.createGson(), AaiPnfResultModel.class)));
}
private <T, U> AaiHttpClient<T, U> createLazyConfigClient(
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java
index 0b26890d..a0d844b1 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java
@@ -30,8 +30,8 @@ import org.onap.dcaegen2.services.prh.model.bbs.ImmutableLogicalLink;
import org.onap.dcaegen2.services.prh.model.bbs.ImmutableRelationship;
import org.onap.dcaegen2.services.prh.model.bbs.ImmutableRelationshipWrapper;
import org.onap.dcaegen2.services.prh.model.bbs.RelationshipWrapper;
-import org.onap.dcaegen2.services.prh.model.utils.GsonSerializer;
import org.onap.dcaegen2.services.prh.model.utils.HttpUtils;
+import org.onap.dcaegen2.services.prh.model.utils.PrhModelAwareGsonBuilder;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.*;
import org.onap.dcaegen2.services.sdk.rest.services.uri.URI.URIBuilder;
import org.slf4j.Logger;
@@ -98,7 +98,7 @@ public class BbsActionsTaskImpl implements BbsActionsTask {
private ImmutableHttpRequest buildLogicalLinkRequest(String linkName, String pnfName) {
String uri = buildLogicalLinkUri(linkName);
ImmutableLogicalLink logicalLink = buildModel(linkName, pnfName);
- RequestBody requestBody = RequestBody.fromString(GsonSerializer.createJsonBody(logicalLink));
+ RequestBody requestBody = RequestBody.fromString(PrhModelAwareGsonBuilder.createGson().toJson(logicalLink));
// FIXME: AAI headers for PUT are different than PATCH (taken from prh_endpoints.json)
Map<String, String> aaiHeaders = HashMap
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiQueryTaskImplTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiQueryTaskImplTest.java
index 4b6d7a61..26a6060f 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiQueryTaskImplTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/AaiQueryTaskImplTest.java
@@ -38,6 +38,7 @@ import java.util.List;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
public class AaiQueryTaskImplTest {
@@ -59,9 +60,14 @@ public class AaiQueryTaskImplTest {
@Mock
private AaiServiceInstanceResultModel serviceModel;
- private final RelationshipData customer = new RelationshipData();
- private final RelationshipData serviceType = new RelationshipData();
- private final RelationshipData serviceInstanceId = new RelationshipData();
+ @Mock
+ private RelationshipData customer;
+
+ @Mock
+ private RelationshipData serviceType;
+
+ @Mock
+ private RelationshipData serviceInstanceId;
private List<RelationshipData> allRelationData;
@@ -71,14 +77,14 @@ public class AaiQueryTaskImplTest {
@BeforeEach
void setUp() {
- customer.setRelationshipKey(AaiQueryTaskImpl.CUSTOMER);
- customer.setRelationshipValue("Foo");
+ when(customer.getRelationshipKey()).thenReturn(AaiQueryTaskImpl.CUSTOMER);
+ when(customer.getRelationshipValue()).thenReturn("Foo");
- serviceType.setRelationshipKey(AaiQueryTaskImpl.SERVICE_TYPE);
- serviceType.setRelationshipValue("Bar");
+ when(serviceType.getRelationshipKey()).thenReturn(AaiQueryTaskImpl.SERVICE_TYPE);
+ when(serviceType.getRelationshipValue()).thenReturn("Bar");
- serviceInstanceId.setRelationshipKey(AaiQueryTaskImpl.SERVICE_INSTANCE_ID);
- serviceInstanceId.setRelationshipValue("Baz");
+ when(serviceInstanceId.getRelationshipKey()).thenReturn(AaiQueryTaskImpl.SERVICE_INSTANCE_ID);
+ when(serviceInstanceId.getRelationshipValue()).thenReturn("Baz");
allRelationData = Lists.list(customer, serviceType, serviceInstanceId);