diff options
author | m.kowalski3 <m.kowalski3@partner.samsung.com> | 2019-06-14 15:17:03 +0200 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2019-06-17 07:17:35 +0000 |
commit | 6159cb862e49b2ab8b06c11b159681beaf7cbd89 (patch) | |
tree | a55e70cbdfd06bc52a10956a4a4018aef4d18f53 /src/test | |
parent | 1785dedb0251c6f08bc6d5f97cc6811251a3d4c5 (diff) |
Improve unit tests for MapAction
Issue-ID: SDC-2327
Signed-off-by: Marcin Kowalski <m.kowalski3@partner.samsung.com>
Change-Id: I15e555c6c65fa2ba253d53a67d00d895668b22f9
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/MapActionTest.java | 68 |
1 files changed, 62 insertions, 6 deletions
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 index 7a3c9a1..1a21d50 100644 --- 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 @@ -1,27 +1,83 @@ -package org.onap.sdc.dcae.composition.restmodels.ruleeditor; +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * 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. + * ============LICENSE_END=========================================== + * =================================================================== + * + */ -import org.junit.Test; +package org.onap.sdc.dcae.composition.restmodels.ruleeditor; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import java.util.List; +import org.junit.Before; +import org.junit.Test; + + public class MapActionTest { - private MapAction classUnderTest = new MapAction(); + + private MapAction mapAction; + + private static Gson gson = new GsonBuilder().registerTypeAdapter(BaseAction.class, new ActionDeserializer()) + .registerTypeAdapter(BaseCondition.class, new ConditionDeserializer()).create(); + + @Before + public void setup() { + String json = + "{\"map\":{\"default\":\"defaultValue\",\"haveDefault\":true,\"values\":[{\"UIHashMap\":{\"key\":\"val\"}}]}}"; + mapAction = gson.fromJson(json, MapAction.class); + } @Test public void checkEqualsTrueOther() { MapAction equalMapAction = new MapAction(); - assertTrue(classUnderTest.equals(equalMapAction)); + assertTrue(equalMapAction.equals(new MapAction())); } @Test public void checkEqualsTrueSame() { - assertTrue(classUnderTest.equals(classUnderTest)); + assertTrue(mapAction.equals(mapAction)); } @Test public void checkEqualsFalse() { - assertFalse(classUnderTest.equals(null)); + assertFalse(mapAction.equals(null)); + } + + @Test + public void testMapHasDefault() { + assertTrue(mapAction.mapHasDefault()); + } + + @Test + public void testGetMapDefaultValue() { + String defaultValue = mapAction.getMapDefaultValue(); + assertEquals("defaultValue", defaultValue); + } + + @Test + public void testGetMapValues() { + List<BaseAction.UIHashMap> list = mapAction.getMapValues(); + assertEquals(1, list.size()); } } |