summaryrefslogtreecommitdiffstats
path: root/feature-pooling-dmaap/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-06-19 14:32:10 -0400
committerJim Hahn <jrh3@att.com>2020-06-19 15:44:28 -0400
commit56a15039437ba5bf5d0fb422551bfb12e1f59eb1 (patch)
tree1fc57df4d9462790d4c4dd811425ab029d8ec710 /feature-pooling-dmaap/src/test
parent1d810e0be1188c07ec9292b348c9d286f36963d9 (diff)
Address checkstyle version issues in drools-pdp
Also added serializationId to several classes to address eclipse warnings. Issue-ID: POLICY-2188 Change-Id: I3df5e8abaad8da9261c0d5cd19a93ed68dceb870 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-pooling-dmaap/src/test')
-rw-r--r--feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java77
-rw-r--r--feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/MapExtractorTest.java22
-rw-r--r--feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java8
3 files changed, 53 insertions, 54 deletions
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java
index d51e61e6..c35e525a 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -76,7 +76,7 @@ import org.slf4j.LoggerFactory;
* <dt>PolicyEngine, PolicyController, DroolsController</dt>
* <dd>mocked</dd>
* </dl>
- *
+ *
* <p>Invoke {@link #runSlow()}, before the test, to slow things down.
*/
public class FeatureTest {
@@ -178,7 +178,7 @@ public class FeatureTest {
private String makeMessage(int reqnum) {
return "{\"reqid\":\"req" + reqnum + "\", \"data\":\"hello " + reqnum + "\"}";
}
-
+
/**
* Invoke this to slow the timers down.
*/
@@ -196,7 +196,7 @@ public class FeatureTest {
/**
* Decodes an event.
- *
+ *
* @param event event
* @return the decoded event, or {@code null} if it cannot be decoded
*/
@@ -253,7 +253,7 @@ public class FeatureTest {
/**
* Constructor.
- *
+ *
* @param nEvents number of events to be processed
*/
public Context(int events) {
@@ -270,7 +270,7 @@ public class FeatureTest {
/**
* Creates and adds a new host to the context.
- *
+ *
* @return the new Host
*/
public Host addHost() {
@@ -308,7 +308,7 @@ public class FeatureTest {
/**
* Sets {@link #currentHost} to the specified host, and then invokes the given
* function. Resets {@link #currentHost} to {@code null} before returning.
- *
+ *
* @param host host
* @param func function to invoke
*/
@@ -320,7 +320,7 @@ public class FeatureTest {
/**
* Offers an event to the external topic.
- *
+ *
* @param event event
*/
public void offerExternal(String event) {
@@ -329,7 +329,7 @@ public class FeatureTest {
/**
* Adds an internal channel to the set of channels.
- *
+ *
* @param channel channel
* @param queue the channel's queue
*/
@@ -339,7 +339,7 @@ public class FeatureTest {
/**
* Offers a message to all internal channels.
- *
+ *
* @param message message
*/
public void offerInternal(String message) {
@@ -348,7 +348,7 @@ public class FeatureTest {
/**
* Offers amessage to an internal channel.
- *
+ *
* @param channel channel
* @param message message
*/
@@ -361,7 +361,7 @@ public class FeatureTest {
/**
* Associates a controller with its drools controller.
- *
+ *
* @param controller controller
* @param droolsController drools controller
*/
@@ -371,7 +371,7 @@ public class FeatureTest {
/**
* Get controller.
- *
+ *
* @param droolsController drools controller
* @return the controller associated with a drools controller, or {@code null} if
* it has no associated controller
@@ -382,7 +382,7 @@ public class FeatureTest {
/**
* Constructor.
- *
+ *
* @return queue for the external topic
*/
public BlockingQueue<String> getExternalTopic() {
@@ -391,7 +391,7 @@ public class FeatureTest {
/**
* Get decode errors.
- *
+ *
* @return the number of decode errors so far
*/
public int getDecodeErrors() {
@@ -407,7 +407,7 @@ public class FeatureTest {
/**
* Get remaining events.
- *
+ *
* @return the number of events that haven't been processed
*/
public long getRemainingEvents() {
@@ -423,7 +423,7 @@ public class FeatureTest {
/**
* Waits, for a period of time, for all events to be processed.
- *
+ *
* @param time time
* @param units units
* @return {@code true} if all events have been processed, {@code false} otherwise
@@ -436,7 +436,7 @@ public class FeatureTest {
/**
* Gets the current host, provided this is used from within a call to
* {@link #withHost(Host, VoidFunction)}.
- *
+ *
* @return the current host, or {@code null} if there is no current host
*/
public Host getCurrentHost() {
@@ -475,7 +475,7 @@ public class FeatureTest {
/**
* Constructor.
- *
+ *
* @param context context
*/
public Host(Context context) {
@@ -496,13 +496,13 @@ public class FeatureTest {
// arrange to read from the external topic
externalSource = new TopicSourceImpl(context, false);
-
+
feature = new PoolingFeatureImpl(context);
}
/**
* Get name.
- *
+ *
* @return the host name
*/
public String getName() {
@@ -543,7 +543,7 @@ public class FeatureTest {
/**
* Offers an event to the feature, before the policy controller handles it.
- *
+ *
* @param protocol protocol
* @param topic2 topic
* @param event event
@@ -555,7 +555,7 @@ public class FeatureTest {
/**
* Offers an event to the feature, after the policy controller handles it.
- *
+ *
* @param protocol protocol
* @param topic topic
* @param event event
@@ -569,7 +569,7 @@ public class FeatureTest {
/**
* Offers an event to the feature, before the drools controller handles it.
- *
+ *
* @param fact fact
* @return {@code true} if the event was handled, {@code false} otherwise
*/
@@ -579,7 +579,7 @@ public class FeatureTest {
/**
* Offers an event to the feature, after the drools controller handles it.
- *
+ *
* @param fact fact
* @param successInsert {@code true} if it was successfully inserted by the drools
* controller, {@code false} otherwise
@@ -598,7 +598,7 @@ public class FeatureTest {
/**
* Message seen.
- *
+ *
* @return {@code true} if a message was seen for this host, {@code false}
* otherwise
*/
@@ -608,7 +608,7 @@ public class FeatureTest {
/**
* Get internal queue.
- *
+ *
* @return the queue associated with this host's internal topic
*/
public BlockingQueue<String> getInternalQueue() {
@@ -681,7 +681,7 @@ public class FeatureTest {
/**
* Constructor.
- *
+ *
* @param context context
*/
public TopicSinkImpl(Context context) {
@@ -738,7 +738,7 @@ public class FeatureTest {
/**
* Constructor.
- *
+ *
* @param context context
* @param internal {@code true} if to read from the internal topic, {@code false}
* to read from the external topic
@@ -784,8 +784,7 @@ public class FeatureTest {
try {
do {
processMessages(newPair.first(), listener);
- }
- while (!newPair.first().await(stdInterPollMs, TimeUnit.MILLISECONDS));
+ } while (!newPair.first().await(stdInterPollMs, TimeUnit.MILLISECONDS));
logger.info("topic source thread completed");
@@ -816,7 +815,7 @@ public class FeatureTest {
/**
* Registers a new "pair" with this source, stopping the consumer associated with
* any previous registration.
- *
+ *
* @param newPair the new "pair", or {@code null} to unregister
*/
private void reregister(Pair<CountDownLatch, CountDownLatch> newPair) {
@@ -855,7 +854,7 @@ public class FeatureTest {
/**
* Polls for messages from the topic and offers them to the listener.
- *
+ *
* @param stopped triggered if processing should stop
* @param listener listener
* @throws InterruptedException throws interrupted exception
@@ -967,7 +966,7 @@ public class FeatureTest {
/**
* Constructor.
- *
+ *
* @param context context
*/
public PoolingFeatureImpl(Context context) {
@@ -1010,7 +1009,7 @@ public class FeatureTest {
/**
* Embeds a specializer within a property name, after the prefix.
- *
+ *
* @param propnm property name into which it should be embedded
* @param spec specializer to be embedded
* @return the property name, with the specializer embedded within it
@@ -1025,7 +1024,7 @@ public class FeatureTest {
CountDownLatch activeLatch) {
currentContext.set(context);
-
+
return new PoolingManagerTest(host, controller, props, activeLatch);
}
}
@@ -1037,7 +1036,7 @@ public class FeatureTest {
/**
* Constructor.
- *
+ *
* @param host the host
* @param controller the controller
* @param props the properties
@@ -1072,7 +1071,7 @@ public class FeatureTest {
/**
* Constructor.
- *
+ *
* @param context this manager's context
* @param topic the topic
* @throws PoolingFeatureException if an error occurs
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/MapExtractorTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/MapExtractorTest.java
index afaa2b65..74694579 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/MapExtractorTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/MapExtractorTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -31,17 +31,17 @@ import org.junit.Test;
public class MapExtractorTest {
private static final String KEY = "a.key";
private static final String VALUE = "a.value";
-
+
private MapExtractor ext;
-
+
@Before
public void setUp() {
- ext = new MapExtractor(KEY);
+ ext = new MapExtractor(KEY);
}
@Test
public void testExtract_NotAMap() {
-
+
// object is not a map (i.e., it's a String)
assertNull(ext.extract(KEY));
}
@@ -49,9 +49,9 @@ public class MapExtractorTest {
@Test
public void testExtract_MissingValue() {
- Map<String,Object> map = new HashMap<>();
+ Map<String, Object> map = new HashMap<>();
map.put(KEY + "x", VALUE + "x");
-
+
// object is a map, but doesn't have the key
assertNull(ext.extract(map));
}
@@ -59,13 +59,13 @@ public class MapExtractorTest {
@Test
public void testExtract() {
- Map<String,Object> map = new HashMap<>();
+ Map<String, Object> map = new HashMap<>();
map.put(KEY + "x", VALUE + "x");
map.put(KEY, VALUE);
-
+
// object is a map and contains the key
assertEquals(VALUE, ext.extract(map));
-
+
// change to value to a different type
map.put(KEY, 20);
assertEquals(20, ext.extract(map));
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java
index 3682dcb4..82346f5c 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -275,7 +275,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
@Test
public void testRemoveExcessHosts() {
- /**
+ /*
* All hosts are still alive, plus some others.
*/
state.setAssignments(ASGN3);
@@ -314,7 +314,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
@Test
public void testRebalanceBuckets() {
- /**
+ /*
* Some are very lopsided.
*/
String[] asgn = {MY_HOST, HOST1, MY_HOST, MY_HOST, MY_HOST, MY_HOST, HOST1, HOST2, HOST1, HOST3};