summaryrefslogtreecommitdiffstats
path: root/policy-endpoints
diff options
context:
space:
mode:
authorJorge Hernandez <jorge.hernandez-herrero@att.com>2019-02-14 15:05:27 +0000
committerGerrit Code Review <gerrit@onap.org>2019-02-14 15:05:27 +0000
commite4db2076fa2c7ce1763bfb0d70bd360bf57f6c99 (patch)
treef0d1132730f9374cabdb52faa2836428d77c2ff1 /policy-endpoints
parentd299d6ecb966971fa0226d4da7415bb1de62fe8c (diff)
parentc064f5e9ea7e385ae8c730bb9e9fc5fdd45e25d6 (diff)
Merge "Add gson handler and tests"
Diffstat (limited to 'policy-endpoints')
-rw-r--r--policy-endpoints/pom.xml8
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java9
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java4
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java2
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java11
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java8
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.java8
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.java8
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.java8
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.java10
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.java8
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.java8
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java18
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java11
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java3
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json74
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.json12
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.json13
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.json13
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.json13
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.json16
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.json16
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.json16
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.json8
-rw-r--r--policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/http/server/internal/HttpServerTest.json7
26 files changed, 299 insertions, 17 deletions
diff --git a/policy-endpoints/pom.xml b/policy-endpoints/pom.xml
index 2c8b0d7f..c7bc8c4a 100644
--- a/policy-endpoints/pom.xml
+++ b/policy-endpoints/pom.xml
@@ -195,6 +195,13 @@
</dependency>
<dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>utils-test</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
@@ -209,7 +216,6 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
- <version>3.11.1</version>
<scope>test</scope>
</dependency>
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java
index 9912761f..ebed381d 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java
@@ -31,6 +31,7 @@ import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSink;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSource;
import org.onap.policy.common.endpoints.event.comm.bus.UebTopicSink;
import org.onap.policy.common.endpoints.event.comm.bus.UebTopicSource;
+import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -229,35 +230,42 @@ class TopicEndpointProxy implements TopicEndpoint {
}
@JsonIgnore
+ @GsonJsonIgnore
@Override
public List<UebTopicSource> getUebTopicSources() {
return UebTopicSource.factory.inventory();
}
@JsonIgnore
+ @GsonJsonIgnore
@Override
public List<DmaapTopicSource> getDmaapTopicSources() {
return DmaapTopicSource.factory.inventory();
}
+ @JsonIgnore
+ @GsonJsonIgnore
@Override
public List<NoopTopicSource> getNoopTopicSources() {
return NoopTopicSource.factory.inventory();
}
@JsonIgnore
+ @GsonJsonIgnore
@Override
public List<UebTopicSink> getUebTopicSinks() {
return UebTopicSink.factory.inventory();
}
@JsonIgnore
+ @GsonJsonIgnore
@Override
public List<DmaapTopicSink> getDmaapTopicSinks() {
return DmaapTopicSink.factory.inventory();
}
@JsonIgnore
+ @GsonJsonIgnore
@Override
public List<NoopTopicSink> getNoopTopicSinks() {
return NoopTopicSink.factory.inventory();
@@ -325,6 +333,7 @@ class TopicEndpointProxy implements TopicEndpoint {
* @return list of managed endpoints
*/
@JsonIgnore
+ @GsonJsonIgnore
protected List<Startable> getEndpoints() {
final List<Startable> endpoints = new ArrayList<>();
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java
index 9b2e6f5c..1c2d6eeb 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -41,6 +41,7 @@ import org.onap.dmaap.mr.client.response.MRPublisherResponse;
import org.onap.dmaap.mr.test.clients.ProtocolTypeConstants;
import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicSinkFactory;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
+import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -72,6 +73,7 @@ public interface BusPublisher {
* The actual Cambria publisher.
*/
@JsonIgnore
+ @GsonJsonIgnore
protected volatile CambriaBatchingPublisher publisher;
/**
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java
index 2287486e..01f9fbe3 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java
@@ -41,6 +41,7 @@ import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClient;
+import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -270,6 +271,7 @@ public class JerseyClient implements HttpClient {
}
@JsonIgnore
+ @GsonJsonIgnore
@Override
public String getPassword() {
return password;
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java
index 0c52aca8..76ad116f 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 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.
@@ -44,6 +44,7 @@ import org.eclipse.jetty.util.security.Credential;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.onap.aaf.cadi.filter.CadiFilter;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -486,6 +487,7 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
* @return the password
*/
@JsonIgnore
+ @GsonJsonIgnore
public String getPassword() {
return password;
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java
index 19dde432..a311c0b0 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java
@@ -33,6 +33,7 @@ import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicPropertyBuilder;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicPropertyBuilder;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
+import org.onap.policy.common.utils.gson.GsonTestUtils;
public class TopicEndpointProxyTest {
@@ -112,6 +113,16 @@ public class TopicEndpointProxyTest {
}
@Test
+ public void testSerialize() {
+ TopicEndpoint manager = new TopicEndpointProxy();
+
+ manager.addTopicSources(configuration);
+ manager.addTopicSinks(configuration);
+
+ new GsonTestUtils().compareGson(manager, TopicEndpointProxyTest.class);
+ }
+
+ @Test
public void addTopicSources() {
TopicEndpoint manager = new TopicEndpointProxy();
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java
index 56d3b47a..83a94bd5 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 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.
@@ -28,6 +28,7 @@ import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase;
+import org.onap.policy.common.utils.gson.GsonTestUtils;
public class BusTopicBaseTest extends TopicTestBase {
@@ -49,6 +50,11 @@ public class BusTopicBaseTest extends TopicTestBase {
}
@Test
+ public void testSerialize() {
+ new GsonTestUtils().compareGson(base, BusTopicBaseTest.class);
+ }
+
+ @Test
public void testGetApiKey() {
assertEquals(MY_API_KEY, base.getApiKey());
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.java
index 7330e6f7..cb6eb107 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 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.
@@ -37,6 +37,7 @@ import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase;
+import org.onap.policy.common.utils.gson.GsonTestUtils;
public class InlineBusTopicSinkTest extends TopicTestBase {
@@ -58,6 +59,11 @@ public class InlineBusTopicSinkTest extends TopicTestBase {
}
@Test
+ public void testSerialize() {
+ new GsonTestUtils().compareGson(sink, InlineBusTopicSinkTest.class);
+ }
+
+ @Test
public void testInlineBusTopicSinkImpl() {
// verify that different wrappers can be built
sink = new InlineBusTopicSinkImpl(makeBuilder().build());
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.java
index bf064100..aaab402c 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 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.
@@ -28,6 +28,7 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase;
+import org.onap.policy.common.utils.gson.GsonTestUtils;
public class InlineDmaapTopicSinkTest extends TopicTestBase {
private InlineDmaapTopicSink sink;
@@ -48,6 +49,11 @@ public class InlineDmaapTopicSinkTest extends TopicTestBase {
}
@Test
+ public void testSerialize() {
+ new GsonTestUtils().compareGson(sink, InlineDmaapTopicSinkTest.class);
+ }
+
+ @Test
public void testToString() {
assertTrue(sink.toString().startsWith("InlineDmaapTopicSink ["));
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.java
index 610070e3..2516406f 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 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.
@@ -28,6 +28,7 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase;
+import org.onap.policy.common.utils.gson.GsonTestUtils;
public class InlineUebTopicSinkTest extends TopicTestBase {
private InlineUebTopicSink sink;
@@ -48,6 +49,11 @@ public class InlineUebTopicSinkTest extends TopicTestBase {
}
@Test
+ public void testSerialize() {
+ new GsonTestUtils().compareGson(sink, InlineUebTopicSinkTest.class);
+ }
+
+ @Test
public void testToString() {
assertTrue(sink.toString().startsWith("InlineUebTopicSink ["));
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.java
index d0e8569b..f930fb6b 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 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.
@@ -43,6 +43,7 @@ import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusConsumer.FilterableBusConsumer;
+import org.onap.policy.common.utils.gson.GsonTestUtils;
public class SingleThreadedBusTopicSourceTest extends TopicTestBase {
private Thread thread;
@@ -69,6 +70,11 @@ public class SingleThreadedBusTopicSourceTest extends TopicTestBase {
}
@Test
+ public void testSerialize() {
+ new GsonTestUtils().compareGson(source, SingleThreadedBusTopicSourceTest.class);
+ }
+
+ @Test
public void testRegister() {
source.register(listener);
assertEquals(1, source.initCount);
@@ -146,7 +152,7 @@ public class SingleThreadedBusTopicSourceTest extends TopicTestBase {
// do nothing
}
};
-
+
assertNotNull(source2.makePollerThread());
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.java
index c7444034..29c34591 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 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.
@@ -29,6 +29,7 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase;
+import org.onap.policy.common.utils.gson.GsonTestUtils;
public class SingleThreadedDmaapTopicSourceTest extends TopicTestBase {
private SingleThreadedDmaapTopicSource source;
@@ -49,6 +50,11 @@ public class SingleThreadedDmaapTopicSourceTest extends TopicTestBase {
}
@Test
+ public void testSerialize() {
+ new GsonTestUtils().compareGson(source, SingleThreadedDmaapTopicSourceTest.class);
+ }
+
+ @Test
public void testToString() {
assertTrue(source.toString().startsWith("SingleThreadedDmaapTopicSource ["));
source.shutdown();
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.java
index b8cb0c13..99dc6fb7 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 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.
@@ -28,6 +28,7 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase;
+import org.onap.policy.common.utils.gson.GsonTestUtils;
public class SingleThreadedUebTopicSourceTest extends TopicTestBase {
private SingleThreadedUebTopicSource source;
@@ -48,6 +49,11 @@ public class SingleThreadedUebTopicSourceTest extends TopicTestBase {
}
@Test
+ public void testSerialize() {
+ new GsonTestUtils().compareGson(source, SingleThreadedUebTopicSourceTest.class);
+ }
+
+ @Test
public void testToString() {
assertTrue(source.toString().startsWith("SingleThreadedUebTopicSource ["));
source.shutdown();
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java
index 76883b3c..a8ea84fc 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine - Common Modules
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 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.
@@ -37,6 +37,7 @@ import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase;
+import org.onap.policy.common.utils.gson.GsonTestUtils;
public class TopicBaseTest extends TopicTestBase {
@@ -48,7 +49,7 @@ public class TopicBaseTest extends TopicTestBase {
@Before
public void setUp() {
super.setUp();
-
+
base = new TopicBaseImpl(servers, MY_TOPIC);
}
@@ -73,6 +74,11 @@ public class TopicBaseTest extends TopicTestBase {
}
@Test
+ public void testSerialize() {
+ new GsonTestUtils().compareGson(base, TopicBaseTest.class);
+ }
+
+ @Test
public void testRegister() {
TopicListener listener = mock(TopicListener.class);
base.register(listener);
@@ -246,7 +252,7 @@ public class TopicBaseTest extends TopicTestBase {
/**
* Constructor.
- *
+ *
* @param servers list of servers
* @param topic topic name
*/
@@ -285,7 +291,7 @@ public class TopicBaseTest extends TopicTestBase {
/**
* Adds an event to the list of recent events.
- *
+ *
* @param event event to be added
*/
public void addEvent(String event) {
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
index 3d80793e..972fc666 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
@@ -39,6 +39,7 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.utils.gson.GsonTestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -233,6 +234,16 @@ public class HttpServerTest {
}
@Test
+ public void testSerialize() {
+ HttpServletServer server = HttpServletServer.factory.build("echo", "localhost", port, "/", false, true);
+ server.addServletPackage("/*", this.getClass().getPackage().getName());
+ server.addFilterClass("/*", TestFilter.class.getCanonicalName());
+
+ // ensure we can serialize the server
+ new GsonTestUtils().compareGson(server, HttpServerTest.class);
+ }
+
+ @Test
public void testSingleServer() throws Exception {
logger.info("-- testSingleServer() --");
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java
index 5778eeeb..c211881f 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoReqResp.java
@@ -22,6 +22,7 @@ package org.onap.policy.common.endpoints.http.server.test;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
+import org.onap.policy.common.gson.annotation.GsonJsonProperty;
/**
* "ECHO" request and response supporting serialization and de-serialization via
@@ -29,10 +30,12 @@ import com.google.gson.annotations.SerializedName;
*/
public class RestEchoReqResp {
@JsonProperty("reqId")
+ @GsonJsonProperty("reqId")
@SerializedName("reqId")
private int requestId;
@JsonProperty("textValue")
+ @GsonJsonProperty("textValue")
@SerializedName("textValue")
private String text;
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json
new file mode 100644
index 00000000..11624af0
--- /dev/null
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json
@@ -0,0 +1,74 @@
+{
+ "locked" : false,
+ "alive" : false,
+ "topicSources" : [ {
+ "servers" : [ "my-server" ],
+ "topic" : "ueb-source",
+ "recentEvents" : [ ],
+ "alive" : false,
+ "locked" : false,
+ "apiKey" : null,
+ "apiSecret" : null,
+ "useHttps" : true,
+ "allowSelfSignedCerts" : true,
+ "consumerGroup" : "${obj.topicSources[0].consumerGroup}",
+ "consumerInstance" : "${obj.topicSources[0].consumerInstance}",
+ "fetchTimeout" : 15000,
+ "fetchLimit" : 100,
+ "topicCommInfrastructure" : "UEB"
+ }, {
+ "servers" : [ "my-server" ],
+ "topic" : "dmaap-source",
+ "recentEvents" : [ ],
+ "alive" : false,
+ "locked" : false,
+ "apiKey" : "my-api-key",
+ "apiSecret" : "my-api-secret",
+ "useHttps" : true,
+ "allowSelfSignedCerts" : true,
+ "consumerGroup" : "my-cons-group",
+ "consumerInstance" : "my-cons-inst",
+ "fetchTimeout" : 101,
+ "fetchLimit" : 100,
+ "topicCommInfrastructure" : "DMAAP"
+ }, {
+ "servers" : [ "my-server" ],
+ "topic" : "noop-source",
+ "recentEvents" : [ ],
+ "alive" : false,
+ "locked" : false,
+ "topicCommInfrastructure" : "NOOP"
+ } ],
+ "topicSinks" : [ {
+ "servers" : [ "my-server" ],
+ "topic" : "ueb-sink",
+ "recentEvents" : [ ],
+ "alive" : false,
+ "locked" : false,
+ "apiKey" : null,
+ "apiSecret" : null,
+ "useHttps" : true,
+ "allowSelfSignedCerts" : true,
+ "topicCommInfrastructure" : "UEB",
+ "partitionKey" : "${obj.topicSinks[0].partitionKey}"
+ }, {
+ "servers" : [ "my-server" ],
+ "topic" : "dmaap-sink",
+ "recentEvents" : [ ],
+ "alive" : false,
+ "locked" : false,
+ "apiKey" : "my-api-key",
+ "apiSecret" : "my-api-secret",
+ "useHttps" : true,
+ "allowSelfSignedCerts" : true,
+ "topicCommInfrastructure" : "DMAAP",
+ "partitionKey" : "my-partition"
+ }, {
+ "servers" : [ "my-server" ],
+ "topic" : "noop-sink",
+ "recentEvents" : [ ],
+ "alive" : false,
+ "locked" : false,
+ "topicCommInfrastructure" : "NOOP"
+ } ]
+}
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.json
new file mode 100644
index 00000000..49eafaf1
--- /dev/null
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.json
@@ -0,0 +1,12 @@
+{
+ "servers" : [ "svra", "svrb" ],
+ "topic" : "my-topic",
+ "recentEvents" : [ ],
+ "alive" : false,
+ "locked" : false,
+ "apiKey" : "my-api-key",
+ "apiSecret" : "my-api-secret",
+ "useHttps" : true,
+ "allowSelfSignedCerts" : true,
+ "topicCommInfrastructure" : "NOOP"
+}
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.json
new file mode 100644
index 00000000..98318751
--- /dev/null
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.json
@@ -0,0 +1,13 @@
+{
+ "servers" : [ "svra", "svrb" ],
+ "topic" : "my-topic",
+ "recentEvents" : [ ],
+ "alive" : false,
+ "locked" : false,
+ "apiKey" : "my-api-key",
+ "apiSecret" : "my-api-secret",
+ "useHttps" : true,
+ "allowSelfSignedCerts" : true,
+ "topicCommInfrastructure" : "NOOP",
+ "partitionKey" : "my-partition"
+}
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.json
new file mode 100644
index 00000000..a83f5c97
--- /dev/null
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSinkTest.json
@@ -0,0 +1,13 @@
+{
+ "servers" : [ "svra", "svrb" ],
+ "topic" : "my-topic",
+ "recentEvents" : [ ],
+ "alive" : false,
+ "locked" : false,
+ "apiKey" : "my-api-key",
+ "apiSecret" : "my-api-secret",
+ "useHttps" : true,
+ "allowSelfSignedCerts" : true,
+ "topicCommInfrastructure" : "DMAAP",
+ "partitionKey" : "my-partition"
+}
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.json
new file mode 100644
index 00000000..4ec0c80f
--- /dev/null
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSinkTest.json
@@ -0,0 +1,13 @@
+{
+ "servers" : [ "svra", "svrb" ],
+ "topic" : "my-topic",
+ "recentEvents" : [ ],
+ "alive" : false,
+ "locked" : false,
+ "apiKey" : "my-api-key",
+ "apiSecret" : "my-api-secret",
+ "useHttps" : true,
+ "allowSelfSignedCerts" : true,
+ "topicCommInfrastructure" : "UEB",
+ "partitionKey" : "my-partition"
+}
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.json
new file mode 100644
index 00000000..4f880257
--- /dev/null
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.json
@@ -0,0 +1,16 @@
+{
+ "servers" : [ "svra", "svrb" ],
+ "topic" : "my-topic",
+ "recentEvents" : [ ],
+ "alive" : false,
+ "locked" : false,
+ "apiKey" : "my-api-key",
+ "apiSecret" : "my-api-secret",
+ "useHttps" : true,
+ "allowSelfSignedCerts" : true,
+ "consumerGroup" : "my-cons-group",
+ "consumerInstance" : "my-cons-inst",
+ "fetchTimeout" : 101,
+ "fetchLimit" : 100,
+ "topicCommInfrastructure" : "NOOP"
+}
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.json
new file mode 100644
index 00000000..82e4b3ff
--- /dev/null
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.json
@@ -0,0 +1,16 @@
+{
+ "servers" : [ "svra", "svrb" ],
+ "topic" : "my-topic",
+ "recentEvents" : [ ],
+ "alive" : false,
+ "locked" : false,
+ "apiKey" : "my-api-key",
+ "apiSecret" : "my-api-secret",
+ "useHttps" : true,
+ "allowSelfSignedCerts" : true,
+ "consumerGroup" : "my-cons-group",
+ "consumerInstance" : "my-cons-inst",
+ "fetchTimeout" : 101,
+ "fetchLimit" : 100,
+ "topicCommInfrastructure" : "DMAAP"
+}
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.json
new file mode 100644
index 00000000..4eeacc6d
--- /dev/null
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.json
@@ -0,0 +1,16 @@
+{
+ "servers" : [ "svra", "svrb" ],
+ "topic" : "my-topic",
+ "recentEvents" : [ ],
+ "alive" : false,
+ "locked" : false,
+ "apiKey" : "my-api-key",
+ "apiSecret" : "my-api-secret",
+ "useHttps" : true,
+ "allowSelfSignedCerts" : true,
+ "consumerGroup" : "my-cons-group",
+ "consumerInstance" : "my-cons-inst",
+ "fetchTimeout" : 101,
+ "fetchLimit" : 100,
+ "topicCommInfrastructure" : "UEB"
+}
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.json
new file mode 100644
index 00000000..7431854d
--- /dev/null
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.json
@@ -0,0 +1,8 @@
+{
+ "servers" : [ "svra", "svrb" ],
+ "topic" : "my-topic",
+ "recentEvents" : [ ],
+ "alive" : false,
+ "locked" : false,
+ "topicCommInfrastructure" : "NOOP"
+}
diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/http/server/internal/HttpServerTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/http/server/internal/HttpServerTest.json
new file mode 100644
index 00000000..5f4a7a90
--- /dev/null
+++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/http/server/internal/HttpServerTest.json
@@ -0,0 +1,7 @@
+{
+ "aaf": false,
+ "alive": false,
+ "host": "localhost",
+ "name": "echo",
+ "port": ${obj.port}
+}