From 150c53fdda47ae838a8783b8bdfd3168bd0484e0 Mon Sep 17 00:00:00 2001 From: uj426b Date: Thu, 23 Jul 2020 16:17:24 -0400 Subject: Sonar fixes for policy/distribution Change-Id: Ia48406096706daaa6a98985c488b4055276863d3 Issue-ID: POLICY-2713 Signed-off-by: uj426b --- .../TestDistributionParameterHandler.java | 22 +++++++++------------- .../distribution/main/startstop/TestMain.java | 7 ++++--- 2 files changed, 13 insertions(+), 16 deletions(-) (limited to 'main') diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java index a789569b..89d7c656 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java +++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2020 Nordix Foundation + * Modifications Copyright (C) 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. @@ -105,11 +106,9 @@ public class TestDistributionParameterHandler { { "-c", "parameters/NoParameters.json" }; final DistributionCommandLineArguments noArguments = new DistributionCommandLineArguments(); + final DistributionParameterHandler paramHandler = new DistributionParameterHandler(); noArguments.parse(noArgumentString); - - assertThatThrownBy(() -> - new DistributionParameterHandler().getParameters(noArguments) - ).isInstanceOf(ParameterRuntimeException.class) + assertThatThrownBy(() -> paramHandler.getParameters(noArguments)).isInstanceOf(ParameterRuntimeException.class) .hasMessageContaining("map parameter \"receptionHandlerParameters\" is null"); } @@ -209,11 +208,10 @@ public class TestDistributionParameterHandler { { "-c", "parameters/DistributionConfigParameters_NoReceptionHandler.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); + final DistributionParameterHandler paramHandler = new DistributionParameterHandler(); arguments.parse(distributionConfigParameters); - assertThatThrownBy(() -> - new DistributionParameterHandler().getParameters(arguments) - ).isInstanceOf(ParameterRuntimeException.class) + assertThatThrownBy(() -> paramHandler.getParameters(arguments)).isInstanceOf(ParameterRuntimeException.class) .hasMessageContaining("map parameter \"receptionHandlerParameters\" is null"); } @@ -237,11 +235,10 @@ public class TestDistributionParameterHandler { { "-c", "parameters/DistributionConfigParameters_NoPolicyDecoder.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); + final DistributionParameterHandler paramHandler = new DistributionParameterHandler(); arguments.parse(distributionConfigParameters); - assertThatThrownBy(() -> - new DistributionParameterHandler().getParameters(arguments) - ).isInstanceOf(ParameterRuntimeException.class) + assertThatThrownBy(() -> paramHandler.getParameters(arguments)).isInstanceOf(ParameterRuntimeException.class) .hasMessageContaining("map parameter \"policyDecoders\" is null"); } @@ -251,11 +248,10 @@ public class TestDistributionParameterHandler { { "-c", "parameters/DistributionConfigParameters_NoPolicyForwarder.json" }; final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); + final DistributionParameterHandler paramHandler = new DistributionParameterHandler(); arguments.parse(distributionConfigParameters); - assertThatThrownBy(() -> - new DistributionParameterHandler().getParameters(arguments) - ).isInstanceOf(ParameterRuntimeException.class) + assertThatThrownBy(() -> paramHandler.getParameters(arguments)).isInstanceOf(ParameterRuntimeException.class) .hasMessageContaining("map parameter \"policyForwarders\" is null"); } diff --git a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java index e5d03aaf..f6ddbe99 100644 --- a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java +++ b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java @@ -23,6 +23,7 @@ package org.onap.policy.distribution.main.startstop; import static org.assertj.core.api.Assertions.assertThatCode; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; @@ -51,7 +52,7 @@ public class TestMain { final String[] distributionConfigParameters = {}; final Main main = new Main(distributionConfigParameters); - assertTrue(main.getParameters() == null); + assertNull(main.getParameters()); } @Test @@ -59,7 +60,7 @@ public class TestMain { final String[] distributionConfigParameters = { "parameters/DistributionConfigParameters.json" }; final Main main = new Main(distributionConfigParameters); - assertTrue(main.getParameters() == null); + assertNull(main.getParameters()); } @Test @@ -76,6 +77,6 @@ public class TestMain { final String[] distributionConfigParameters = { "-c", "parameters/DistributionConfigParameters_InvalidName.json" }; final Main main = new Main(distributionConfigParameters); - assertTrue(main.getParameters() == null); + assertNull(main.getParameters()); } } -- cgit 1.2.3-korg