summaryrefslogtreecommitdiffstats
path: root/plugins/reception-plugins/src/test
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2018-11-13 10:19:07 -0500
committerRam Krishna Verma <ram.krishna.verma@ericsson.com>2018-11-13 17:17:51 +0000
commitbf30e81ea77ab361a25f0076c7f81c10ded9c53e (patch)
treeb81d5f6f52f8286bc2cabbd655cf574c77990af7 /plugins/reception-plugins/src/test
parent9b18d4f702586fd022fd142f0f23e5a0e3b24359 (diff)
Fix unchecked cast sonar issue
Removed the unused variable. We are reasonably sure that the cast is ok. Fixed the JUnit tests, removed useless imports, unused variables and raw types. Issue-ID: POLICY-1256 Change-Id: Iad7dbbf02a4dd48648fc9d5c20595c9f0f8d7acb Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'plugins/reception-plugins/src/test')
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandler.java10
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandlerConfigurationParameterGroup.java12
2 files changed, 10 insertions, 12 deletions
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandler.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandler.java
index 29eb3f7e..fc2a2b6a 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandler.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandler.java
@@ -26,6 +26,7 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.File;
+import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -37,7 +38,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
-import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
@@ -45,7 +45,6 @@ import org.mockito.stubbing.Answer;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.common.parameters.ParameterService;
-import org.onap.policy.distribution.forwarding.PolicyForwarder;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.policy.distribution.reception.statistics.DistributionStatisticsManager;
@@ -56,7 +55,6 @@ import org.onap.policy.distribution.reception.statistics.DistributionStatisticsM
public class TestFileSystemReceptionHandler {
private static final Logger LOGGER = FlexLogger.getLogger(TestFileSystemReceptionHandler.class);
- private static final String DUMMY_SERVICE_CSAR = "dummyService.csar";
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
@@ -80,9 +78,7 @@ public class TestFileSystemReceptionHandler {
DistributionStatisticsManager.resetAllStatistics();
final Gson gson = new GsonBuilder().create();
- String json = "{ \"name\": \"parameterConfig9\", \"watchPath\": \"";
- json += tempFolder.getRoot().getAbsolutePath() + "\"}";
- pssdConfigParameters = gson.fromJson(json,
+ pssdConfigParameters = gson.fromJson(new FileReader("src/test/resources/handling-filesystem.json"),
FileSystemReceptionHandlerConfigurationParameterGroup.class);
ParameterService.register(pssdConfigParameters);
fileSystemHandler = new FileSystemReceptionHandler();
@@ -127,7 +123,7 @@ public class TestFileSystemReceptionHandler {
Processed cond = new Processed();
final FileSystemReceptionHandler sypHandler = Mockito.spy(fileSystemHandler);
- Mockito.doAnswer(new Answer() {
+ Mockito.doAnswer(new Answer<Object>() {
public Object answer(InvocationOnMock invocation) {
synchronized (lock) {
cond.processed = true;
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandlerConfigurationParameterGroup.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandlerConfigurationParameterGroup.java
index b4b905c5..3039560a 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandlerConfigurationParameterGroup.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandlerConfigurationParameterGroup.java
@@ -30,7 +30,6 @@ import com.google.gson.GsonBuilder;
import java.io.FileReader;
import java.io.IOException;
-import java.util.Arrays;
import org.junit.Rule;
import org.junit.Test;
@@ -49,16 +48,19 @@ public class TestFileSystemReceptionHandlerConfigurationParameterGroup {
@Test
public void testFileSystemConfiguration() throws IOException {
FileSystemReceptionHandlerConfigurationParameterGroup configParameters = null;
+ String validPath = null;
try {
- final Gson gson = new GsonBuilder().create();
- configParameters = gson.fromJson(new FileReader("src/test/resources/handling-filesystem.json"),
- FileSystemReceptionHandlerConfigurationParameterGroup.class);
+ validPath = tempFolder.getRoot().getAbsolutePath();
+
+ final FileSystemReceptionHandlerConfigurationParameterBuilder builder =
+ new FileSystemReceptionHandlerConfigurationParameterBuilder().setWatchPath(validPath);
+ configParameters = new FileSystemReceptionHandlerConfigurationParameterGroup(builder);
} catch (final Exception e) {
fail("test should not thrown an exception here: " + e.getMessage());
}
final GroupValidationResult validationResult = configParameters.validate();
assertTrue(validationResult.isValid());
- assertEquals("/tmp", configParameters.getWatchPath());
+ assertEquals(validPath, configParameters.getWatchPath());
}
@Test