aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2020-03-26 17:25:54 +0000
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-03-30 05:11:15 +0000
commitee80eb11d8ace0117ea1084c5ac16d8d271b8fd9 (patch)
tree7fb61496a0fc01087fb2760da4bc9ff044b21a8b /catalog-model/src
parent7422f22140b7ce24e3e735dabaa325e2f7a4fc92 (diff)
Increase test coverage
Change-Id: If9b371042a42213f38828f9628714d076261f25c Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-2833
Diffstat (limited to 'catalog-model/src')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/category/CategoryDefinition.java28
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/category/GroupingDefinition.java5
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/category/SubCategoryDefinition.java29
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/SerializedHashMap.java8
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/unittests/utils/FactoryUtils.java9
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/category/CategoryDefinitionTest.java63
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/category/GroupingDefinitionTest.java40
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/category/SubCategoryDefinitionTest.java65
8 files changed, 102 insertions, 145 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/category/CategoryDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/category/CategoryDefinition.java
index d943fb0a05..44a0362a41 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/category/CategoryDefinition.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/category/CategoryDefinition.java
@@ -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.
@@ -20,11 +20,18 @@
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 + "]";
- }
-
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/category/GroupingDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/category/GroupingDefinition.java
index 8d839332fe..f8436db7db 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/category/GroupingDefinition.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/category/GroupingDefinition.java
@@ -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) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/category/SubCategoryDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/category/SubCategoryDefinition.java
index c9ae3ac5c5..ed7b490b54 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/category/SubCategoryDefinition.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/category/SubCategoryDefinition.java
@@ -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.
@@ -20,31 +20,29 @@
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 + "]";
- }
-
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/SerializedHashMap.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/SerializedHashMap.java
index d193f9ecdb..5e73ee95e2 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/SerializedHashMap.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/SerializedHashMap.java
@@ -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
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/unittests/utils/FactoryUtils.java b/catalog-model/src/main/java/org/openecomp/sdc/be/unittests/utils/FactoryUtils.java
index f83d888bd9..79f5b80953 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/unittests/utils/FactoryUtils.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/unittests/utils/FactoryUtils.java
@@ -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;
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/category/CategoryDefinitionTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/category/CategoryDefinitionTest.java
index d522b6d94f..db26e6ed22 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/category/CategoryDefinitionTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/category/CategoryDefinitionTest.java
@@ -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.
@@ -20,58 +20,25 @@
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
index 0000000000..a06d3fed48
--- /dev/null
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/category/GroupingDefinitionTest.java
@@ -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
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/category/SubCategoryDefinitionTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/category/SubCategoryDefinitionTest.java
index 7a42c870f5..f2fc17844f 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/category/SubCategoryDefinitionTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/category/SubCategoryDefinitionTest.java
@@ -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.
@@ -20,58 +20,23 @@
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();
+ }
}