Some unit tests for catalog-be 83/85183/3
authorTomasz Golabek <tomasz.golabek@nokia.com>
Fri, 12 Apr 2019 10:25:50 +0000 (12:25 +0200)
committerTomasz Golabek <tomasz.golabek@nokia.com>
Mon, 6 May 2019 07:19:57 +0000 (09:19 +0200)
This is the last part of tests for info-models so at least this
package should be quite nice covered by test since now.
Some refactor made if needed.

Change-Id: I78303ae8c5976b4a2c97422517a6df0cbae88e26
Issue-ID: SDC-2220
Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
15 files changed:
catalog-be/src/main/java/org/openecomp/sdc/be/info/MergedArtifactInfo.java
catalog-be/src/main/java/org/openecomp/sdc/be/info/RelationshipData.java
catalog-be/src/main/java/org/openecomp/sdc/be/info/ServiceInfo.java
catalog-be/src/main/java/org/openecomp/sdc/be/info/ServiceVersionInfo.java
catalog-be/src/test/java/org/openecomp/sdc/be/info/MergedArtifactInfoTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/info/OperationalEnvInfoTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/info/RelatedToPropertyTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipDataTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/info/RelationshipTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceInfoTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/info/ServiceVersionInfoTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/info/ServicesWrapperTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/info/ServletJsonResponseTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInfoTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/info/ToscaNodeTypeInterfaceTest.java

index 455bf40..85618a4 100644 (file)
@@ -43,7 +43,6 @@ public class MergedArtifactInfo {
         if (relatedGroupTemplateList != null && !relatedGroupTemplateList.isEmpty()) {
             this.createArtifactsGroupSet(relatedGroupTemplateList, parsetArtifactsNames);
         }
-
     }
 
     public ArtifactTemplateInfo getJsonArtifactTemplate() {
index 2b01dae..a151657 100644 (file)
@@ -1,3 +1,22 @@
+/*-
+ * ============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=========================================================
+ */
 package org.openecomp.sdc.be.info;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -10,7 +29,7 @@ public final class RelationshipData {
     @JsonProperty("relationship-value")
     private String relationshipValue;
 
-    public void setRelationshipkey(String relationshipKey) {
+    public void setRelationshipKey(String relationshipKey) {
         this.relationshipKey = relationshipKey;
     }
 
index 9939535..5a09362 100644 (file)
@@ -20,6 +20,7 @@
 
 package org.openecomp.sdc.be.info;
 
+import com.google.common.annotations.VisibleForTesting;
 import java.util.List;
 
 public class ServiceInfo {
@@ -27,6 +28,10 @@ public class ServiceInfo {
     private String name;
     private List<ServiceVersionInfo> versions;
 
+    @VisibleForTesting
+    ServiceInfo() {
+    }
+
     public ServiceInfo(String serviceName, List<ServiceVersionInfo> list) {
         this.name = serviceName;
         this.versions = list;
index 32c7c54..fc4cb89 100644 (file)
 
 package org.openecomp.sdc.be.info;
 
+import com.google.common.annotations.VisibleForTesting;
+
 public class ServiceVersionInfo {
 
     private String version;
     private String url;
 
+    @VisibleForTesting
+    ServiceVersionInfo() {}
+
     public ServiceVersionInfo(String serviceName, String serviceVersion, String context) {
         super();
         this.version = serviceVersion;
index d448313..24676a2 100644 (file)
+/*-
+ * ============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
index 67ee993..66c29a4 100644 (file)
+/*-
+ * ============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
index 9bfa6a5..4e88950 100644 (file)
@@ -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
index 3a3ac2c..878666d 100644 (file)
@@ -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
index dd766b8..5266753 100644 (file)
+/*-
+ * ============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
index e8c9374..73a4bb0 100644 (file)
@@ -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
index d609f80..6ea2b2a 100644 (file)
@@ -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
index 9886058..8e96ead 100644 (file)
@@ -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
index f542019..c3e76af 100644 (file)
@@ -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
index 5642b2f..101b72c 100644 (file)
@@ -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
index c74ce36..bfb4a90 100644 (file)
@@ -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() {