diff options
author | Tomasz Golabek <tomasz.golabek@nokia.com> | 2019-08-23 16:06:13 +0200 |
---|---|---|
committer | Piotr Darosz <piotr.darosz@nokia.com> | 2019-08-26 05:37:05 +0000 |
commit | bdfd60b4871f205746b136c43cfc4be1470db957 (patch) | |
tree | 5d7c64c3fd88ace43a9d7a497c78fe801e3de40c /catalog-model/src/test | |
parent | 86e5ac595936cffc37030ec8cf6f5d1cc98073e2 (diff) |
unit tests - catalog-model
Additional junit tests
Change-Id: I82f88ec4cc1fb18314cfb33dd9aafa58688318e0
Issue-ID: SDC-2326
Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
Diffstat (limited to 'catalog-model/src/test')
4 files changed, 217 insertions, 0 deletions
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 index 0000000000..044e9e0c57 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstanceInterfaceBeanTest.java @@ -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 index 0000000000..91d0a219c5 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationInputTest.java @@ -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 index 0000000000..199f26500a --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/OperationInstanceTest.java @@ -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 index 0000000000..d757b0ec88 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/utils/TypeCompareUtilsTest.java @@ -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 |