Increase test coverage 24/104524/3
authorvasraz <vasyl.razinkov@est.tech>
Thu, 26 Mar 2020 17:25:54 +0000 (17:25 +0000)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Mon, 30 Mar 2020 05:11:15 +0000 (05:11 +0000)
Change-Id: If9b371042a42213f38828f9628714d076261f25c
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Issue-ID: SDC-2833

catalog-model/src/main/java/org/openecomp/sdc/be/model/category/CategoryDefinition.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/category/GroupingDefinition.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/category/SubCategoryDefinition.java
catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/SerializedHashMap.java
catalog-model/src/main/java/org/openecomp/sdc/be/unittests/utils/FactoryUtils.java
catalog-model/src/test/java/org/openecomp/sdc/be/model/category/CategoryDefinitionTest.java
catalog-model/src/test/java/org/openecomp/sdc/be/model/category/GroupingDefinitionTest.java [new file with mode: 0644]
catalog-model/src/test/java/org/openecomp/sdc/be/model/category/SubCategoryDefinitionTest.java

index d943fb0..44a0362 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
 
 package org.openecomp.sdc.be.model.category;
 
-import org.openecomp.sdc.be.datatypes.category.CategoryDataDefinition;
-
 import java.util.ArrayList;
 import java.util.List;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.openecomp.sdc.be.datatypes.category.CategoryDataDefinition;
 
+@Getter
+@Setter
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
 public class CategoryDefinition extends CategoryDataDefinition {
 
     private List<SubCategoryDefinition> subcategories;
@@ -37,14 +44,6 @@ public class CategoryDefinition extends CategoryDataDefinition {
         super(c);
     }
 
-    public List<SubCategoryDefinition> getSubcategories() {
-        return subcategories;
-    }
-
-    public void setSubcategories(List<SubCategoryDefinition> subcategories) {
-        this.subcategories = subcategories;
-    }
-
     public void addSubCategory(SubCategoryDefinition subcategory) {
         if (subcategories == null) {
             subcategories = new ArrayList<>();
@@ -52,9 +51,4 @@ public class CategoryDefinition extends CategoryDataDefinition {
         subcategories.add(subcategory);
     }
 
-    @Override
-    public String toString() {
-        return super.toString() + " CategoryDefinition [subcategories=" + subcategories + "]";
-    }
-
 }
index 8d83933..f8436db 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -25,7 +25,6 @@ import org.openecomp.sdc.be.datatypes.category.GroupingDataDefinition;
 public class GroupingDefinition extends GroupingDataDefinition {
 
     public GroupingDefinition() {
-        super();
     }
 
     public GroupingDefinition(GroupingDataDefinition g) {
index c9ae3ac..ed7b490 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
 
 package org.openecomp.sdc.be.model.category;
 
-import org.openecomp.sdc.be.datatypes.category.SubCategoryDataDefinition;
-
 import java.util.ArrayList;
 import java.util.List;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.openecomp.sdc.be.datatypes.category.SubCategoryDataDefinition;
 
+@Getter
+@Setter
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
 public class SubCategoryDefinition extends SubCategoryDataDefinition {
 
     private List<GroupingDefinition> groupings;
 
     public SubCategoryDefinition() {
-        super();
     }
 
     public SubCategoryDefinition(SubCategoryDataDefinition subCategory) {
         super(subCategory);
     }
 
-    public List<GroupingDefinition> getGroupings() {
-        return groupings;
-    }
-
-    public void setGroupings(List<GroupingDefinition> groupingDefinitions) {
-        this.groupings = groupingDefinitions;
-    }
-
     public void addGrouping(GroupingDefinition groupingDefinition) {
         if (groupings == null) {
             groupings = new ArrayList<>();
@@ -52,9 +50,4 @@ public class SubCategoryDefinition extends SubCategoryDataDefinition {
         groupings.add(groupingDefinition);
     }
 
-    @Override
-    public String toString() {
-        return super.toString() + " SubCategoryDefinition [groupings=" + groupings + "]";
-    }
-
 }
index d193f9e..5e73ee9 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -21,7 +21,9 @@
 package org.openecomp.sdc.be.ui.model;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
-public class SerializedHashMap<T,R>  extends java.util.HashMap<T,R> {
+import java.util.HashMap;
+
+public class SerializedHashMap<T, R> extends HashMap<T, R> {
 
     @JsonIgnore
     @Override
index f83d888..79f5b80 100644 (file)
@@ -35,14 +35,11 @@ import java.util.UUID;
 
 public final class FactoryUtils {
     private static final String STRING = "string";
+    private static final String DEFAULT_CAPABILITY_TYPE = "tosca.capabilities.Node";
 
        private FactoryUtils() {
     }
 
-    public static final class Constants {
-        public static final String DEFAULT_CAPABILITY_TYPE = "tosca.capabilities.Node";
-    }
-
     public static Resource createVFWithRI(String riVersion) {
         Resource vf = createVF();
         ComponentInstance ri = createResourceInstanceWithVersion(riVersion);
@@ -96,7 +93,7 @@ public final class FactoryUtils {
         String uniqueId = UUID.randomUUID().toString();
         capData.setUniqueId(uniqueId);
 
-        capData.setType(Constants.DEFAULT_CAPABILITY_TYPE);
+        capData.setType(DEFAULT_CAPABILITY_TYPE);
         return capData;
     }
 
@@ -171,7 +168,7 @@ public final class FactoryUtils {
     public static RequirementDefinition convertRequirementDataIDToRequirementDefinition(String reqDataId) {
         RequirementDefinition reqDef = new RequirementDefinition();
         reqDef.setUniqueId(reqDataId);
-        reqDef.setCapability(Constants.DEFAULT_CAPABILITY_TYPE);
+        reqDef.setCapability(DEFAULT_CAPABILITY_TYPE);
         return reqDef;
     }
 
index d522b6d..db26e6e 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
 
 package org.openecomp.sdc.be.model.category;
 
-import java.util.List;
-
+import org.assertj.core.api.Assertions;
 import org.junit.Test;
 
 
 public class CategoryDefinitionTest {
 
-       private CategoryDefinition createTestSubject() {
-               return new CategoryDefinition();
-       }
-
-       
-       @Test
-       public void testGetSubcategories() throws Exception {
-               CategoryDefinition testSubject;
-               List<SubCategoryDefinition> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getSubcategories();
-       }
-
-       
-       @Test
-       public void testSetSubcategories() throws Exception {
-               CategoryDefinition testSubject;
-               List<SubCategoryDefinition> subcategories = null;
-
-               // default test
-               testSubject = createTestSubject();
-               testSubject.setSubcategories(subcategories);
-       }
-
-       
-       @Test
-       public void testAddSubCategory() throws Exception {
-               CategoryDefinition testSubject;
-               SubCategoryDefinition subcategory = null;
+    private CategoryDefinition createTestSubject() {
+        return new CategoryDefinition();
+    }
 
-               // default test
-               testSubject = createTestSubject();
-               testSubject.addSubCategory(subcategory);
-       }
+    @Test
+    public void testAddSubCategory() throws Exception {
+        final CategoryDefinition testSubject;
+        final SubCategoryDefinition subcategory = new SubCategoryDefinition();
 
-       
-       @Test
-       public void testToString() throws Exception {
-               CategoryDefinition testSubject;
-               String result;
+        // default test
+        testSubject = createTestSubject();
+        testSubject.addSubCategory(subcategory);
+        Assertions.assertThat(testSubject.getSubcategories()).isNotNull().isNotEmpty();
+    }
 
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.toString();
-       }
 }
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/category/GroupingDefinitionTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/category/GroupingDefinitionTest.java
new file mode 100644 (file)
index 0000000..a06d3fe
--- /dev/null
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020, Nordix Foundation. 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.openecomp.sdc.be.model.category;
+
+import org.assertj.core.api.Assertions;
+import org.junit.Test;
+import org.openecomp.sdc.be.datatypes.category.GroupingDataDefinition;
+
+public class GroupingDefinitionTest {
+
+    @Test
+    public void testCtor() {
+        final GroupingDefinition testSubject = new GroupingDefinition();
+        Assertions.assertThat(testSubject).isNotNull().isInstanceOf(GroupingDefinition.class);
+    }
+
+    @Test
+    public void testClone() {
+        final GroupingDefinition testSubject = new GroupingDefinition(new GroupingDataDefinition());
+        Assertions.assertThat(testSubject).isNotNull().isInstanceOf(GroupingDefinition.class);
+    }
+}
\ No newline at end of file
index 7a42c87..f2fc178 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
 
 package org.openecomp.sdc.be.model.category;
 
-import java.util.List;
-
 import org.junit.Test;
-
+import org.assertj.core.api.Assertions;
 
 public class SubCategoryDefinitionTest {
 
-       private SubCategoryDefinition createTestSubject() {
-               return new SubCategoryDefinition();
-       }
-
-       
-       @Test
-       public void testGetGroupings() throws Exception {
-               SubCategoryDefinition testSubject;
-               List<GroupingDefinition> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getGroupings();
-       }
-
-       
-       @Test
-       public void testSetGroupings() throws Exception {
-               SubCategoryDefinition testSubject;
-               List<GroupingDefinition> groupingDefinitions = null;
-
-               // default test
-               testSubject = createTestSubject();
-               testSubject.setGroupings(groupingDefinitions);
-       }
-
-       
-       @Test
-       public void testAddGrouping() throws Exception {
-               SubCategoryDefinition testSubject;
-               GroupingDefinition groupingDefinition = null;
-
-               // default test
-               testSubject = createTestSubject();
-               testSubject.addGrouping(groupingDefinition);
-       }
+    private SubCategoryDefinition createTestSubject() {
+        return new SubCategoryDefinition();
+    }
 
-       
-       @Test
-       public void testToString() throws Exception {
-               SubCategoryDefinition testSubject;
-               String result;
+    @Test
+    public void testAddGrouping() throws Exception {
+        final SubCategoryDefinition testSubject;
+        final GroupingDefinition groupingDefinition = new GroupingDefinition();
 
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.toString();
-       }
+        // default test
+        testSubject = createTestSubject();
+        testSubject.addGrouping(groupingDefinition);
+               Assertions.assertThat(testSubject.getGroupings()).isNotNull().isNotEmpty();
+    }
 }