From 1e80f98e25442b4badf570fd6ca652c21e499e28 Mon Sep 17 00:00:00 2001 From: waynedunican Date: Thu, 9 Jul 2020 13:03:28 +0100 Subject: Remove try/catch blocks with assertj - apex-pdp Removed try/catch blocks in apex-pdp and replaced with assertj assertions Part III Issue-ID: POLICY-2451 Change-Id: I1e6ede1c256c5bcf7899e1af130add71fdf1381c Signed-off-by: waynedunican --- .../apex/model/policymodel/concepts/LogicTest.java | 29 ++++++---------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'model/policy-model/src/test/java/org') diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java index 655df059a..7961d8e8e 100644 --- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java +++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java @@ -21,6 +21,7 @@ package org.onap.policy.apex.model.policymodel.concepts; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; @@ -103,21 +104,11 @@ public class LogicTest { result = logic.validate(result); assertEquals(ValidationResult.VALID, result.getValidationResult()); - try { - logic.setLogicFlavour(null); - fail("test shold throw an exception here"); - } catch (final Exception e) { - assertEquals("parameter \"logicFlavour\" is null", e.getMessage()); - } - - try { - logic.setLogicFlavour(""); - fail("test shold throw an exception here"); - } catch (final Exception e) { - assertEquals("parameter \"logicFlavour\": value \"\", " - + "does not match regular expression \"[A-Za-z0-9\\-_]+\"", e.getMessage()); - } - + assertThatThrownBy(() -> logic.setLogicFlavour(null)) + .hasMessageContaining("parameter \"logicFlavour\" is null"); + assertThatThrownBy(() -> logic.setLogicFlavour("")) + .hasMessage("parameter \"logicFlavour\": value \"\", " + + "does not match regular expression \"[A-Za-z0-9\\-_]+\""); logic.setLogicFlavour(AxLogic.LOGIC_FLAVOUR_UNDEFINED); result = new AxValidationResult(); result = logic.validate(result); @@ -128,13 +119,7 @@ public class LogicTest { result = logic.validate(result); assertEquals(ValidationResult.VALID, result.getValidationResult()); - try { - logic.setLogic(null); - fail("test shold throw an exception here"); - } catch (final Exception e) { - assertEquals("logic may not be null", e.getMessage()); - } - + assertThatThrownBy(() -> logic.setLogic(null)).hasMessage("logic may not be null"); logic.setLogic(""); result = new AxValidationResult(); result = logic.validate(result); -- cgit 1.2.3-korg