summaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src
diff options
context:
space:
mode:
Diffstat (limited to 'policy-endpoints/src')
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java41
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpoint.java15
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java17
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java2
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java4
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java23
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisherTest.java9
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java5
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.java4
-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.java9
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSourceTest.java9
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSourceTest.java6
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java3
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java5
16 files changed, 95 insertions, 73 deletions
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 9aabad52..6f3094ff 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 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.
@@ -449,21 +449,21 @@ class TopicEndpointProxy implements TopicEndpoint {
@Override
public boolean lock() {
+ boolean shouldLock;
synchronized (this) {
- if (this.locked) {
- return true;
- }
-
+ shouldLock = !this.locked;
this.locked = true;
}
- for (final TopicSource source : this.getTopicSources()) {
- source.lock();
- }
+ if (shouldLock) {
+ for (final TopicSource source : this.getTopicSources()) {
+ source.lock();
+ }
- for (final TopicSink sink : this.getTopicSinks()) {
- sink.lock();
+ for (final TopicSink sink : this.getTopicSinks()) {
+ sink.lock();
+ }
}
return true;
@@ -471,20 +471,21 @@ class TopicEndpointProxy implements TopicEndpoint {
@Override
public boolean unlock() {
- synchronized (this) {
- if (!this.locked) {
- return true;
- }
+ boolean shouldUnlock;
+ synchronized (this) {
+ shouldUnlock = this.locked;
this.locked = false;
}
- for (final TopicSource source : this.getTopicSources()) {
- source.unlock();
- }
+ if (shouldUnlock) {
+ for (final TopicSource source : this.getTopicSources()) {
+ source.unlock();
+ }
- for (final TopicSink sink : this.getTopicSinks()) {
- sink.unlock();
+ for (final TopicSink sink : this.getTopicSinks()) {
+ sink.unlock();
+ }
}
return true;
@@ -579,4 +580,4 @@ class TopicEndpointProxy implements TopicEndpoint {
logger.debug("No sink for topic: {}", topicName, ex);
}
-} \ No newline at end of file
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpoint.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpoint.java
index 73c61651..833574a3 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpoint.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpoint.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -94,16 +94,13 @@ public abstract class NoopTopicEndpoint extends TopicBase {
logger.info("{}: starting", this);
synchronized (this) {
+ if (!this.alive) {
+ if (locked) {
+ throw new IllegalStateException(this + " is locked.");
+ }
- if (this.alive) {
- return true;
+ this.alive = true;
}
-
- if (locked) {
- throw new IllegalStateException(this + " is locked.");
- }
-
- this.alive = true;
}
return true;
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java
index e94bdffa..16669904 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2018-2019 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -84,17 +84,14 @@ public abstract class InlineBusTopicSink extends BusTopicBase implements BusTopi
logger.info("{}: starting", this);
synchronized (this) {
+ if (!this.alive) {
+ if (locked) {
+ throw new IllegalStateException(this + " is locked.");
+ }
- if (this.alive) {
- return true;
- }
-
- if (locked) {
- throw new IllegalStateException(this + " is locked.");
+ this.init();
+ this.alive = true;
}
-
- this.init();
- this.alive = true;
}
return true;
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java
index 510ddaaa..d0d25a26 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java
@@ -225,7 +225,7 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase
try {
fetchAllMessages();
} catch (IOException | RuntimeException e) {
- logger.error("{}: cannot fetch because of ", this, e.getMessage(), e);
+ logger.error("{}: cannot fetch", this, e);
}
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java
index 72747350..6776a328 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -125,7 +125,7 @@ public class RestServer extends ServiceManagerContainer {
}
private String getValue(final String value) {
- if (value != null && value.matches("[$][{].*[}]$")) {
+ if (value != null && value.startsWith("${") && value.endsWith("}")) {
return System.getenv(value.substring(2, value.length() - 1));
}
return value;
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java
index 0255c100..5264b2f4 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-endpoints
* ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 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.
@@ -20,6 +20,7 @@
package org.onap.policy.common.endpoints.event.comm.bus.internal;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -65,7 +66,9 @@ public class BusConsumerTest extends TopicTestBase {
new CambriaConsumerWrapper(makeBuilder().apiKey(null).apiSecret(null).build());
new CambriaConsumerWrapper(makeBuilder().userName(null).build());
new CambriaConsumerWrapper(makeBuilder().password(null).build());
- new CambriaConsumerWrapper(makeBuilder().userName(null).password(null).build());
+
+ assertThatCode(() -> new CambriaConsumerWrapper(makeBuilder().userName(null).password(null).build()))
+ .doesNotThrowAnyException();
}
@Test
@@ -101,7 +104,8 @@ public class BusConsumerTest extends TopicTestBase {
// set filter several times to cause different branches of close() to be executed
for (int count = 0; count < 3; ++count) {
cons.close();
- cons.setFilter("close=" + count);
+ final int count2 = count;
+ assertThatCode(() -> cons.setFilter("close=" + count2)).doesNotThrowAnyException();
}
}
@@ -110,7 +114,8 @@ public class BusConsumerTest extends TopicTestBase {
// set filter several times to cause different branches to be executed
CambriaConsumerWrapper cons = new CambriaConsumerWrapper(builder.build());
for (int count = 0; count < 3; ++count) {
- cons.setFilter("set-filter=" + count);
+ final int count2 = count;
+ assertThatCode(() -> cons.setFilter("set-filter=" + count2)).doesNotThrowAnyException();
}
}
@@ -122,7 +127,7 @@ public class BusConsumerTest extends TopicTestBase {
@Test
public void testDmaapConsumerWrapper() throws Exception {
// verify that different wrappers can be built
- new DmaapAafConsumerWrapper(makeBuilder().build());
+ assertThatCode(() -> new DmaapAafConsumerWrapper(makeBuilder().build())).doesNotThrowAnyException();
}
@Test(expected = IllegalArgumentException.class)
@@ -167,7 +172,7 @@ public class BusConsumerTest extends TopicTestBase {
@Test
public void testDmaapConsumerWrapperClose() throws Exception {
- new DmaapAafConsumerWrapper(makeBuilder().build()).close();
+ assertThatCode(() -> new DmaapAafConsumerWrapper(makeBuilder().build()).close()).doesNotThrowAnyException();
}
@Test
@@ -179,7 +184,8 @@ public class BusConsumerTest extends TopicTestBase {
public void testDmaapAafConsumerWrapper() throws Exception {
// verify that different wrappers can be built
new DmaapAafConsumerWrapper(makeBuilder().useHttps(true).build());
- new DmaapAafConsumerWrapper(makeBuilder().useHttps(false).build());
+ assertThatCode(() -> new DmaapAafConsumerWrapper(makeBuilder().useHttps(false).build()))
+ .doesNotThrowAnyException();
}
@Test(expected = IllegalArgumentException.class)
@@ -207,7 +213,8 @@ public class BusConsumerTest extends TopicTestBase {
addProps.put(ROUTE_PROP, MY_ROUTE);
new DmaapDmeConsumerWrapper(makeBuilder().build());
- new DmaapDmeConsumerWrapper(makeBuilder().partner(null).build());
+ assertThatCode(() -> new DmaapDmeConsumerWrapper(makeBuilder().partner(null).build()))
+ .doesNotThrowAnyException();
}
@Test(expected = IllegalArgumentException.class)
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisherTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisherTest.java
index 5a933e9b..513673bd 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisherTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisherTest.java
@@ -20,6 +20,7 @@
package org.onap.policy.common.endpoints.event.comm.bus.internal;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
@@ -66,7 +67,8 @@ public class BusPublisherTest extends TopicTestBase {
new CambriaPublisherWrapper(makeBuilder().apiKey(null).apiSecret(null).build());
new CambriaPublisherWrapper(makeBuilder().userName(null).build());
new CambriaPublisherWrapper(makeBuilder().password(null).build());
- new CambriaPublisherWrapper(makeBuilder().userName(null).password(null).build());
+ assertThatCode(() -> new CambriaPublisherWrapper(makeBuilder().userName(null).password(null).build()))
+ .doesNotThrowAnyException();
}
@Test
@@ -109,7 +111,8 @@ public class BusPublisherTest extends TopicTestBase {
// verify with different constructor arguments
new DmaapAafPublisherWrapper(servers, MY_TOPIC, MY_USERNAME, MY_PASS, true);
new DmaapAafPublisherWrapper(servers, MY_TOPIC, MY_USERNAME, MY_PASS, false);
- new DmaapPublisherWrapper(ProtocolTypeConstants.DME2, servers, MY_TOPIC, MY_USERNAME, MY_PASS, true) {};
+ assertThatCode(() -> new DmaapPublisherWrapper(ProtocolTypeConstants.DME2, servers, MY_TOPIC, MY_USERNAME,
+ MY_PASS, true) {}).doesNotThrowAnyException();
}
@Test(expected = IllegalArgumentException.class)
@@ -188,7 +191,7 @@ public class BusPublisherTest extends TopicTestBase {
new DmaapDmePublisherWrapper(makeBuilder().partner(null).build());
addProps.put("null-value", null);
- new DmaapDmePublisherWrapper(makeBuilder().build());
+ assertThatCode(() -> new DmaapDmePublisherWrapper(makeBuilder().build())).doesNotThrowAnyException();
}
@Test(expected = IllegalArgumentException.class)
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 01028045..0a2a5d34 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-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 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.
@@ -20,6 +20,7 @@
package org.onap.policy.common.endpoints.event.comm.bus.internal;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
@@ -53,7 +54,7 @@ public class BusTopicBaseTest extends TopicTestBase {
@Test
public void testSerialize() {
- new GsonTestUtils().compareGson(base, BusTopicBaseTest.class);
+ assertThatCode(() -> new GsonTestUtils().compareGson(base, BusTopicBaseTest.class)).doesNotThrowAnyException();
}
@Test
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 634ee762..e6eec799 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
@@ -20,6 +20,7 @@
package org.onap.policy.common.endpoints.event.comm.bus.internal;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -61,7 +62,8 @@ public class InlineBusTopicSinkTest extends TopicTestBase {
@Test
public void testSerialize() {
- new GsonTestUtils().compareGson(sink, InlineBusTopicSinkTest.class);
+ assertThatCode(() -> new GsonTestUtils().compareGson(sink, InlineBusTopicSinkTest.class))
+ .doesNotThrowAnyException();
}
@Test
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 d9bc990b..239bf33a 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-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 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.
@@ -20,6 +20,7 @@
package org.onap.policy.common.endpoints.event.comm.bus.internal;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -51,7 +52,8 @@ public class InlineDmaapTopicSinkTest extends TopicTestBase {
@Test
public void testSerialize() {
- new GsonTestUtils().compareGson(sink, InlineDmaapTopicSinkTest.class);
+ assertThatCode(() -> new GsonTestUtils().compareGson(sink, InlineDmaapTopicSinkTest.class))
+ .doesNotThrowAnyException();
}
@Test
@@ -70,7 +72,7 @@ public class InlineDmaapTopicSinkTest extends TopicTestBase {
sink = new InlineDmaapTopicSink(makeBuilder().environment(null).aftEnvironment(null).latitude(null)
.longitude(null).partner(null).build());
sink.init();
- sink.shutdown();
+ assertThatCode(() -> sink.shutdown()).doesNotThrowAnyException();
}
@Test
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 a45504f2..674f379f 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-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 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.
@@ -20,6 +20,7 @@
package org.onap.policy.common.endpoints.event.comm.bus.internal;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -51,7 +52,8 @@ public class InlineUebTopicSinkTest extends TopicTestBase {
@Test
public void testSerialize() {
- new GsonTestUtils().compareGson(sink, InlineUebTopicSinkTest.class);
+ assertThatCode(() -> new GsonTestUtils().compareGson(sink, InlineUebTopicSinkTest.class))
+ .doesNotThrowAnyException();
}
@Test
@@ -61,7 +63,7 @@ public class InlineUebTopicSinkTest extends TopicTestBase {
@Test
public void testInit() {
- sink.init();
+ assertThatCode(() -> sink.init()).doesNotThrowAnyException();
}
@Test
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 16d74df2..1e95924d 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-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 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.
@@ -20,6 +20,7 @@
package org.onap.policy.common.endpoints.event.comm.bus.internal;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -72,7 +73,8 @@ public class SingleThreadedBusTopicSourceTest extends TopicTestBase {
@Test
public void testSerialize() {
- new GsonTestUtils().compareGson(source, SingleThreadedBusTopicSourceTest.class);
+ assertThatCode(() -> new GsonTestUtils().compareGson(source, SingleThreadedBusTopicSourceTest.class))
+ .doesNotThrowAnyException();
}
@Test
@@ -163,7 +165,8 @@ public class SingleThreadedBusTopicSourceTest extends TopicTestBase {
new SingleThreadedBusTopicSourceImpl(makeBuilder().consumerGroup(null).build());
new SingleThreadedBusTopicSourceImpl(makeBuilder().consumerInstance(null).build());
new SingleThreadedBusTopicSourceImpl(makeBuilder().fetchTimeout(-1).build());
- new SingleThreadedBusTopicSourceImpl(makeBuilder().fetchLimit(-1).build());
+ assertThatCode(() -> new SingleThreadedBusTopicSourceImpl(makeBuilder().fetchLimit(-1).build()))
+ .doesNotThrowAnyException();
}
@Test
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 b7faf161..c7d30025 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-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 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.
@@ -20,6 +20,7 @@
package org.onap.policy.common.endpoints.event.comm.bus.internal;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -53,7 +54,8 @@ public class SingleThreadedDmaapTopicSourceTest extends TopicTestBase {
@Test
public void testSerialize() {
- new GsonTestUtils().compareGson(source, SingleThreadedDmaapTopicSourceTest.class);
+ assertThatCode(() -> new GsonTestUtils().compareGson(source, SingleThreadedDmaapTopicSourceTest.class))
+ .doesNotThrowAnyException();
}
@Test
@@ -75,9 +77,10 @@ public class SingleThreadedDmaapTopicSourceTest extends TopicTestBase {
@Test
public void testInit() {
// verify with different parameters
- new SingleThreadedDmaapTopicSource(makeBuilder().userName(null).build()).shutdown();
new SingleThreadedDmaapTopicSource(makeBuilder().environment(null).aftEnvironment(null).latitude(null)
.longitude(null).partner(null).build()).shutdown();
+ assertThatCode(() -> new SingleThreadedDmaapTopicSource(makeBuilder().userName(null).build()).shutdown())
+ .doesNotThrowAnyException();
}
@Test(expected = IllegalArgumentException.class)
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 2ff353b8..6536d0e8 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-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 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.
@@ -20,6 +20,7 @@
package org.onap.policy.common.endpoints.event.comm.bus.internal;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -51,7 +52,8 @@ public class SingleThreadedUebTopicSourceTest extends TopicTestBase {
@Test
public void testSerialize() {
- new GsonTestUtils().compareGson(source, SingleThreadedUebTopicSourceTest.class);
+ assertThatCode(() -> new GsonTestUtils().compareGson(source, SingleThreadedUebTopicSourceTest.class))
+ .doesNotThrowAnyException();
}
@Test
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 0cf1486f..67b84ea8 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
@@ -20,6 +20,7 @@
package org.onap.policy.common.endpoints.event.comm.bus.internal;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -97,7 +98,7 @@ public class TopicBaseTest extends TopicTestBase {
@Test
public void testSerialize() {
- new GsonTestUtils().compareGson(base, TopicBaseTest.class);
+ assertThatCode(() -> new GsonTestUtils().compareGson(base, TopicBaseTest.class)).doesNotThrowAnyException();
}
@Test
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 e202b11b..cbe5a5a5 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,6 +22,7 @@
package org.onap.policy.common.endpoints.http.server.test;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.catchThrowable;
import static org.junit.Assert.assertEquals;
@@ -346,7 +347,7 @@ public class HttpServerTest {
server.addFilterClass("/*", TestFilter.class.getName());
// ensure we can serialize the server
- new GsonTestUtils().compareGson(server, HttpServerTest.class);
+ assertThatCode(() -> new GsonTestUtils().compareGson(server, HttpServerTest.class)).doesNotThrowAnyException();
}
@Test