Unit-tests for mappers in item services 22/73022/2
authorvempo <vitaliy.emporopulo@amdocs.com>
Sat, 17 Nov 2018 16:58:36 +0000 (18:58 +0200)
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>
Mon, 19 Nov 2018 18:05:46 +0000 (18:05 +0000)
Change-Id: I44b2574a70f6ad357dd0528f9bf4b3608ec33063
Issue-ID: SDC-1917
Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
(cherry picked from commit 03fb4087901e4cf56b02f6a9456d987f28844a2f)

openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml
openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/test/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDtoTest.java [new file with mode: 0644]
openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/test/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDtoTest.java [new file with mode: 0644]
openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/test/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDtoTest.java [new file with mode: 0644]
openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/test/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDtoTest.java [new file with mode: 0644]

index 2afd375..afda696 100644 (file)
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-context</artifactId>
-            <version>${spring.framework.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
         </dependency>
     </dependencies>
 
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/test/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/test/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDtoTest.java
new file mode 100644 (file)
index 0000000..3bfc3f7
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.sdcrests.item.rest.mapping;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Date;
+import org.junit.Test;
+import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
+import org.openecomp.sdc.activitylog.dao.type.ActivityType;
+import org.openecomp.sdcrests.item.types.ActivityLogDto;
+
+/**
+ * This class was generated.
+ */
+public class MapActivityLogEntityToDtoTest {
+
+    @Test()
+    public void testConversion() {
+
+        final ActivityLogEntity source = new ActivityLogEntity();
+
+        final String id = "e8ad437b-8d86-4819-954f-57fb9161a912";
+        source.setId(id);
+
+        final ActivityType type = ActivityType.Upload_Artifact;
+        source.setType(type);
+
+        final String user = "278dbb70-469d-4a5f-bea2-bc62fa9d4671";
+        source.setUser(user);
+
+        final Date timestamp = new Date();
+        source.setTimestamp(timestamp);
+
+        final String comment = "1cf631a9-016b-4914-9ced-ded9d5ba9469";
+        source.setComment(comment);
+
+        final boolean success = true;
+        source.setSuccess(true);
+
+        final String message = "9b5e29e9-b47a-4ece-b8a0-b68f4b346e3b";
+        source.setMessage(message);
+
+        final ActivityLogDto target = new ActivityLogDto();
+        final MapActivityLogEntityToDto mapper = new MapActivityLogEntityToDto();
+        mapper.doMapping(source, target);
+
+        assertEquals(id, target.getId());
+        assertEquals(timestamp, target.getTimestamp());
+        assertEquals(type.name(), target.getType());
+        assertEquals(comment, target.getComment());
+        assertEquals(user, target.getUser());
+        assertEquals(success, target.getStatus().isSuccess());
+        assertEquals(message, target.getStatus().getMessage());
+    }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/test/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/test/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDtoTest.java
new file mode 100644 (file)
index 0000000..1de05e7
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.sdcrests.item.rest.mapping;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+import java.util.Collections;
+import java.util.Map;
+import org.junit.Test;
+import org.openecomp.sdc.versioning.types.Item;
+import org.openecomp.sdc.versioning.types.ItemStatus;
+import org.openecomp.sdcrests.item.types.ItemDto;
+
+/**
+ * This class was generated.
+ */
+public class MapItemToDtoTest {
+
+    @Test
+    public void testConversion() {
+
+        final Item source = new Item();
+
+        final String id = "8c3cf5c1-956d-4701-9805-41ee7496a4b0";
+        source.setId(id);
+
+        final String type = "0df6dc63-30a9-453c-9d20-ccd839b30e55";
+        source.setType(type);
+
+        final String name = "fa425317-c53a-4ad2-94f5-9a33f2b76e67";
+        source.setName(name);
+
+        final String owner = "db08f579-7f4c-4d1a-ae92-a1c1c27c8cc6";
+        source.setOwner(owner);
+
+        final ItemStatus status = ItemStatus.ARCHIVED;
+        source.setStatus(status);
+
+        final String description = "9b5e29e9-b47a-4ece-b8a0-b68f4b346e3b";
+        source.setDescription(description);
+
+        final Map<String, Object> properties = Collections.emptyMap();
+        source.setProperties(properties);
+
+        final ItemDto target = new ItemDto();
+        final MapItemToDto mapper = new MapItemToDto();
+        mapper.doMapping(source, target);
+
+        assertEquals(id, target.getId());
+        assertEquals(type, target.getType());
+        assertEquals(name, target.getName());
+        assertEquals(description, target.getDescription());
+        assertEquals(owner, target.getOwner());
+        assertEquals(status.name(), target.getStatus());
+        assertSame(properties, target.getProperties());
+    }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/test/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/test/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDtoTest.java
new file mode 100644 (file)
index 0000000..f9df209
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.sdcrests.item.rest.mapping;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Date;
+import org.junit.Test;
+import org.openecomp.sdc.versioning.dao.types.Revision;
+import org.openecomp.sdcrests.item.types.RevisionDto;
+
+/**
+ * This class was generated.
+ */
+public class MapRevisionToDtoTest {
+
+    @Test()
+    public void testConversion() {
+
+        final Revision source = new Revision();
+
+        final String id = "ecbf1a77-a420-4655-b2fc-e403a703036d";
+        source.setId(id);
+
+        final String message = "2f2a55c8-90b6-413c-bf31-168108e75cb3";
+        source.setMessage(message);
+
+        final Date time = new Date();
+        source.setTime(time);
+
+        final String user = "503cf667-028b-4d53-bf76-68ad85edf51d";
+        source.setUser(user);
+
+        final RevisionDto target = new RevisionDto();
+        final MapRevisionToDto mapper = new MapRevisionToDto();
+        mapper.doMapping(source, target);
+
+        assertEquals(id, target.getId());
+        assertEquals(message, target.getMessage());
+        assertEquals(time, target.getTime());
+        assertEquals(user, target.getUser());
+    }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/test/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/test/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDtoTest.java
new file mode 100644 (file)
index 0000000..706de57
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.sdcrests.item.rest.mapping;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.Map;
+import org.junit.Test;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionState;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+import org.openecomp.sdcrests.item.types.VersionDto;
+
+/**
+ * This class was generated.
+ */
+public class MapVersionToDtoTest {
+
+    @Test()
+    public void testConversion() {
+
+        final Version source = new Version();
+
+        final String id = "2cb11529-5b9c-4561-a6d6-9188d3df84d6";
+        source.setId(id);
+
+        final String name = "c9798995-750d-4759-99ac-7942b24e356a";
+        source.setName(name);
+
+        final String description = "269d595d-e818-41d0-a991-bf6dccab8125";
+        source.setDescription(description);
+
+        final String baseId = "d8efa2d7-8def-4646-8b9d-363ae102cde0";
+        source.setBaseId(baseId);
+
+        final Date creationTime = new Date();
+        source.setCreationTime(creationTime);
+
+        final Date modificationTime = new Date();
+        source.setModificationTime(modificationTime);
+
+        final VersionStatus status = VersionStatus.Deleted;
+        source.setStatus(status);
+
+        final VersionState state = new VersionState();
+        source.setState(state);
+
+        final Map<String, Object> additionalInfo = Collections.emptyMap();
+        source.setAdditionalInfo(additionalInfo);
+
+        final VersionDto target = new VersionDto();
+        final MapVersionToDto mapper = new MapVersionToDto();
+        mapper.doMapping(source, target);
+
+        assertEquals(id, target.getId());
+        assertEquals(name, target.getName());
+        assertEquals(description, target.getDescription());
+        assertEquals(baseId, target.getBaseId());
+        assertSame(status, target.getStatus());
+        assertSame(state, target.getState());
+        assertEquals(creationTime, target.getCreationTime());
+        assertEquals(modificationTime, target.getModificationTime());
+        assertSame(additionalInfo, target.getAdditionalInfo());
+    }
+}