From 7e28cea706ca5e0ca423fde637a7846eaaa2e1e0 Mon Sep 17 00:00:00 2001 From: Tomasz Golabek Date: Thu, 11 Apr 2019 14:29:49 +0200 Subject: Some unit tests for catalog-be Code coverage for some classes from catalog-be increased. Some refactor made if needed. Change-Id: Ia9348f624984ab7e5f9aa53c0adf33cf5867fa07 Issue-ID: SDC-2220 Signed-off-by: Tomasz Golabek --- .../openecomp/sdc/be/info/DistributionStatus.java | 25 +++-- .../openecomp/sdc/be/info/GroupDefinitionInfo.java | 14 +-- .../openecomp/sdc/be/info/GroupTemplateInfo.java | 4 +- .../sdc/be/info/NodeTypeInfoToUpdateArtifacts.java | 22 ++++ ...istributionStatusOfServiceListResponceTest.java | 29 ++++- .../sdc/be/info/DistributionStatusTest.java | 58 +++++----- .../sdc/be/info/GenericArtifactQueryInfoTest.java | 55 ++++++++++ .../sdc/be/info/GroupDefinitionInfoTest.java | 119 ++++++++++++++++++--- .../sdc/be/info/GroupTemplateInfoTest.java | 27 ++++- .../be/info/NodeTypeInfoToUpdateArtifactsTest.java | 78 +++++++------- .../sdc/be/info/RelationshipListTest.java | 40 +++++++ 11 files changed, 366 insertions(+), 105 deletions(-) create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/info/GenericArtifactQueryInfoTest.java create mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipListTest.java (limited to 'catalog-be/src') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/info/DistributionStatus.java b/catalog-be/src/main/java/org/openecomp/sdc/be/info/DistributionStatus.java index 11a42694bf..1aad998e78 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/info/DistributionStatus.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/info/DistributionStatus.java @@ -7,19 +7,23 @@ * 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========================================================= + * Modifications copyright (c) 2019 Nokia + * ================================================================================ */ package org.openecomp.sdc.be.info; +import java.util.Arrays; +import java.util.Optional; import org.openecomp.sdc.common.log.wrappers.Logger; public enum DistributionStatus { @@ -44,18 +48,13 @@ public enum DistributionStatus { } public static DistributionStatus getStatusByAuditingStatusName(String auditingStatus) { - DistributionStatus res = null; - DistributionStatus[] values = values(); - for (DistributionStatus value : values) { - if (value.getAuditingStatus().equals(auditingStatus)) { - res = value; - break; - } - } - if (res == null) { - log.debug("No DistributionStatus is mapped to name {}", auditingStatus); + Optional distributionStatus = Arrays.stream(values()) + .filter(value -> value.getAuditingStatus().equals(auditingStatus)).findAny(); + if (!distributionStatus.isPresent()){ + log.debug("No DistributionStatus is mapped to name {}", auditingStatus); } - return res; + // it should be replaced by some exception handling. Keeping it only for the purpose of backward compatibility + return distributionStatus.orElse(null); } } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupDefinitionInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupDefinitionInfo.java index e7a0706b31..621485c7a1 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupDefinitionInfo.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupDefinitionInfo.java @@ -7,17 +7,18 @@ * 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========================================================= + * Modifications copyright (c) 2019 Nokia + * ================================================================================ */ - package org.openecomp.sdc.be.info; import org.openecomp.sdc.be.model.GroupDefinition; @@ -62,9 +63,7 @@ public class GroupDefinitionInfo { private List properties; - public GroupDefinitionInfo() { - super(); - } + public GroupDefinitionInfo() {} public GroupDefinitionInfo(GroupDefinition other) { this.setName(other.getName()); @@ -139,7 +138,6 @@ public class GroupDefinitionInfo { this.version = version; } - public String getCustomizationUUID() { return customizationUUID; } @@ -172,8 +170,6 @@ public class GroupDefinitionInfo { this.properties = (properties==null) ? null : new ArrayList<>(properties); } - - public String getGroupInstanceUniqueId() { return groupInstanceUniqueId; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupTemplateInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupTemplateInfo.java index 301cffafdc..3ae0dcdf62 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupTemplateInfo.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupTemplateInfo.java @@ -25,9 +25,7 @@ public class GroupTemplateInfo { boolean isBase; ArtifactTemplateInfo artifactTemplateInfo; - public GroupTemplateInfo() { - super(); - } + public GroupTemplateInfo() {} public String getGroupName() { return groupName; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/info/NodeTypeInfoToUpdateArtifacts.java b/catalog-be/src/main/java/org/openecomp/sdc/be/info/NodeTypeInfoToUpdateArtifacts.java index 766581bd62..9ab0bd7f27 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/info/NodeTypeInfoToUpdateArtifacts.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/info/NodeTypeInfoToUpdateArtifacts.java @@ -1,3 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. 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========================================================= + * Modifications copyright (c) 2019 Nokia + * ================================================================================ + */ package org.openecomp.sdc.be.info; import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum; @@ -12,6 +33,7 @@ public class NodeTypeInfoToUpdateArtifacts { private String nodeName; private Map>> nodeTypesArtifactsToHandle; + NodeTypeInfoToUpdateArtifacts() {} public NodeTypeInfoToUpdateArtifacts(String nodeName, Map>> nodeTypesArtifactsToHandle) { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceListResponceTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceListResponceTest.java index e4d3c9bce9..c95b80295e 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceListResponceTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceListResponceTest.java @@ -1,12 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. 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========================================================= + * Modifications copyright (c) 2019 Nokia + * ================================================================================ + */ package org.openecomp.sdc.be.info; import org.junit.Test; +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; import static org.hamcrest.MatcherAssert.assertThat; - public class DistributionStatusOfServiceListResponceTest { + + @Test + public void shouldHaveValidDefaultConstructor() { + assertThat(DistributionStatusOfServiceListResponce.class, hasValidBeanConstructor()); + } + @Test public void shouldHaveValidGettersAndSetters() { assertThat(DistributionStatusOfServiceListResponce.class, hasValidGettersAndSetters()); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusTest.java index f8ce8ade58..1b3633ca56 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusTest.java @@ -1,39 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. 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========================================================= + * Modifications copyright (c) 2019 Nokia + * ================================================================================ + */ package org.openecomp.sdc.be.info; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; + import org.junit.Test; public class DistributionStatusTest { - private DistributionStatus createTestSubject() { - return DistributionStatus.DEPLOYED; - } - @Test - public void testGetName() throws Exception { - DistributionStatus testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getName(); + public void deployedStatusShouldProvideCorrectStrings() { + assertThat(DistributionStatus.DEPLOYED.getName(), is("Deployed")); + assertThat(DistributionStatus.DEPLOYED.getAuditingStatus(), is("DEPLOYED")); } @Test - public void testGetAuditingStatus() throws Exception { - DistributionStatus testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getAuditingStatus(); + public void shouldGetStatusByAuditingStatusName() { + DistributionStatus deployed = DistributionStatus.getStatusByAuditingStatusName("DEPLOYED"); + assertThat(deployed, is(DistributionStatus.DEPLOYED)); } @Test - public void testGetStatusByAuditingStatusName() throws Exception { - String auditingStatus = ""; - DistributionStatus result; - - // default test - result = DistributionStatus.getStatusByAuditingStatusName(auditingStatus); + public void shouldNotGetStatusByAuditingStatusName() { + DistributionStatus deployed = DistributionStatus.getStatusByAuditingStatusName("DIFFERENT_THAN_DEPLOYED"); + assertThat(deployed, is(nullValue())); } } \ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/GenericArtifactQueryInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/GenericArtifactQueryInfoTest.java new file mode 100644 index 0000000000..e814605a71 --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/GenericArtifactQueryInfoTest.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia Intellectual Property. 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.info; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.Collections; +import java.util.Set; +import org.junit.Test; + +public class GenericArtifactQueryInfoTest { + + private static final String ARTIFACT_UNIQUE_ID = "artifactId"; + private static final String PARENT_ID = "parentId"; + private static final Set FIELDS = Collections.emptySet(); + + @Test + public void shouldHaveValidDefaultConstructor() { + assertThat(GenericArtifactQueryInfo.class, hasValidBeanConstructor()); + } + + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(GenericArtifactQueryInfo.class, hasValidGettersAndSetters()); + } + + @Test + public void shouldTestConstructorCorrectlySetFields(){ + GenericArtifactQueryInfo genericArtifactQueryInfo = new GenericArtifactQueryInfo(FIELDS, PARENT_ID, + ARTIFACT_UNIQUE_ID); + assertThat(genericArtifactQueryInfo.getArtifactUniqueId(), is(ARTIFACT_UNIQUE_ID)); + assertThat(genericArtifactQueryInfo.getFields(), is(FIELDS)); + assertThat(genericArtifactQueryInfo.getParentId(), is(PARENT_ID)); + } +} \ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupDefinitionInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupDefinitionInfoTest.java index 1fb44a0cb7..bc8041bfda 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupDefinitionInfoTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupDefinitionInfoTest.java @@ -1,29 +1,120 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. 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========================================================= + * Modifications copyright (c) 2019 Nokia + * ================================================================================ + */ package org.openecomp.sdc.be.info; -import org.junit.Ignore; +import java.util.ArrayList; +import java.util.List; import org.junit.Test; + +import com.google.code.beanmatchers.BeanMatchers; +import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition; import org.openecomp.sdc.be.model.GroupDefinition; import org.openecomp.sdc.be.model.GroupInstance; -import com.google.code.beanmatchers.BeanMatchers; +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; - +import static org.hamcrest.Matchers.matchesPattern; public class GroupDefinitionInfoTest { - @Test - public void testCtor() { - new GroupDefinitionInfo(new GroupDefinition()); - new GroupDefinitionInfo(new GroupInstance()); - } - - @Ignore("the test fails on null pointer how ever the method does exists.") - @Test + + private static final String ARTIFACT_NAME = "artifactName"; + private static final String TO_STRING_REGEXP = "GroupDefinitionInfo \\[org.openecomp.sdc.be.info.GroupDefinitionInfo@" + + ".*" + ", isBase=true, artifacts=\\[org.openecomp.sdc.be.info.ArtifactDefinitionInfo@" + ".*" + "\\]\\]"; + private static final String GROUP_UUID = "GROUP_UUID"; + private static final String INVARIANT_UUID = "INVARIANT_UUID"; + private static final String VERSION = "VERSION"; + private static final String UNIQUE_ID = "UNIQUE_ID"; + private static final String DESC = "DESC"; + private static final String NAME = "NAME"; + + @Test + public void shouldHaveValidDefaultConstructor() { + assertThat(GroupDefinitionInfo.class, hasValidBeanConstructor()); + } + + @Test + public void testShouldConstructObjectFromGroupDefinition() { + GroupDefinition groupDefinition = createGroupDefinition(); + GroupDefinitionInfo groupDefinitionInfo = new GroupDefinitionInfo(groupDefinition); + assertThat(groupDefinitionInfo.getName(), is(groupDefinition.getName())); + assertThat(groupDefinitionInfo.getDescription(), is(groupDefinition.getDescription())); + assertThat(groupDefinitionInfo.getUniqueId(), is(groupDefinition.getUniqueId())); + assertThat(groupDefinitionInfo.getVersion(), is(groupDefinition.getVersion())); + assertThat(groupDefinitionInfo.getInvariantUUID(), is(groupDefinition.getInvariantUUID())); + assertThat(groupDefinitionInfo.getGroupUUID(), is(groupDefinition.getGroupUUID())); + } + + @Test + public void testShouldConstructObjectFromGroupInstance() { + GroupInstanceDataDefinition groupInstanceDataDefinition = createGroupInstanceDataDefinition(); + GroupInstance groupInstance = new GroupInstance(groupInstanceDataDefinition); + GroupDefinitionInfo groupDefinitionInfo = new GroupDefinitionInfo(groupInstance); + assertThat(groupDefinitionInfo.getName(), is(groupInstanceDataDefinition.getGroupName())); + assertThat(groupDefinitionInfo.getDescription(), is(groupInstanceDataDefinition.getDescription())); + assertThat(groupDefinitionInfo.getGroupInstanceUniqueId(), is(groupInstanceDataDefinition.getUniqueId())); + assertThat(groupDefinitionInfo.getVersion(), is(groupInstanceDataDefinition.getVersion())); + assertThat(groupDefinitionInfo.getInvariantUUID(), is(groupInstanceDataDefinition.getInvariantUUID())); + assertThat(groupDefinitionInfo.getGroupUUID(), is(groupInstanceDataDefinition.getGroupUUID())); + } + + @Test public void shouldHaveValidGettersAndSetters() { - assertThat(GroupDefinitionInfo.class, BeanMatchers.hasValidGettersAndSetters()); + assertThat(GroupDefinitionInfo.class, BeanMatchers.hasValidGettersAndSettersExcluding("artifacts", "properties")); } - + @Test public void testToString() { - (new GroupDefinitionInfo()).toString(); + GroupDefinitionInfo groupDefinitionInfo = new GroupDefinitionInfo(); + List artifacts = new ArrayList<>(); + ArtifactDefinitionInfo artifactDefinitionInfo = new ArtifactDefinitionInfo(); + artifactDefinitionInfo.setArtifactName(ARTIFACT_NAME); + artifacts.add(artifactDefinitionInfo); + groupDefinitionInfo.setArtifacts(artifacts); + groupDefinitionInfo.setIsBase(true); + assertThat(groupDefinitionInfo.toString(), matchesPattern(TO_STRING_REGEXP)); } + + private GroupDefinition createGroupDefinition() { + GroupDataDefinition groupDataDefinition = new GroupDataDefinition(); + groupDataDefinition.setName(NAME); + groupDataDefinition.setDescription(DESC); + groupDataDefinition.setUniqueId(UNIQUE_ID); + groupDataDefinition.setVersion(VERSION); + groupDataDefinition.setInvariantUUID(INVARIANT_UUID); + groupDataDefinition.setGroupUUID(GROUP_UUID); + return new GroupDefinition(groupDataDefinition); + } + + private GroupInstanceDataDefinition createGroupInstanceDataDefinition() { + GroupInstanceDataDefinition groupInstanceDataDefinition = new GroupInstanceDataDefinition(); + groupInstanceDataDefinition.setGroupName(NAME); + groupInstanceDataDefinition.setDescription(DESC); + groupInstanceDataDefinition.setUniqueId(UNIQUE_ID); + groupInstanceDataDefinition.setVersion(VERSION); + groupInstanceDataDefinition.setInvariantUUID(INVARIANT_UUID); + groupInstanceDataDefinition.setGroupUUID(GROUP_UUID); + return groupInstanceDataDefinition; + } + } \ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupTemplateInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupTemplateInfoTest.java index 03573e13c6..dcce6fdb9b 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupTemplateInfoTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupTemplateInfoTest.java @@ -1,13 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. 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========================================================= + * Modifications copyright (c) 2019 Nokia + * ================================================================================ + */ package org.openecomp.sdc.be.info; import org.junit.Test; +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; import static org.hamcrest.MatcherAssert.assertThat; - public class GroupTemplateInfoTest { + @Test + public void shouldHaveValidDefaultConstructor() { + assertThat(DistributionStatusOfServiceListResponce.class, hasValidBeanConstructor()); + } @Test public void shouldHaveValidGettersAndSetters() { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/NodeTypeInfoToUpdateArtifactsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/NodeTypeInfoToUpdateArtifactsTest.java index 25c71cfb41..388d63757b 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/NodeTypeInfoToUpdateArtifactsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/NodeTypeInfoToUpdateArtifactsTest.java @@ -1,56 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. 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========================================================= + * Modifications copyright (c) 2019 Nokia + * ================================================================================ + */ package org.openecomp.sdc.be.info; -import org.junit.Test; -import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum; -import org.openecomp.sdc.be.model.ArtifactDefinition; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import java.util.Collections; import java.util.EnumMap; import java.util.List; import java.util.Map; +import org.junit.Test; +import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum; +import org.openecomp.sdc.be.model.ArtifactDefinition; public class NodeTypeInfoToUpdateArtifactsTest { - private NodeTypeInfoToUpdateArtifacts createTestSubject() { - return new NodeTypeInfoToUpdateArtifacts("", null); - } + private static final String NAME = "NAME"; + private static final Map>> NODE_TYPES_ARTIFACTS_TO_HANDLE = Collections + .emptyMap(); @Test - public void testGetNodeName() throws Exception { - NodeTypeInfoToUpdateArtifacts testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getNodeName(); + public void shouldHaveValidGettersAndSetters() { + assertThat(NodeTypeInfoToUpdateArtifacts.class, hasValidGettersAndSetters()); } @Test - public void testSetNodeName() throws Exception { - NodeTypeInfoToUpdateArtifacts testSubject; - String nodeName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setNodeName(nodeName); - } - - @Test - public void testGetNodeTypesArtifactsToHandle() throws Exception { - NodeTypeInfoToUpdateArtifacts testSubject; - Map>> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getNodeTypesArtifactsToHandle(); - } - - @Test - public void testSetNodeTypesArtifactsToHandle() throws Exception { - NodeTypeInfoToUpdateArtifacts testSubject; - Map>> nodeTypesArtifactsToHandle = null; - - // default test - testSubject = createTestSubject(); - testSubject.setNodeTypesArtifactsToHandle(nodeTypesArtifactsToHandle); + public void shouldConstructCorrectObject() { + NodeTypeInfoToUpdateArtifacts nodeTypeInfoToUpdateArtifacts = new NodeTypeInfoToUpdateArtifacts(NAME, + NODE_TYPES_ARTIFACTS_TO_HANDLE); + assertThat(nodeTypeInfoToUpdateArtifacts.getNodeName(), is(NAME)); + assertThat(nodeTypeInfoToUpdateArtifacts.getNodeTypesArtifactsToHandle(), is(NODE_TYPES_ARTIFACTS_TO_HANDLE)); } } \ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipListTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipListTest.java new file mode 100644 index 0000000000..ac657ddfff --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipListTest.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia Intellectual Property. 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.info; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.Test; + +public class RelationshipListTest { + + @Test + public void shouldHaveValidDefaultConstructor() { + assertThat(RelationshipList.class, hasValidBeanConstructor()); + } + + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(RelationshipList.class, hasValidGettersAndSetters()); + } + +} \ No newline at end of file -- cgit 1.2.3-korg