Fix junit tests in distribution 99/90099/1
authorJim Hahn <jrh3@att.com>
Tue, 18 Jun 2019 16:25:03 +0000 (12:25 -0400)
committerJim Hahn <jrh3@att.com>
Tue, 18 Jun 2019 16:25:03 +0000 (12:25 -0400)
Sonar fix broke some of the junit tests for parameters; fixed
those.
Also fixed some checkstyle errors (e.g., unused imports).

Change-Id: I76c57792b82b9c2ddd27bdbc35910e9b11d86ea5
Issue-ID: POLICY-1791
Signed-off-by: Jim Hahn <jrh3@att.com>
main/src/test/resources/expectedValidationResults/InvalidDecoderAndForwarderParameters.txt
main/src/test/resources/expectedValidationResults/InvalidReceptionHandlerParameters.txt
plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderParameterGroupTest.java
plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderTest.java
plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java

index 392f845..a5e84f5 100644 (file)
@@ -1,15 +1,15 @@
 validation error(s) on parameters from "parameters/DistributionConfigParameters_InvalidDecoderAndForwarderParameters.json"
 parameter group "SDCDistributionGroup" type "org.onap.policy.distribution.main.parameters.DistributionParameterGroup" INVALID, parameter group has status INVALID
-  parameter group map "receptionHandlerParameters" INVALID, parameter group has status INVALID
+  parameter group map "receptionHandlerParameters" INVALID, parameter group map has status INVALID
     parameter group "null_DummyReceptionHandler" type "org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters" INVALID, parameter group has status INVALID
       parameter group "null_PluginHandler" type "org.onap.policy.distribution.reception.parameters.PluginHandlerParameters" INVALID, parameter group has status INVALID
-        parameter group map "policyDecoders" INVALID, parameter group has status INVALID
+        parameter group map "policyDecoders" INVALID, parameter group map has status INVALID
           parameter group "" type "org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters" INVALID, parameter group has status INVALID
             field "decoderType" type "java.lang.String" value "" INVALID, must be a non-blank string
             field "decoderClassName" type "java.lang.String" value "org.onap.policy.distribution.main.testclasses.PolicyDecoderApexPdpa" INVALID, policy decoder class not found in classpath
           parameter group "DROOLS" type "org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters" INVALID, parameter group has status INVALID
             field "decoderClassName" type "java.lang.String" value "" INVALID, must be a non-blank string containing full class name of the decoder
-        parameter group map "policyForwarders" INVALID, parameter group has status INVALID
+        parameter group map "policyForwarders" INVALID, parameter group map has status INVALID
           parameter group "" type "org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters" INVALID, parameter group has status INVALID
             field "forwarderType" type "java.lang.String" value "" INVALID, must be a non-blank string
             field "forwarderClassName" type "java.lang.String" value "org.onap.policy.distribution.main.testclasses.PapStandalonePolicyForwarder" INVALID, policy forwarder class not found in classpath
index cec33d0..37c3457 100644 (file)
@@ -1,6 +1,6 @@
 validation error(s) on parameters from "parameters/DistributionConfigParameters_InvalidReceptionHandlerParameters.json"
 parameter group "SDCDistributionGroup" type "org.onap.policy.distribution.main.parameters.DistributionParameterGroup" INVALID, parameter group has status INVALID
-  parameter group map "receptionHandlerParameters" INVALID, parameter group has status INVALID
+  parameter group map "receptionHandlerParameters" INVALID, parameter group map has status INVALID
     parameter group "null_" type "org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters" INVALID, parameter group has status INVALID
       field "receptionHandlerType" type "java.lang.String" value "" INVALID, must be a non-blank string
       field "receptionHandlerClassName" type "java.lang.String" value "org.onap.policy.distribution.main.testclasses.InvalidSdcReceptionHandler" INVALID, reception handler class not found in classpath
index 20528a5..ec677cb 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Intel Corp. All rights reserved.
+ *  Modifications Copyright (C) 2019 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.
@@ -21,7 +22,6 @@
 package org.onap.policy.distribution.forwarding.file;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
index 9da9c1d..e474f69 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Intel Corp. All rights reserved.
+ *  Modifications Copyright (C) 2019 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.
@@ -30,19 +31,16 @@ import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
 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.runners.MockitoJUnitRunner;
 import org.onap.policy.common.parameters.ParameterGroup;
 import org.onap.policy.common.parameters.ParameterService;
-import org.onap.policy.distribution.forwarding.PolicyForwardingException;
 import org.onap.policy.distribution.model.OptimizationPolicy;
 import org.onap.policy.distribution.model.Policy;
 
@@ -107,6 +105,7 @@ public class FilePolicyForwarderTest {
     }
 
     @Test
+    @SuppressWarnings("unchecked")
     public void testForwardPolicyError() {
         final Collection<Policy> policies = new ArrayList<>();
         OptimizationPolicy policy = new OptimizationPolicy();
index df5302c..77269bb 100644 (file)
@@ -2,6 +2,7 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2018 Intel Corp. All rights reserved.
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 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.
@@ -113,7 +114,6 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler {
      * @param maxThread the max thread number
      * @throws InterruptedException if it occurs
      */
-    @SuppressWarnings("unchecked")
     protected void startWatchService(final WatchService watcher,
             final Path dir, int maxThread) throws InterruptedException {
         WatchKey key;
@@ -137,6 +137,7 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler {
 
     private void processFileEvents(Path dir, WatchKey key, ExecutorService pool) {
         for (final WatchEvent<?> event : key.pollEvents()) {
+            @SuppressWarnings("unchecked")
             final WatchEvent<Path> ev = (WatchEvent<Path>) event;
             final Path fileName = ev.context();
             pool.execute(() -> {