diff options
Diffstat (limited to 'catalog-be/src/test/java/org')
11 files changed, 424 insertions, 536 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/MergedArtifactInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/MergedArtifactInfoTest.java index d448313fce..24676a263b 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/MergedArtifactInfoTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/MergedArtifactInfoTest.java @@ -1,130 +1,137 @@ +/*- + * ============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 mockit.Deencapsulation; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.junit.Test; -import org.openecomp.sdc.be.model.ArtifactDefinition; +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; -import java.util.HashSet; -import java.util.LinkedList; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; -import java.util.Set; +import org.junit.Test; +import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; +import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; +import org.openecomp.sdc.be.model.ArtifactDefinition; public class MergedArtifactInfoTest { - private MergedArtifactInfo createTestSubject() { - MergedArtifactInfo testSubject = new MergedArtifactInfo(); - testSubject.setJsonArtifactTemplate(new ArtifactTemplateInfo()); - LinkedList<ArtifactDefinition> createdArtifact = new LinkedList<>(); - ArtifactDefinition e = new ArtifactDefinition(); - e.setArtifactName("mock"); - createdArtifact.add(e); - testSubject.setCreatedArtifact(createdArtifact); - return testSubject; - } + private static final String NAME = "NAME"; + private static final String FILE = "FILE"; + private static final String ENV = "ENV"; + private static final String URL = "URL"; + private static final String CHECKSUM = "CHECKSUM"; + private static final String CREATOR = "CREATOR"; + private static final String DISPLAY_NAME = "DISPLAY_NAME"; + private static final String LABEL = "LABEL"; + private static final String REF = "REF"; + private static final String REPOSITORY = "REPOSITORY"; + private static final String TYPE = "TYPE"; + private static final String UUID = "UUID"; + private static final String ES_ID = "ES_ID"; + private static final String UNIQUE_ID = "UNIQUE_ID"; + private static final String GENERATED_FROM = "GENERATED_FROM"; @Test - public void testGetCreatedArtifact() throws Exception { - MergedArtifactInfo testSubject; - List<ArtifactDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getCreatedArtifact(); + public void shouldHaveValidDefaultConstructor() { + assertThat(MergedArtifactInfo.class, hasValidBeanConstructor()); } @Test - public void testSetCreatedArtifact() throws Exception { - MergedArtifactInfo testSubject; - List<ArtifactDefinition> createdArtifact = new LinkedList<>(); - - // default test - testSubject = createTestSubject(); - testSubject.setCreatedArtifact(createdArtifact); + public void shouldCorrectlySetCreatedArtifact() { + MergedArtifactInfo mergedArtifactInfo = createMergedArtifactInfo(); + assertJsonArtifactTemplate(mergedArtifactInfo.getJsonArtifactTemplate()); + assertCreatedArtifact(mergedArtifactInfo.getCreatedArtifact()); } @Test - public void testGetJsonArtifactTemplate() throws Exception { - MergedArtifactInfo testSubject; - ArtifactTemplateInfo result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getJsonArtifactTemplate(); + public void shouldReturnListToDisassociateArtifactFromGroup() { + MergedArtifactInfo mergedArtifactInfo = createMergedArtifactInfo(); + mergedArtifactInfo.getCreatedArtifact().get(0).setToscaPresentationValue(JsonPresentationFields.GENERATED_FROM_ID, + GENERATED_FROM); + List<ArtifactDefinition> listToDissotiateArtifactFromGroup = mergedArtifactInfo + .getListToDissotiateArtifactFromGroup(Collections.emptyList()); + assertThat(listToDissotiateArtifactFromGroup.size(), is(1)); + assertThat(listToDissotiateArtifactFromGroup.get(0).getUniqueId(), is(UNIQUE_ID)); } @Test - public void testSetJsonArtifactTemplate() throws Exception { - MergedArtifactInfo testSubject; - ArtifactTemplateInfo jsonArtifactTemplate = new ArtifactTemplateInfo(); - - // default test - testSubject = createTestSubject(); - testSubject.setJsonArtifactTemplate(jsonArtifactTemplate); + public void shouldReturnEmptyListToDisassociateArtifactFromGroupWhenGeneratedFormIdIsEmpty() { + MergedArtifactInfo mergedArtifactInfo = createMergedArtifactInfo(); + List<ArtifactDefinition> artifactDefinitions = new ArrayList<>(); + artifactDefinitions.add(new ArtifactDefinition(createArtifactDataDefinition())); + List<ArtifactDefinition> listToDissotiateArtifactFromGroup = mergedArtifactInfo + .getListToDissotiateArtifactFromGroup(artifactDefinitions); + assertThat(listToDissotiateArtifactFromGroup.isEmpty(), is(true)); } - @Test - public void testGetListToAssociateArtifactToGroup() throws Exception { - MergedArtifactInfo testSubject; - List<ArtifactTemplateInfo> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getListToAssociateArtifactToGroup(); + private MergedArtifactInfo createMergedArtifactInfo() { + MergedArtifactInfo mergedArtifactInfo = new MergedArtifactInfo(); + List<ArtifactTemplateInfo> relatedArtifactsInfo = new ArrayList<>(); + relatedArtifactsInfo.add(new ArtifactTemplateInfo(TYPE, FILE, ENV, Collections.emptyList())); + mergedArtifactInfo.setJsonArtifactTemplate(new ArtifactTemplateInfo(NAME, FILE, ENV, relatedArtifactsInfo)); + List<ArtifactDefinition> createdArtifact = new ArrayList<>(); + createdArtifact.add(new ArtifactDefinition(createArtifactDataDefinition())); + mergedArtifactInfo.setCreatedArtifact(createdArtifact); + return mergedArtifactInfo; } - @Test - public void testGetListToDissotiateArtifactFromGroup() throws Exception { - MergedArtifactInfo testSubject; - List<ArtifactDefinition> deletedArtifacts = new LinkedList<>(); - List<ArtifactDefinition> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getListToDissotiateArtifactFromGroup(deletedArtifacts); + private ArtifactDataDefinition createArtifactDataDefinition() { + ArtifactDataDefinition artifactDataDefinition = new ArtifactDataDefinition(); + artifactDataDefinition.setApiUrl(URL); + artifactDataDefinition.setUniqueId(UNIQUE_ID); + artifactDataDefinition.setArtifactChecksum(CHECKSUM); + artifactDataDefinition.setArtifactCreator(CREATOR); + artifactDataDefinition.setArtifactDisplayName(DISPLAY_NAME); + artifactDataDefinition.setArtifactLabel(LABEL); + artifactDataDefinition.setArtifactName(NAME); + artifactDataDefinition.setArtifactRef(REF); + artifactDataDefinition.setArtifactRepository(REPOSITORY); + artifactDataDefinition.setArtifactType(TYPE); + artifactDataDefinition.setArtifactUUID(UUID); + artifactDataDefinition.setEsId(ES_ID); + return artifactDataDefinition; } - @Test - public void testGetListToUpdateArtifactInGroup() throws Exception { - MergedArtifactInfo testSubject; - List<ImmutablePair<ArtifactDefinition, ArtifactTemplateInfo>> result; - - // default test - testSubject = createTestSubject(); - - result = testSubject.getListToUpdateArtifactInGroup(); - } - - @Test - public void testGetUpdateArtifactsInGroup() throws Exception { - MergedArtifactInfo testSubject; - List<ImmutablePair<ArtifactDefinition, ArtifactTemplateInfo>> resList = new LinkedList<>(); - List<ArtifactTemplateInfo> jsonArtifacts = new LinkedList<>(); - - // default test - testSubject = createTestSubject(); - Deencapsulation.invoke(testSubject, "getUpdateArtifactsInGroup", resList, resList); + private void assertCreatedArtifact(List<ArtifactDefinition> artifactDefinitions){ + assertThat(artifactDefinitions.size(), is(1)); + ArtifactDefinition artifactDefinition = artifactDefinitions.get(0); + assertThat(artifactDefinition.getArtifactType(), is(TYPE)); + assertThat(artifactDefinition.getArtifactRef(), is(REF)); + assertThat(artifactDefinition.getArtifactName(), is(NAME)); + assertThat(artifactDefinition.getArtifactRepository(), is(REPOSITORY)); + assertThat(artifactDefinition.getArtifactChecksum(), is(CHECKSUM)); + assertThat(artifactDefinition.getEsId(), is(ES_ID)); + assertThat(artifactDefinition.getArtifactLabel(), is(LABEL)); + assertThat(artifactDefinition.getArtifactCreator(), is(CREATOR)); + assertThat(artifactDefinition.getArtifactDisplayName(), is(DISPLAY_NAME)); + assertThat(artifactDefinition.getApiUrl(), is(URL)); + assertThat(artifactDefinition.getServiceApi(), is(false)); + assertThat(artifactDefinition.getArtifactUUID(), is(UUID)); } - @Test - public void testGetNewArtifactsInGroup() throws Exception { - MergedArtifactInfo testSubject; - List<ArtifactTemplateInfo> resList = new LinkedList<>(); - List<ArtifactTemplateInfo> jsonArtifacts = new LinkedList<>(); - - // default test - testSubject = createTestSubject(); - Deencapsulation.invoke(testSubject, "getNewArtifactsInGroup", resList, resList); - } - - @Test - public void testCreateArtifactsGroupSet() throws Exception { - MergedArtifactInfo testSubject; - List<ArtifactTemplateInfo> parsedGroupTemplateList = new LinkedList<>(); - Set<String> parsedArtifactsName = new HashSet<>(); - - // default test - testSubject = createTestSubject(); - Deencapsulation.invoke(testSubject, "createArtifactsGroupSet", parsedGroupTemplateList, parsedArtifactsName); + private void assertJsonArtifactTemplate(ArtifactTemplateInfo artifactTemplateInfo){ + assertThat(artifactTemplateInfo.getType(), is(NAME)); + assertThat(artifactTemplateInfo.getFileName(), is(FILE)); + assertThat(artifactTemplateInfo.getEnv(), is(ENV)); } }
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/OperationalEnvInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/OperationalEnvInfoTest.java index 67ee993675..66c29a4cd1 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/OperationalEnvInfoTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/OperationalEnvInfoTest.java @@ -1,189 +1,65 @@ +/*- + * ============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 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 org.junit.Test; public class OperationalEnvInfoTest { - private OperationalEnvInfo createTestSubject() { - return new OperationalEnvInfo(); - } - - @Test - public void testGetOperationalEnvId() throws Exception { - OperationalEnvInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getOperationalEnvId(); - } - - @Test - public void testSetOperationalEnvId() throws Exception { - OperationalEnvInfo testSubject; - String operationalEnvId = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setOperationalEnvId(operationalEnvId); - } - - @Test - public void testGetOperationalEnvName() throws Exception { - OperationalEnvInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getOperationalEnvName(); - } - - @Test - public void testSetOperationalEnvName() throws Exception { - OperationalEnvInfo testSubject; - String operationalEnvName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setOperationalEnvName(operationalEnvName); - } - - @Test - public void testGetOperationalEnvType() throws Exception { - OperationalEnvInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getOperationalEnvType(); - } - - @Test - public void testSetOperationalEnvType() throws Exception { - OperationalEnvInfo testSubject; - String operationalEnvType = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setOperationalEnvType(operationalEnvType); - } - - @Test - public void testGetOperationalEnvStatus() throws Exception { - OperationalEnvInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getOperationalEnvStatus(); - } - - @Test - public void testSetOperationalEnvStatus() throws Exception { - OperationalEnvInfo testSubject; - String operationalEnvStatus = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setOperationalEnvStatus(operationalEnvStatus); - } - - @Test - public void testGetTenantContext() throws Exception { - OperationalEnvInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getTenantContext(); - } - - @Test - public void testSetTenantContext() throws Exception { - OperationalEnvInfo testSubject; - String tenantContext = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setTenantContext(tenantContext); - } - - @Test - public void testGetWorkloadContext() throws Exception { - OperationalEnvInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getWorkloadContext(); - } - - @Test - public void testSetWorkloadContext() throws Exception { - OperationalEnvInfo testSubject; - String workloadContext = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setWorkloadContext(workloadContext); - } - - @Test - public void testGetResourceVersion() throws Exception { - OperationalEnvInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceVersion(); - } - - @Test - public void testSetResourceVersion() throws Exception { - OperationalEnvInfo testSubject; - String resourceVersion = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceVersion(resourceVersion); - } + private static final String ID = "ID"; + private static final String NAME = "NAME"; + private static final String STATUS = "STATUS"; + private static final String TYPE = "TYPE"; + private static final String VERSION = "VERSION"; + private static final String TENANT = "TENANT"; + private static final String WORKLOAD = "WORKLOAD"; + private static final String TO_STRING_RESPONSE = "{\"operational-environment-id\":\"ID\",\"operational-environment-name\":\"NAME\",\"operational-environment-type\":\"TYPE\",\"operational-environment-status\":\"STATUS\",\"tenant-context\":\"TENANT\",\"workload-context\":\"WORKLOAD\",\"resource-version\":\"VERSION\",\"relationship-list\":null}"; @Test - public void testGetRelationships() throws Exception { - OperationalEnvInfo testSubject; - RelationshipList result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelationships(); + public void shouldHaveValidGettersAndSetters() { + assertThat(OperationalEnvInfo.class, hasValidGettersAndSetters()); } @Test - public void testSetRelationships() throws Exception { - OperationalEnvInfo testSubject; - RelationshipList relationships = null; - - // default test - testSubject = createTestSubject(); - testSubject.setRelationships(relationships); + public void shouldHaveValidDefaultConstructor() { + assertThat(OperationalEnvInfo.class, hasValidBeanConstructor()); } @Test - public void testToString() throws Exception { - OperationalEnvInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); + public void testToStringShouldReturnCorrectFormat() { + OperationalEnvInfo operationalEnvInfo = new OperationalEnvInfo(); + operationalEnvInfo.setOperationalEnvId(ID); + operationalEnvInfo.setOperationalEnvName(NAME); + operationalEnvInfo.setOperationalEnvStatus(STATUS); + operationalEnvInfo.setOperationalEnvType(TYPE); + operationalEnvInfo.setResourceVersion(VERSION); + operationalEnvInfo.setTenantContext(TENANT); + operationalEnvInfo.setWorkloadContext(WORKLOAD); + assertThat(operationalEnvInfo.toString(), is(TO_STRING_RESPONSE)); } - @Test - public void testCreateFromJson() throws Exception { - String json = "{}"; - OperationalEnvInfo result; - - // default test - result = OperationalEnvInfo.createFromJson(json); - } }
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelatedToPropertyTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelatedToPropertyTest.java index 9bfa6a5216..4e88950610 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelatedToPropertyTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelatedToPropertyTest.java @@ -1,50 +1,42 @@ +/*- + * ============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 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 RelatedToPropertyTest { - private RelatedToProperty createTestSubject() { - return new RelatedToProperty(); - } - - @Test - public void testGetPropertyKey() throws Exception { - RelatedToProperty testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getPropertyKey(); - } - @Test - public void testSetPropertyKey() throws Exception { - RelatedToProperty testSubject; - String propertyKey = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setPropertyKey(propertyKey); + public void shouldHaveValidGettersAndSetters() { + assertThat(RelatedToProperty.class, hasValidGettersAndSetters()); } @Test - public void testGetPropertyValue() throws Exception { - RelatedToProperty testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getPropertyValue(); + public void shouldHaveValidDefaultConstructor() { + assertThat(RelatedToProperty.class, hasValidBeanConstructor()); } - @Test - public void testSetPropertyValue() throws Exception { - RelatedToProperty testSubject; - String propertyValue = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setPropertyValue(propertyValue); - } }
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipDataTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipDataTest.java index 3a3ac2c577..878666dc3a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipDataTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipDataTest.java @@ -1,50 +1,42 @@ +/*- + * ============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 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 RelationshipDataTest { - private RelationshipData createTestSubject() { - return new RelationshipData(); - } - - @Test - public void testSetRelationshipkey() throws Exception { - RelationshipData testSubject; - String relationshipKey = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setRelationshipkey(relationshipKey); - } - @Test - public void testGetRelationshipKey() throws Exception { - RelationshipData testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelationshipKey(); + public void shouldHaveValidGettersAndSetters() { + assertThat(RelationshipData.class, hasValidGettersAndSetters()); } @Test - public void testSetRelationshipValue() throws Exception { - RelationshipData testSubject; - String relationshipValue = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setRelationshipValue(relationshipValue); + public void shouldHaveValidDefaultConstructor() { + assertThat(RelationshipData.class, hasValidBeanConstructor()); } - @Test - public void testGetRelationshipValue() throws Exception { - RelationshipData testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelationshipValue(); - } }
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipTest.java index dd766b8a77..5266753655 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipTest.java @@ -1,112 +1,42 @@ +/*- + * ============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; -import java.util.List; +import org.junit.Test; public class RelationshipTest { - private Relationship createTestSubject() { - return new Relationship(); - } - - @Test - public void testGetRelatedTo() throws Exception { - Relationship testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelatedTo(); - } - @Test - public void testSetRelatedTo() throws Exception { - Relationship testSubject; - String relatedTo = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setRelatedTo(relatedTo); + public void shouldHaveValidGettersAndSetters() { + assertThat(Relationship.class, hasValidGettersAndSetters()); } @Test - public void testGetRelatedLink() throws Exception { - Relationship testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelatedLink(); + public void shouldHaveValidDefaultConstructor() { + assertThat(Relationship.class, hasValidBeanConstructor()); } - @Test - public void testSetRelatedLink() throws Exception { - Relationship testSubject; - String relatedLink = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setRelatedLink(relatedLink); - } - - @Test - public void testGetRelationshipData() throws Exception { - Relationship testSubject; - List<RelationshipData> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelationshipData(); - } - - @Test - public void testSetRelationshipData() throws Exception { - Relationship testSubject; - List<RelationshipData> relationshipData = null; - - // default test - testSubject = createTestSubject(); - testSubject.setRelationshipData(relationshipData); - } - - @Test - public void testGetRelationshipLabel() throws Exception { - Relationship testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelationshipLabel(); - } - - @Test - public void testSetRelationshipLabel() throws Exception { - Relationship testSubject; - String relationshipLabel = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setRelationshipLabel(relationshipLabel); - } - - @Test - public void testGetRelatedToProperty() throws Exception { - Relationship testSubject; - List<RelatedToProperty> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelatedToProperty(); - } - - @Test - public void testSetRelatedToProperty() throws Exception { - Relationship testSubject; - List<RelatedToProperty> relatedToProperty = null; - - // default test - testSubject = createTestSubject(); - testSubject.setRelatedToProperty(relatedToProperty); - } }
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceInfoTest.java index e8c9374447..73a4bb0a44 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceInfoTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceInfoTest.java @@ -1,57 +1,48 @@ +/*- + * ============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 java.util.List; +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.List; import org.junit.Test; - public class ServiceInfoTest { - private ServiceInfo createTestSubject() { - return new ServiceInfo("", null); - } - - - @Test - public void testGetName() throws Exception { - ServiceInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getName(); - } + private static final String NAME = "NAME"; + private static final List<ServiceVersionInfo> SERVICE_VERSION_INFOS = Collections.emptyList(); - @Test - public void testSetName() throws Exception { - ServiceInfo testSubject; - String name = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setName(name); + public void shouldHaveValidGettersAndSetters() { + assertThat(ServiceInfo.class, hasValidGettersAndSetters()); } - @Test - public void testGetVersions() throws Exception { - ServiceInfo testSubject; - List<ServiceVersionInfo> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getVersions(); - } - - - @Test - public void testSetVersions() throws Exception { - ServiceInfo testSubject; - List<ServiceVersionInfo> versions = null; - - // default test - testSubject = createTestSubject(); - testSubject.setVersions(versions); + public void shouldConstructCorrectObject() { + ServiceInfo serviceInfo = new ServiceInfo(NAME, SERVICE_VERSION_INFOS); + assertThat(serviceInfo.getName(), is(NAME)); + assertThat(serviceInfo.getVersions(), is(SERVICE_VERSION_INFOS)); } }
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceVersionInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceVersionInfoTest.java index d609f8090f..6ea2b2a385 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceVersionInfoTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceVersionInfoTest.java @@ -1,54 +1,48 @@ +/*- + * ============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 com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + import org.junit.Test; public class ServiceVersionInfoTest { - private ServiceVersionInfo createTestSubject() { - return new ServiceVersionInfo("", "", ""); - } - - - @Test - public void testGetVersion() throws Exception { - ServiceVersionInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getVersion(); - } - - - @Test - public void testSetVersion() throws Exception { - ServiceVersionInfo testSubject; - String serviceVersion = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setVersion(serviceVersion); - } + private static final String NAME = "NAME"; + private static final String VERSION = "VERSION"; + private static final String CONTEXT = "http://localhost:1000/"; + private static final String URL = "http://localhost:1000/services/NAME/VERSION"; - @Test - public void testGetUrl() throws Exception { - ServiceVersionInfo testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getUrl(); + public void shouldHaveValidGettersAndSetters() { + assertThat(ServiceVersionInfo.class, hasValidGettersAndSetters()); } - @Test - public void testSetUrl() throws Exception { - ServiceVersionInfo testSubject; - String url = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setUrl(url); + public void shouldConstructCorrectObject() { + ServiceVersionInfo serviceVersionInfo = new ServiceVersionInfo(NAME, VERSION, CONTEXT); + assertThat(serviceVersionInfo.getUrl(), is(URL)); + assertThat(serviceVersionInfo.getVersion(), is(VERSION)); } }
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServicesWrapperTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServicesWrapperTest.java index 98860586b0..8e96ead0fd 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServicesWrapperTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServicesWrapperTest.java @@ -1,16 +1,42 @@ +/*- + * ============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 ServicesWrapperTest { - @Test public void shouldHaveValidGettersAndSetters() { assertThat(ServicesWrapper.class, hasValidGettersAndSetters()); } + + @Test + public void shouldHaveValidDefaultConstructor() { + assertThat(ServiceInfo.class, hasValidBeanConstructor()); + } + }
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServletJsonResponseTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServletJsonResponseTest.java index f542019980..c3e76af97d 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServletJsonResponseTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ServletJsonResponseTest.java @@ -1,14 +1,42 @@ +/*- + * ============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 ServletJsonResponseTest { + @Test public void shouldHaveValidGettersAndSetters() { assertThat(ServletJsonResponse.class, hasValidGettersAndSetters()); } + + @Test + public void shouldHaveValidDefaultConstructor() { + assertThat(ServiceInfo.class, hasValidBeanConstructor()); + } + }
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInfoTest.java index 5642b2f1ef..101b72c5dd 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInfoTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInfoTest.java @@ -1,13 +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 com.google.code.beanmatchers.BeanMatchers; -import static org.hamcrest.MatcherAssert.assertThat; +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor; +import static org.hamcrest.MatcherAssert.assertThat; public class ToscaNodeTypeInfoTest { + @Test + public void shouldHaveValidDefaultConstructor() { + assertThat(ServiceInfo.class, hasValidBeanConstructor()); + } @Test public void shouldHaveValidGettersAndSetters() { @@ -18,4 +44,5 @@ public class ToscaNodeTypeInfoTest { public void allPropertiesShouldBeRepresentedInToStringOutput() { assertThat(ToscaNodeTypeInfo.class, BeanMatchers.hasValidBeanToString()); } + }
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInterfaceTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInterfaceTest.java index c74ce36a92..bfb4a90493 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInterfaceTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInterfaceTest.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 ToscaNodeTypeInterfaceTest { + @Test + public void shouldHaveValidDefaultConstructor() { + assertThat(ToscaNodeTypeInterface.class, hasValidBeanConstructor()); + } @Test public void shouldHaveValidGettersAndSetters() { |