diff options
author | Eran (ev672n), Vosk <ev672n@att.com> | 2018-11-01 14:33:14 +0200 |
---|---|---|
committer | Eran (ev672n), Vosk <ev672n@att.com> | 2018-11-01 14:33:14 +0200 |
commit | c6fe4a8796faaa3ff85d7e47f6e5b8bce2d1b51f (patch) | |
tree | 987c1d7ace2de22ff7991db8f70eb33894e3003e /src/test/java | |
parent | 446286494f4b23f221aef20507807a6b5a86b157 (diff) |
Adding more UTscasablanca
Raising the code coverage in the project
Change-Id: I4561f75db959bbea12310c08965bacb544cb1f7a
Issue-ID: SDC-1872
Signed-off-by: Eran (ev672n), Vosk <ev672n@att.com>
Diffstat (limited to 'src/test/java')
5 files changed, 155 insertions, 2 deletions
diff --git a/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/ConditionDeserializerTest.java b/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/ConditionDeserializerTest.java new file mode 100644 index 0000000..42c2ecb --- /dev/null +++ b/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/ConditionDeserializerTest.java @@ -0,0 +1,28 @@ +package org.onap.sdc.dcae.composition.restmodels.ruleeditor; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import org.junit.Test; + +import java.util.ArrayList; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class ConditionDeserializerTest { + + private Gson gson = new GsonBuilder().registerTypeAdapter(BaseCondition.class, new ConditionDeserializer()).create(); + + @Test + public void deserializerTest(){ + Condition condition = new Condition(); + condition.setLeft("map"); + condition.setRight(new ArrayList<>()); + condition.setOperator("test"); + condition.setEmptyIsAssigned(true); + String input = gson.toJson(condition); + BaseCondition res = gson.fromJson(input, BaseCondition.class); + assertEquals(gson.toJson(res), input); + assertTrue(res instanceof Condition); + } +} diff --git a/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/DateFormatterActionTest.java b/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/DateFormatterActionTest.java new file mode 100644 index 0000000..defec7f --- /dev/null +++ b/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/DateFormatterActionTest.java @@ -0,0 +1,28 @@ +package org.onap.sdc.dcae.composition.restmodels.ruleeditor; + +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class DateFormatterActionTest { + private DateFormatterAction classUnderTest = new DateFormatterAction(); + + @Test + public void checkEqualsTrueOther() { + DateFormatterAction dateFormatterAction = new DateFormatterAction(); + assertTrue(classUnderTest.equals(dateFormatterAction)); + } + + @Test + public void checkEqualsTrueSame() { + assertTrue(classUnderTest.equals(classUnderTest)); + } + + @Test + public void checkEqualsFalse() { + assertFalse(classUnderTest.equals(null)); + } + + +} diff --git a/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/MapActionTest.java b/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/MapActionTest.java new file mode 100644 index 0000000..7a3c9a1 --- /dev/null +++ b/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/MapActionTest.java @@ -0,0 +1,27 @@ +package org.onap.sdc.dcae.composition.restmodels.ruleeditor; + +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class MapActionTest { + private MapAction classUnderTest = new MapAction(); + + @Test + public void checkEqualsTrueOther() { + MapAction equalMapAction = new MapAction(); + assertTrue(classUnderTest.equals(equalMapAction)); + } + + @Test + public void checkEqualsTrueSame() { + assertTrue(classUnderTest.equals(classUnderTest)); + } + + @Test + public void checkEqualsFalse() { + assertFalse(classUnderTest.equals(null)); + } + +} diff --git a/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/MappingRulesTest.java b/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/MappingRulesTest.java index 705ef6a..ae87b57 100644 --- a/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/MappingRulesTest.java +++ b/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/MappingRulesTest.java @@ -5,8 +5,7 @@ import org.junit.Test; import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanHashCodeFor; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.*; public class MappingRulesTest { @@ -38,6 +37,38 @@ public class MappingRulesTest { } @Test + public void getRulesTest() { + classUnderTest.addOrReplaceRule(new Rule()); + assertEquals(1, classUnderTest.getRules().size()); + } + + @Test + public void containsRulesTest() { + Rule rule = new Rule(); + assertFalse(classUnderTest.ruleExists(rule)); + assertTrue(classUnderTest.isEmpty()); + classUnderTest.addOrReplaceRule(rule); + assertTrue(classUnderTest.ruleExists(rule)); + assertFalse(classUnderTest.isEmpty()); + } + + @Test + public void checkEqualsTrueOther() { + MappingRules equalMappingRules = new MappingRules(); + assertTrue(classUnderTest.equals(equalMappingRules)); + } + + @Test + public void checkEqualsTrueSame() { + assertTrue(classUnderTest.equals(classUnderTest)); + } + + @Test + public void checkEqualsFalse() { + assertFalse(classUnderTest.equals(null)); + } + + @Test public void testHasValidConstructor() { assertThat(MappingRules.class, hasValidBeanConstructor()); } diff --git a/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/RuleTest.java b/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/RuleTest.java new file mode 100644 index 0000000..27f8185 --- /dev/null +++ b/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/RuleTest.java @@ -0,0 +1,39 @@ +package org.onap.sdc.dcae.composition.restmodels.ruleeditor; + +import org.junit.Test; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanHashCodeFor; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +public class RuleTest { + private Rule classUnderTest = new Rule(); + + @Test + public void checkEqualsTrueOther() { + Rule equalRule = new Rule(); + assertTrue(classUnderTest.equals(equalRule)); + } + + @Test + public void checkEqualsTrueSame() { + assertTrue(classUnderTest.equals(classUnderTest)); + } + + @Test + public void checkEqualsFalse() { + assertFalse(classUnderTest.equals(null)); + } + + @Test + public void testHasValidConstructor() { + assertThat(Rule.class, hasValidBeanConstructor()); + } + + @Test + public void checkHashCodeFor() { + assertThat(Rule.class, hasValidBeanHashCodeFor()); + } +} |