diff options
author | Joss Armstrong <joss.armstrong@ericsson.com> | 2019-02-26 12:40:24 +0000 |
---|---|---|
committer | Takamune Cho <takamune.cho@att.com> | 2019-02-26 17:51:10 +0000 |
commit | 7ebe54041c04f938cf58fdec9e120347e64c543a (patch) | |
tree | 7f4e20f970241ea70888277be605531691627580 | |
parent | 76c431ff25d09b69ea912f53ca96cbcdcb52a3fb (diff) |
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 <joss.armstrong@ericsson.com>
-rw-r--r-- | appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/data/PreCheckTest.java | 33 |
1 files changed, 23 insertions, 10 deletions
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<PrecheckOption> 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<PrecheckOption> 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<PrecheckOption> precheckOptions = new ArrayList<>(); + precheckOptions.add(new PrecheckOption()); + preCheck2.setPrecheckOptions(new ArrayList<PrecheckOption>()); + assertFalse(preCheck1.equals(preCheck2)); + preCheck1.setPrecheckOptions(precheckOptions); + assertFalse(preCheck1.equals(preCheck2)); + preCheck2.setPrecheckOptions(precheckOptions); + assertTrue(preCheck1.equals(preCheck2)); } - } |