From 87be30582d1db37bee7c6b456c0c5c3ca9584963 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 4 Sep 2018 17:24:15 +0100 Subject: Fix checkstyle issues in apex model basic CHeckstyle issues in apex model basic and knock on changes in other apex modules. Issue-ID: POLICY-1034 Change-Id: I65823f5e2e344526abc74b0812877113acb056ec Signed-off-by: liamfallon --- .../policy/apex/model/utilities/TextFileUtils.java | 3 +- .../model/utilities/CollectionUtilitiesTest.java | 18 +++---- .../apex/model/utilities/DirectoryUtilsTest.java | 3 -- .../apex/model/utilities/json/JSONHandlerTest.java | 60 --------------------- .../apex/model/utilities/json/JsonHandlerTest.java | 61 ++++++++++++++++++++++ 5 files changed, 71 insertions(+), 74 deletions(-) delete mode 100644 model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JSONHandlerTest.java create mode 100644 model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java (limited to 'model/utilities/src') diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TextFileUtils.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TextFileUtils.java index 97face9bd..29e31d6e6 100644 --- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TextFileUtils.java +++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TextFileUtils.java @@ -103,7 +103,8 @@ public abstract class TextFileUtils { if (charsRead > 0) { builder.append(chars, 0, charsRead); } - } while (charsRead > 0); + } + while (charsRead > 0); return builder.toString(); } } diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java index 4682d985d..e9ddc11bc 100644 --- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java +++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java @@ -28,24 +28,22 @@ import java.util.List; import org.junit.Test; import org.onap.policy.apex.model.utilities.CollectionUtils; -/** - * @author Liam Fallon (liam.fallon@ericsson.com) - */ public class CollectionUtilitiesTest { @Test public void testNullLists() { - List leftList = new ArrayList(); - List rightList = new ArrayList(); - int result = 0; result = CollectionUtils.compareLists(null, null); assertEquals(0, result); + List leftList = new ArrayList(); + result = CollectionUtils.compareLists(leftList, null); assertEquals(-1, result); + List rightList = new ArrayList(); + result = CollectionUtils.compareLists(null, rightList); assertEquals(1, result); @@ -73,8 +71,8 @@ public class CollectionUtilitiesTest { result = CollectionUtils.compareLists(leftList, rightList); assertEquals(-1, result); - leftList.remove(leftList.size() -1); - rightList.remove(rightList.size() -1); + leftList.remove(leftList.size() - 1); + rightList.remove(rightList.size() - 1); result = CollectionUtils.compareLists(leftList, rightList); assertEquals(0, result); @@ -83,8 +81,8 @@ public class CollectionUtilitiesTest { result = CollectionUtils.compareLists(leftList, rightList); assertEquals(1, result); - leftList.remove(leftList.size() -1); - rightList.remove(rightList.size() -1); + leftList.remove(leftList.size() - 1); + rightList.remove(rightList.size() - 1); result = CollectionUtils.compareLists(leftList, rightList); assertEquals(0, result); } diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/DirectoryUtilsTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/DirectoryUtilsTest.java index 84e9733f3..95839cd72 100644 --- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/DirectoryUtilsTest.java +++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/DirectoryUtilsTest.java @@ -29,9 +29,6 @@ import org.junit.Test; import org.onap.policy.apex.model.utilities.DirectoryUtils; import org.onap.policy.apex.model.utilities.TextFileUtils; -/** - * @author Liam Fallon (liam.fallon@ericsson.com) - */ public class DirectoryUtilsTest { @Test diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JSONHandlerTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JSONHandlerTest.java deleted file mode 100644 index b8e2cebbc..000000000 --- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JSONHandlerTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. 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. - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.policy.apex.model.utilities.json; - -import static org.junit.Assert.assertEquals; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; - -import org.junit.Test; - -import com.google.gson.GsonBuilder; - -public class JSONHandlerTest { - - private static final String VALUE = "value"; - - @Test - public void testAssertions() throws IOException { - final OverTheMoonObject jsonObject = new OverTheMoonObject(VALUE); - final String jsonString = new GsonBuilder().create().toJson(jsonObject); - - final byte[] bytes = jsonString.getBytes(StandardCharsets.UTF_8); - try (final InputStream inputStream = new ByteArrayInputStream(bytes);) { - - final JSONHandler objUnderTest = new JSONHandler<>(); - - final OverTheMoonObject actualObject = objUnderTest.read(OverTheMoonObject.class, inputStream); - assertEquals(VALUE, actualObject.name); - } - - } - - private class OverTheMoonObject { - private final String name; - - public OverTheMoonObject(final String name) { - this.name = name; - } - } -} diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java new file mode 100644 index 000000000..c9db6c395 --- /dev/null +++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. 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. + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.model.utilities.json; + +import static org.junit.Assert.assertEquals; + +import com.google.gson.GsonBuilder; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +import org.junit.Test; + +public class JsonHandlerTest { + + private static final String VALUE = "value"; + + @Test + public void testAssertions() throws IOException { + final OverTheMoonObject jsonObject = new OverTheMoonObject(VALUE); + final String jsonString = new GsonBuilder().create().toJson(jsonObject); + + final byte[] bytes = jsonString.getBytes(StandardCharsets.UTF_8); + try (final InputStream inputStream = new ByteArrayInputStream(bytes);) { + + final JSONHandler objUnderTest = new JSONHandler<>(); + + final OverTheMoonObject actualObject = objUnderTest.read(OverTheMoonObject.class, inputStream); + assertEquals(VALUE, actualObject.name); + } + + } + + private class OverTheMoonObject { + private final String name; + + public OverTheMoonObject(final String name) { + this.name = name; + } + } +} -- cgit 1.2.3-korg