summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorm.kowalski3 <m.kowalski3@partner.samsung.com>2019-06-06 11:27:31 +0200
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-06-17 07:15:32 +0000
commit252c038ef883fbb3f22e0fb4cb05cac075820fb1 (patch)
tree69aad9e6fec0aaacec4a4610d948827f62b72fbc /src/test
parentfee6481d671d6ae2772a39ff824d1ef38329fc07 (diff)
Add unit test for RequirementDeserializer
Issue-ID: SDC-2327 Signed-off-by: Marcin Kowalski <m.kowalski3@partner.samsung.com> Change-Id: I494a4942dd51c5129d9b6def69ee9ca62e479f93
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/sdc/dcae/composition/model/deserializer/RequirementDeserializerTest.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/test/java/org/onap/sdc/dcae/composition/model/deserializer/RequirementDeserializerTest.java b/src/test/java/org/onap/sdc/dcae/composition/model/deserializer/RequirementDeserializerTest.java
new file mode 100644
index 0000000..463ce7f
--- /dev/null
+++ b/src/test/java/org/onap/sdc/dcae/composition/model/deserializer/RequirementDeserializerTest.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Samsung. All rights reserved.
+ * ================================================================================
+ * 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============================================
+ * ===================================================================
+ */
+
+package org.onap.sdc.dcae.composition.model.deserializer;
+
+import static org.junit.Assert.assertEquals;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import org.junit.Test;
+import org.onap.sdc.dcae.composition.model.Requirement;
+
+public class RequirementDeserializerTest {
+
+
+ @Test
+ public void testDeserialize() {
+ //given
+ RequirementDeserializer requirementDeserializer = new RequirementDeserializer();
+ String jsonString = "{\n" + " \"occurrences\": [\n 1,\n 2,\n 3\n ],\n"
+ + " \"capability\": {\n \"name\": \"name\",\n \"id\": \"id\"\n"
+ + " },\n \"name\": \"name\",\n \"relationship\": {\n"
+ + " \"type\": \"type\"\n }, \"node\": \"nodeName\"\n}";
+ JsonElement jsonElement = new JsonParser().parse(jsonString);
+
+ //when
+ Requirement requirement = requirementDeserializer.deserialize(jsonElement, null, null);
+
+ //then
+ assertEquals(requirement.getOccurrences().get(0), "1");
+ assertEquals(requirement.getOccurrences().get(1), "2");
+ assertEquals(requirement.getOccurrences().get(2), "3");
+ assertEquals(requirement.getName(), "name");
+ assertEquals(requirement.getCapability().getId(), "id");
+ assertEquals(requirement.getCapability().getName(), "name");
+ assertEquals(requirement.getRelationship().getType(), "type");
+ assertEquals(requirement.getNodeFilter(), null);
+ assertEquals(requirement.getNode(), "nodeName");
+ }
+}