From 7ebe54041c04f938cf58fdec9e120347e64c543a Mon Sep 17 00:00:00 2001 From: Joss Armstrong Date: Tue, 26 Feb 2019 12:40:24 +0000 Subject: Fixed tests on PreCheck class Replaced console printing with assertions Added branch coverage to clear Sonar major warning Increased line coverage to 100% Issue-ID: APPC-1499 Change-Id: Ia027b9d7f414789816d80e12543d27a0baeed9c1 Signed-off-by: Joss Armstrong --- .../appc/flow/controller/data/PreCheckTest.java | 33 +++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'appc-config') diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/data/PreCheckTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/data/PreCheckTest.java index 80e038440..c3145d77d 100644 --- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/data/PreCheckTest.java +++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/data/PreCheckTest.java @@ -5,6 +5,8 @@ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. * ============================================================================= * Modifications Copyright (C) 2018 IBM. + * ================================================================================ + * Modifications Copyright (C) 2019 Ericsson * ============================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +28,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; - +import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -50,7 +52,7 @@ public class PreCheckTest { public void testSetPrecheckOperator() { preCheck.setPrecheckOperator("op"); assertNotNull(preCheck.getPrecheckOperator()); - assertEquals(preCheck.getPrecheckOperator(),"op"); + assertEquals("op", preCheck.getPrecheckOperator()); } @Test @@ -58,13 +60,13 @@ public class PreCheckTest { List precheckOptionList = new LinkedList<>(); preCheck.setPrecheckOptions(precheckOptionList); assertNotNull(preCheck.getPrecheckOptions()); - assertEquals(preCheck.getPrecheckOptions(), precheckOptionList); + assertEquals(precheckOptionList, preCheck.getPrecheckOptions()); } @Test public void testHashCode() { preCheck.setPrecheckOperator("1"); - System.out.println(" precheck hashcode is " + preCheck.hashCode()); + assertNotNull(preCheck.hashCode()); } @Test @@ -72,16 +74,27 @@ public class PreCheckTest { preCheck.setPrecheckOperator("A"); List precheckOptionList = new LinkedList<>(); preCheck.setPrecheckOptions(precheckOptionList); - String ret = preCheck.toString(); - System.out.println("ret is " + ret); - + assertTrue(preCheck.toString().contains("precheckOperator=A")); } - + @Test public void testEqualsObject() { - assertTrue(preCheck1.equals(preCheck2) && preCheck2.equals(preCheck1)); + assertTrue(preCheck1.equals(preCheck2)); assertTrue(preCheck1.equals(preCheck1)); assertFalse(preCheck1.equals(null)); + assertFalse(preCheck1.equals("")); + preCheck2.setPrecheckOperator("other_precheckOperator"); + assertFalse(preCheck1.equals(preCheck2)); + preCheck1.setPrecheckOperator("precheckOperator"); + assertFalse(preCheck1.equals(preCheck2)); + preCheck2.setPrecheckOperator("precheckOperator"); + List precheckOptions = new ArrayList<>(); + precheckOptions.add(new PrecheckOption()); + preCheck2.setPrecheckOptions(new ArrayList()); + assertFalse(preCheck1.equals(preCheck2)); + preCheck1.setPrecheckOptions(precheckOptions); + assertFalse(preCheck1.equals(preCheck2)); + preCheck2.setPrecheckOptions(precheckOptions); + assertTrue(preCheck1.equals(preCheck2)); } - } -- cgit 1.2.3-korg