unit tests - catalog-model 21/94221/2
authorTomasz Golabek <tomasz.golabek@nokia.com>
Fri, 23 Aug 2019 14:06:13 +0000 (16:06 +0200)
committerPiotr Darosz <piotr.darosz@nokia.com>
Mon, 26 Aug 2019 05:37:05 +0000 (05:37 +0000)
Additional junit tests

Change-Id: I82f88ec4cc1fb18314cfb33dd9aafa58688318e0
Issue-ID: SDC-2326
Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInterface.java
catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceInterfaceBeanTest.java [new file with mode: 0644]
catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationInputTest.java [new file with mode: 0644]
catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationInstanceTest.java [new file with mode: 0644]
catalog-model/src/test/java/org/openecomp/sdc/be/model/utils/TypeCompareUtilsTest.java [new file with mode: 0644]

index 5482a51..c5a0080 100644 (file)
@@ -16,6 +16,7 @@
 
 package org.openecomp.sdc.be.model;
 
+import com.google.common.annotations.VisibleForTesting;
 import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.InterfaceInstanceDataDefinition;
 
@@ -23,6 +24,9 @@ public class ComponentInstanceInterface extends InterfaceDefinition {
   private String interfaceId;
   private InterfaceInstanceDataDefinition interfaceInstanceDataDefinition;
 
+  @VisibleForTesting
+  ComponentInstanceInterface() {}
+
   public ComponentInstanceInterface(String interfaceId,
                                     InterfaceInstanceDataDefinition interfaceInstanceDataDefinition) {
     this.interfaceId = interfaceId;
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceInterfaceBeanTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceInterfaceBeanTest.java
new file mode 100644 (file)
index 0000000..044e9e0
--- /dev/null
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.InterfaceInstanceDataDefinition;
+
+public class ComponentInstanceInterfaceBeanTest {
+
+    private static final String INTERFACE_ID = "interfaceId";
+    private static final InterfaceDataDefinition INTERFACE_DATA_DEFINITION = new InterfaceDataDefinition();
+    private static final InterfaceInstanceDataDefinition INTERFACE_INSTANCE_DATA_DEFINITION = new InterfaceInstanceDataDefinition();
+    private static final String ID = "ID";
+
+    @Test
+    public void shouldHaveValidGettersAndSetters() {
+        assertThat(ComponentInstanceInterface.class,
+            hasValidGettersAndSettersExcluding(
+                "definition",
+                "ownerIdIfEmpty",
+                "empty",
+                "operationsMap",
+                "version"));
+    }
+
+    @Test
+    public void verifyConstructors() {
+        INTERFACE_DATA_DEFINITION.setUniqueId(ID);
+        ComponentInstanceInterface componentInstanceInterface1 = new ComponentInstanceInterface(INTERFACE_ID,
+            INTERFACE_DATA_DEFINITION);
+        ComponentInstanceInterface componentInstanceInterface2 = new ComponentInstanceInterface(INTERFACE_ID,
+            INTERFACE_INSTANCE_DATA_DEFINITION);
+
+        assertEquals(componentInstanceInterface1.getInterfaceId(), INTERFACE_ID);
+        assertEquals(componentInstanceInterface2.getInterfaceId(), INTERFACE_ID);
+        assertEquals(componentInstanceInterface1.getUniqueId(), ID);
+        assertEquals(componentInstanceInterface2.getInterfaceInstanceDataDefinition(), INTERFACE_INSTANCE_DATA_DEFINITION);
+    }
+}
\ No newline at end of file
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationInputTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationInputTest.java
new file mode 100644 (file)
index 0000000..91d0a21
--- /dev/null
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Collections;
+import java.util.List;
+import org.junit.Test;
+import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
+
+public class OperationInputTest {
+
+    private static final String NAME = "NAME";
+
+    @Test
+    public void shouldHaveValidGettersAndSetters() {
+        OperationInputDefinition operationInputDefinition = new OperationInputDefinition();
+        operationInputDefinition.setName(NAME);
+        OperationInput operationInput = new OperationInput(operationInputDefinition);
+        List<PropertyConstraint> constraints = Collections.emptyList();
+        operationInput.setConstraints(constraints);
+        assertEquals(operationInput.getConstraints(), constraints);
+        assertEquals(operationInput.getName(), operationInputDefinition.getName());
+    }
+}
\ No newline at end of file
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationInstanceTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationInstanceTest.java
new file mode 100644 (file)
index 0000000..199f265
--- /dev/null
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEquals;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+public class OperationInstanceTest {
+    @Test
+    public void shouldHaveValidGettersAndSetters() {
+        assertThat(OperationInstance.class, hasValidGettersAndSetters());
+        assertThat(OperationInstance.class, hasValidBeanEquals());
+    }
+}
\ No newline at end of file
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/utils/TypeCompareUtilsTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/utils/TypeCompareUtilsTest.java
new file mode 100644 (file)
index 0000000..d757b0e
--- /dev/null
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.utils;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.Collections;
+import org.junit.Test;
+import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
+import org.openecomp.sdc.be.model.GroupTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.RelationshipTypeDefinition;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+
+public class TypeCompareUtilsTest {
+
+    @Test
+    public void checkTypeAlreadyExists() {
+        assertEquals(TypeCompareUtils.typeAlreadyExists().right().value(), StorageOperationStatus.OK);
+    }
+
+    @Test
+    public void checkGroupTypesEquality() {
+        GroupTypeDefinition object1 = new GroupTypeDefinition();
+        GroupTypeDefinition object2 = new GroupTypeDefinition();
+        assertTrue(TypeCompareUtils.isGroupTypesEquals(object1, object1));
+        assertTrue(TypeCompareUtils.isGroupTypesEquals(object1, object2));
+        assertFalse(TypeCompareUtils.isGroupTypesEquals(object1, null));
+    }
+
+    @Test
+    public void checkCapabilityTypesEquality() {
+        CapabilityTypeDefinition object1 = new CapabilityTypeDefinition();
+        CapabilityTypeDefinition object2 = new CapabilityTypeDefinition();
+        assertTrue(TypeCompareUtils.isCapabilityTypesEquals(object1, object1));
+        assertTrue(TypeCompareUtils.isCapabilityTypesEquals(object1, object2));
+        assertFalse(TypeCompareUtils.isCapabilityTypesEquals(object1, null));
+    }
+
+    @Test
+    public void checkRelationshipTypesEquality() {
+        RelationshipTypeDefinition object1 = new RelationshipTypeDefinition();
+        RelationshipTypeDefinition object2 = new RelationshipTypeDefinition();
+        assertTrue(TypeCompareUtils.isRelationshipTypesEquals(object1, object1));
+        assertTrue(TypeCompareUtils.isRelationshipTypesEquals(object1, object2));
+        assertFalse(TypeCompareUtils.isRelationshipTypesEquals(object1, null));
+    }
+
+    @Test
+    public void checkPropertyDefinitionEquality() {
+        PropertyDefinition object1 = new PropertyDefinition();
+        PropertyDefinition object2 = new PropertyDefinition();
+        assertTrue(TypeCompareUtils.propertiesEquals(
+            Collections.singletonList(object1), Collections.singletonList(object1)));
+        assertTrue(TypeCompareUtils.propertiesEquals(
+            Collections.singletonList(object1), Collections.singletonList(object2)));
+        assertFalse(TypeCompareUtils.propertiesEquals(
+            Collections.singletonList(object1), null));
+    }
+}
\ No newline at end of file