Some unit tests for catalog-be

Code coverage for some classes from catalog-be increased.
Some refactor made if needed.

Change-Id: I33114eed03d4e176896fd803b54fb77787c34283
Issue-ID: SDC-2220
Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactAccessList.java b/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactAccessList.java
index 635a082..fa3a333 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactAccessList.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactAccessList.java
@@ -16,6 +16,8 @@
  * 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;
@@ -24,12 +26,14 @@
 
 public class ArtifactAccessList {
 
+    ArtifactAccessList() {}
+
+    private List<ArtifactAccessInfo> artifacts;
+
     public ArtifactAccessList(List<ArtifactAccessInfo> artifacts) {
         this.artifacts = artifacts;
     }
 
-    private List<ArtifactAccessInfo> artifacts;
-
     public List<ArtifactAccessInfo> getArtifacts() {
         return artifacts;
     }
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactDefinitionInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactDefinitionInfo.java
index bf257ee..dcb5f42 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactDefinitionInfo.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/info/ArtifactDefinitionInfo.java
@@ -16,6 +16,8 @@
  * 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;
@@ -31,13 +33,15 @@
     private String artifactVersion;
     private String artifactUUID;
 
+    ArtifactDefinitionInfo() {
+    }
+
     public ArtifactDefinitionInfo(ArtifactDefinition artifactDefinition) {
         uniqueId = artifactDefinition.getUniqueId();
         artifactName = artifactDefinition.getArtifactName();
         artifactDisplayName = artifactDefinition.getArtifactDisplayName();
         artifactVersion = artifactDefinition.getArtifactVersion();
         artifactUUID = artifactDefinition.getArtifactUUID();
-
     }
 
     public String getUniqueId() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessListTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessListTest.java
index 89be01c..ad73636 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessListTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessListTest.java
@@ -1,34 +1,46 @@
+/*-
+ * ============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.junit.Assert.assertThat;
+
+import java.util.ArrayList;
 import java.util.List;
-
 import org.junit.Test;
 
-
 public class ArtifactAccessListTest {
 
-	private ArtifactAccessList createTestSubject() {
-		return new ArtifactAccessList(null);
+	@Test
+	public void shouldHaveValidGettersAndSetters() {
+		assertThat(ArtifactAccessList.class, hasValidGettersAndSetters());
 	}
 
 	@Test
-	public void testGetArtifacts() throws Exception {
-		ArtifactAccessList testSubject;
-		List<ArtifactAccessInfo> result;
-
-		// default test
-		testSubject = createTestSubject();
-		result = testSubject.getArtifacts();
+	public void testCtor() {
+		List<ArtifactAccessInfo> artifacts = new ArrayList<>();
+		ArtifactAccessList artifactAccessList = new ArtifactAccessList(artifacts);
+		assertThat(artifactAccessList.getArtifacts(), is(artifacts));
 	}
 
-
-	@Test
-	public void testSetArtifacts() throws Exception {
-		ArtifactAccessList testSubject;
-		List<ArtifactAccessInfo> artifacts = null;
-
-		// default test
-		testSubject = createTestSubject();
-		testSubject.setArtifacts(artifacts);
-	}
 }
\ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactDefinitionInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactDefinitionInfoTest.java
index b73874e..2811c15 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactDefinitionInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactDefinitionInfoTest.java
@@ -1,122 +1,69 @@
+/*-
+ * ============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.junit.Assert.assertThat;
+
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.openecomp.sdc.be.model.ArtifactDefinition;
 
-
+@RunWith(MockitoJUnitRunner.Silent.class)
 public class ArtifactDefinitionInfoTest {
 
-	private ArtifactDefinitionInfo createTestSubject() {
-		return new ArtifactDefinitionInfo(new ArtifactDefinition());
-	}
+	@Mock
+	private ArtifactDefinition artifactDefinition;
 
-	
+	private static final String VERSION = "VERSION";
+	private static final String DISPLAY_NAME = "DISPLAY NAME";
+	private static final String UUID = "1";
+	private static final byte[] PAYLOAD_DATA = "Test".getBytes();
+	private static final String NAME = "Name";
+
 	@Test
-	public void testGetUniqueId() throws Exception {
-		ArtifactDefinitionInfo testSubject;
-		String result;
-
-		// default test
-		testSubject = createTestSubject();
-		result = testSubject.getUniqueId();
+	public void shouldHaveValidGettersAndSetters() {
+		assertThat(ArtifactDefinitionInfo.class, hasValidGettersAndSetters());
 	}
 
-	
 	@Test
-	public void testSetUniqueId() throws Exception {
-		ArtifactDefinitionInfo testSubject;
-		String uniqueId = "";
+	public void testCtor() {
+		Mockito.when(artifactDefinition.getPayloadData()).thenReturn(PAYLOAD_DATA);
+		Mockito.when(artifactDefinition.getArtifactName()).thenReturn(NAME);
+		Mockito.when(artifactDefinition.getArtifactDisplayName()).thenReturn(DISPLAY_NAME);
+		Mockito.when(artifactDefinition.getArtifactVersion()).thenReturn(VERSION);
+		Mockito.when(artifactDefinition.getArtifactUUID()).thenReturn(UUID);
 
-		// default test
-		testSubject = createTestSubject();
-		testSubject.setUniqueId(uniqueId);
+		ArtifactDefinitionInfo artifactDefinitionInfo = new ArtifactDefinitionInfo(artifactDefinition);
+		assertThat(artifactDefinitionInfo.getArtifactDisplayName(), is(DISPLAY_NAME));
+		assertThat(artifactDefinitionInfo.getArtifactName(), is(NAME));
+		assertThat(artifactDefinitionInfo.getArtifactVersion(), is(VERSION));
+		assertThat(artifactDefinitionInfo.getArtifactUUID(), is(UUID));
+
 	}
 
-	
-	@Test
-	public void testGetArtifactName() throws Exception {
-		ArtifactDefinitionInfo testSubject;
-		String result;
 
-		// default test
-		testSubject = createTestSubject();
-		result = testSubject.getArtifactName();
-	}
-
-	
-	@Test
-	public void testSetArtifactName() throws Exception {
-		ArtifactDefinitionInfo testSubject;
-		String artifactName = "";
-
-		// default test
-		testSubject = createTestSubject();
-		testSubject.setArtifactName(artifactName);
-	}
-
-	
-	@Test
-	public void testGetArtifactDisplayName() throws Exception {
-		ArtifactDefinitionInfo testSubject;
-		String result;
-
-		// default test
-		testSubject = createTestSubject();
-		result = testSubject.getArtifactDisplayName();
-	}
-
-	
-	@Test
-	public void testSetArtifactDisplayName() throws Exception {
-		ArtifactDefinitionInfo testSubject;
-		String artifactDisplayName = "";
-
-		// default test
-		testSubject = createTestSubject();
-		testSubject.setArtifactDisplayName(artifactDisplayName);
-	}
-
-	
-	@Test
-	public void testGetArtifactVersion() throws Exception {
-		ArtifactDefinitionInfo testSubject;
-		String result;
-
-		// default test
-		testSubject = createTestSubject();
-		result = testSubject.getArtifactVersion();
-	}
-
-	
-	@Test
-	public void testSetArtifactVersion() throws Exception {
-		ArtifactDefinitionInfo testSubject;
-		String artifactVersion = "";
-
-		// default test
-		testSubject = createTestSubject();
-		testSubject.setArtifactVersion(artifactVersion);
-	}
-
-	
-	@Test
-	public void testGetArtifactUUID() throws Exception {
-		ArtifactDefinitionInfo testSubject;
-		String result;
-
-		// default test
-		testSubject = createTestSubject();
-		result = testSubject.getArtifactUUID();
-	}
-
-	
-	@Test
-	public void testSetArtifactUUID() throws Exception {
-		ArtifactDefinitionInfo testSubject;
-		String artifactUUID = "";
-
-		// default test
-		testSubject = createTestSubject();
-		testSubject.setArtifactUUID(artifactUUID);
-	}
 }
\ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTemplateInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTemplateInfoTest.java
index 8b820ea..5991341 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTemplateInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTemplateInfoTest.java
@@ -1,186 +1,60 @@
+/*-
+ * ============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.junit.Assert.assertThat;
+
 import java.util.LinkedList;
 import java.util.List;
 
 import org.junit.Test;
 
-
 public class ArtifactTemplateInfoTest {
 
-	private ArtifactTemplateInfo createTestSubject() {
-		return new ArtifactTemplateInfo();
+	private static final String TYPE = "TYPE";
+	private static final String FILENAME = "FILENAME";
+	private static final String ENV = "ENV";
+
+	@Test
+	public void shouldHaveValidGettersAndSetters() {
+		assertThat(ArtifactTemplateInfo.class, hasValidGettersAndSetters());
 	}
 
 	@Test
-	public void testCtor() throws Exception {
-		new ArtifactTemplateInfo("mock", "mock", "mock", new LinkedList<>());
+	public void testDefaultCtor() {
+		assertThat(ArtifactTemplateInfo.class, hasValidBeanConstructor());
 	}
-	
+
 	@Test
-	public void testGetType() throws Exception {
-		ArtifactTemplateInfo testSubject;
-		String result;
-
-		// default test
-		testSubject = createTestSubject();
-		result = testSubject.getType();
+	public void testCtor() {
+		List<ArtifactTemplateInfo> artifactsInfo = new LinkedList<>();
+		ArtifactTemplateInfo artifactTemplateInfo = new ArtifactTemplateInfo(TYPE, FILENAME, ENV, artifactsInfo);
+		assertThat(artifactTemplateInfo.getType(), is(TYPE));
+		assertThat(artifactTemplateInfo.getFileName(), is(FILENAME));
+		assertThat(artifactTemplateInfo.getEnv(), is(ENV));
+		assertThat(artifactTemplateInfo.getRelatedArtifactsInfo(), is(artifactsInfo));
 	}
 
-	
-	@Test
-	public void testSetType() throws Exception {
-		ArtifactTemplateInfo testSubject;
-		String type = "";
-
-		// default test
-		testSubject = createTestSubject();
-		testSubject.setType(type);
-	}
-
-	
-	@Test
-	public void testGetFileName() throws Exception {
-		ArtifactTemplateInfo testSubject;
-		String result;
-
-		// default test
-		testSubject = createTestSubject();
-		result = testSubject.getFileName();
-	}
-
-	
-	@Test
-	public void testSetFileName() throws Exception {
-		ArtifactTemplateInfo testSubject;
-		String fileName = "";
-
-		// default test
-		testSubject = createTestSubject();
-		testSubject.setFileName(fileName);
-	}
-
-	
-	@Test
-	public void testGetEnv() throws Exception {
-		ArtifactTemplateInfo testSubject;
-		String result;
-
-		// default test
-		testSubject = createTestSubject();
-		result = testSubject.getEnv();
-	}
-
-	
-	@Test
-	public void testSetEnv() throws Exception {
-		ArtifactTemplateInfo testSubject;
-		String env = "";
-
-		// default test
-		testSubject = createTestSubject();
-		testSubject.setEnv(env);
-	}
-
-	
-	@Test
-	public void testGetRelatedArtifactsInfo() throws Exception {
-		ArtifactTemplateInfo testSubject;
-		List<ArtifactTemplateInfo> result;
-
-		// default test
-		testSubject = createTestSubject();
-		result = testSubject.getRelatedArtifactsInfo();
-	}
-
-	
-	@Test
-	public void testSetRelatedArtifactsInfo() throws Exception {
-		ArtifactTemplateInfo testSubject;
-		List<ArtifactTemplateInfo> relatedArtifactsInfo = null;
-
-		// default test
-		testSubject = createTestSubject();
-		testSubject.setRelatedArtifactsInfo(relatedArtifactsInfo);
-	}
-
-	
-	@Test
-	public void testGetGroupName() throws Exception {
-		ArtifactTemplateInfo testSubject;
-		String result;
-
-		// default test
-		testSubject = createTestSubject();
-		result = testSubject.getGroupName();
-	}
-
-	
-	@Test
-	public void testSetGroupName() throws Exception {
-		ArtifactTemplateInfo testSubject;
-		String groupName = "";
-
-		// default test
-		testSubject = createTestSubject();
-		testSubject.setGroupName(groupName);
-	}
-
-	
-	@Test
-	public void testIsBase() throws Exception {
-		ArtifactTemplateInfo testSubject;
-		boolean result;
-
-		// default test
-		testSubject = createTestSubject();
-		result = testSubject.isBase();
-	}
-
-	
-	@Test
-	public void testSetBase() throws Exception {
-		ArtifactTemplateInfo testSubject;
-		boolean isBase = false;
-
-		// default test
-		testSubject = createTestSubject();
-		testSubject.setBase(isBase);
-	}
-
-	
-	@Test
-	public void testGetDescription() throws Exception {
-		ArtifactTemplateInfo testSubject;
-		String result;
-
-		// default test
-		testSubject = createTestSubject();
-		result = testSubject.getDescription();
-	}
-
-	
-	@Test
-	public void testSetDescription() throws Exception {
-		ArtifactTemplateInfo testSubject;
-		String description = "";
-
-		// default test
-		testSubject = createTestSubject();
-		testSubject.setDescription(description);
-	}
-
-	
-	@Test
-	public void testToString() throws Exception {
-		ArtifactTemplateInfo testSubject;
-		String result;
-
-		// default test
-		testSubject = createTestSubject();
-		result = testSubject.toString();
-	}
-
-	
-	
 }
\ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTypesInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTypesInfoTest.java
index b129247..ba76898 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTypesInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactTypesInfoTest.java
@@ -1,14 +1,41 @@
+/*-
+ * ============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.Assert;
 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 ArtifactTypesInfoTest {
     @Test
     public void shouldHaveValidGettersAndSetters() {
         assertThat(ArtifactTypesInfo.class, hasValidGettersAndSetters());
     }
+
+    @Test
+    public void testDefaultCtor() {
+        Assert.assertThat(ArtifactTypesInfo.class, hasValidBeanConstructor());
+    }
 }
\ No newline at end of file