Issue-ID: SDC-1342 replaced some junits
replaced junits under sdc/be/info
refactored + added testcases for EcompUserConverter
Change-Id: I569354fef87450cfccff827fe98e2ab7659113eb
Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
diff --git a/catalog-be/pom.xml b/catalog-be/pom.xml
index 2451d09..60a1008 100644
--- a/catalog-be/pom.xml
+++ b/catalog-be/pom.xml
@@ -667,6 +667,13 @@
<version>${jmockit.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>com.google.code.bean-matchers</groupId>
+ <artifactId>bean-matchers</artifactId>
+ <version>0.11</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java
index a5982c1..0f9c9be 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java
@@ -20,17 +20,17 @@
package org.openecomp.sdc.be.ecomp.converters;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
+import com.google.common.base.Strings;
+import com.google.common.collect.Sets;
+import fj.data.Either;
import org.openecomp.portalsdk.core.restful.domain.EcompRole;
import org.openecomp.portalsdk.core.restful.domain.EcompUser;
import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.user.Role;
-import fj.data.Either;
+import java.util.Iterator;
+import java.util.Objects;
public final class EcompUserConverter {
@@ -38,12 +38,41 @@
}
public static Either<EcompUser, String> convertUserToEcompUser(User asdcUser) {
- EcompUser convertedUser = new EcompUser();
+ return (Objects.nonNull(asdcUser)) ? Either.left(convertToEcompUser(asdcUser)) : Either.right("User is null");
+ }
- if (asdcUser == null) {
- return Either.right("User is null");
+
+ public static Either<User, String> convertEcompUserToUser(EcompUser ecompUser) {
+ return (Objects.nonNull(ecompUser)) ? Either.left(convertToUser(ecompUser)) : Either.right("EcompUser is null");
+ }
+
+ private static User convertToUser(EcompUser ecompUser) {
+ User convertedUser = new User();
+
+ convertedUser.setFirstName(ecompUser.getFirstName());
+ convertedUser.setLastName(ecompUser.getLastName());
+ convertedUser.setUserId((!isLoginIdEmpty(ecompUser) ? ecompUser.getLoginId() : ecompUser.getOrgUserId()));
+
+ convertedUser.setEmail(ecompUser.getEmail());
+
+ if (Objects.nonNull(ecompUser.getRoles())) {
+ Iterator<EcompRole> iter = ecompUser.getRoles().iterator();
+
+ if (iter.hasNext()) {
+ String updatedRole = EcompRoleConverter.convertEcompRoleToRole(iter.next());
+ convertedUser.setRole(updatedRole);
+ }
}
+ convertedUser.setStatus((ecompUser.isActive()) ? UserStatusEnum.ACTIVE : UserStatusEnum.INACTIVE);
+
+
+ return convertedUser;
+ }
+
+ private static EcompUser convertToEcompUser(User asdcUser) {
+ EcompUser convertedUser = new EcompUser();
+
convertedUser.setFirstName(asdcUser.getFirstName());
convertedUser.setLastName(asdcUser.getLastName());
convertedUser.setLoginId(asdcUser.getUserId());
@@ -56,55 +85,33 @@
convertedUser.setActive(false);
}
+ EcompRole convertedRole = getEcompRole(asdcUser);
+
+ convertedUser.setRoles(Sets.newHashSet(convertedRole));
+
+ return convertedUser;
+ }
+
+
+ private static boolean isLoginIdEmpty(EcompUser user) {
+ return Strings.isNullOrEmpty(user.getLoginId());
+ }
+
+ private static EcompRole getEcompRole(User asdcUser) {
EcompRole convertedRole = new EcompRole();
for (Role role : Role.values()) {
- if (role.name().equals(asdcUser.getRole()) || role.toString().equals(asdcUser.getRole())) {
+ if (isRolesNamesEqual(asdcUser, role)) {
convertedRole.setName(role.name());
- convertedRole.setId(new Long(role.ordinal()));
+ convertedRole.setId((long) role.ordinal());
break;
}
}
-
- Set<EcompRole> convertedRoleSet = new HashSet<>();
- convertedRoleSet.add(convertedRole);
- convertedUser.setRoles(convertedRoleSet);
-
- return Either.left(convertedUser);
+ return convertedRole;
}
- public static Either<User, String> convertEcompUserToUser(EcompUser ecompUser) {
- User convertedUser = new User();
-
- if (ecompUser == null) {
- return Either.right("EcompUser is null");
- }
-
- convertedUser.setFirstName(ecompUser.getFirstName());
- convertedUser.setLastName(ecompUser.getLastName());
-
- if (ecompUser.getLoginId() != null && !ecompUser.getLoginId().isEmpty()) {
- convertedUser.setUserId(ecompUser.getLoginId());
- } else {
- convertedUser.setUserId(ecompUser.getOrgUserId());
- }
-
- convertedUser.setEmail(ecompUser.getEmail());
-
- if (ecompUser.getRoles() != null) {
- Iterator<EcompRole> iter = ecompUser.getRoles().iterator();
-
- if (iter.hasNext()) {
- String updatedRole = EcompRoleConverter.convertEcompRoleToRole(iter.next());
- convertedUser.setRole(updatedRole);
- }
- }
-
- if (ecompUser.isActive()) {
- convertedUser.setStatus(UserStatusEnum.ACTIVE);
- } else {
- convertedUser.setStatus(UserStatusEnum.INACTIVE);
- }
-
- return Either.left(convertedUser);
+ private static boolean isRolesNamesEqual(User asdcUser, Role role) {
+ String asdcUserRole = asdcUser.getRole();
+ return role.name().equals(asdcUserRole) || role.toString().equals(asdcUserRole);
}
+
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverterTest.java
index fa16003..20fa4d1 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverterTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverterTest.java
@@ -1,28 +1,84 @@
package org.openecomp.sdc.be.ecomp.converters;
+
+import fj.data.Either;
import org.junit.Test;
+import org.openecomp.portalsdk.core.restful.domain.EcompRole;
import org.openecomp.portalsdk.core.restful.domain.EcompUser;
import org.openecomp.sdc.be.model.User;
-import fj.data.Either;
+import java.util.Collections;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
public class EcompUserConverterTest {
+ private static final String FIRST_NAME = "firstname";
+ private static final String LAST_NAME = "lastname";
+ private static final String USER_ID = "sample id";
+ private static final String EMAIL_ADDRESS = "sample@sample.com";
+ private static final String ROLE = "ADMIN";
- @Test
- public void testConvertUserToEcompUser() throws Exception {
- User asdcUser = new User();
- Either<EcompUser, String> result;
+ private static final Long LAST_LOGIN_TIME = 12345L;
+ private static final User TEST_USER = new User(FIRST_NAME, LAST_NAME, USER_ID, EMAIL_ADDRESS, ROLE, LAST_LOGIN_TIME);
- // test 1
- result = EcompUserConverter.convertUserToEcompUser(asdcUser);
- }
- @Test
- public void testConvertEcompUserToUser() throws Exception {
- EcompUser ecompUser = new EcompUser();
- Either<User, String> result;
+ @Test
+ public void shouldProperlyConvertEcompUserToUser() {
+ Either<EcompUser, String> convertedUser = EcompUserConverter.convertUserToEcompUser(TEST_USER);
- // test 1
- result = EcompUserConverter.convertEcompUserToUser(ecompUser);
- }
+ assertThat(convertedUser.isLeft()).isTrue();
+
+ EcompUser user = convertedUser.left().value();
+
+ assertThat(EMAIL_ADDRESS).isEqualTo(user.getEmail());
+ assertThat(FIRST_NAME).isEqualTo(user.getFirstName());
+ assertThat(LAST_NAME).isEqualTo(user.getLastName());
+ assertThat(USER_ID).isEqualTo(user.getLoginId());
+ assertThat(user.getRoles().stream().anyMatch((x) -> ROLE.equals(x.getName()))).isTrue();
+ }
+
+ @Test
+ public void shouldNotCrashWhenUserIsNotProvided() {
+ Either<EcompUser, String> convertedUser = EcompUserConverter.convertUserToEcompUser(null);
+
+ assertThat(convertedUser.isRight()).isTrue();
+ }
+
+ @Test
+ public void shouldNotCrashWhenEcompUserIsNotProvided() {
+ Either<User, String> convertedUser = EcompUserConverter.convertEcompUserToUser(null);
+
+ assertThat(convertedUser.isRight()).isTrue();
+ }
+
+ @Test
+ public void shouldProperlyConvertUserToEcompUser() {
+ Either<User, String> convertedUser = EcompUserConverter.convertEcompUserToUser(createEcompUser());
+
+ assertThat(convertedUser.isLeft()).isTrue();
+
+ User user = convertedUser.left().value();
+
+ assertThat(EMAIL_ADDRESS).isEqualTo(user.getEmail());
+ assertThat(FIRST_NAME).isEqualTo(user.getFirstName());
+ assertThat(LAST_NAME).isEqualTo(user.getLastName());
+ assertThat(USER_ID).isEqualTo(user.getUserId());
+ assertThat(ROLE).isEqualTo(user.getRole());
+ }
+
+ private EcompUser createEcompUser() {
+ EcompUser user = new EcompUser();
+
+ EcompRole role = new EcompRole();
+
+ role.setName(ROLE);
+ role.setId(0L);
+
+ user.setRoles(Collections.singleton(role));
+ user.setEmail(EMAIL_ADDRESS);
+ user.setLastName(LAST_NAME);
+ user.setFirstName(FIRST_NAME);
+ user.setOrgUserId(USER_ID);
+ return user;
+ }
}
\ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessInfoTest.java
index c947d62..a6ad10a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/ArtifactAccessInfoTest.java
@@ -3,235 +3,21 @@
import org.junit.Test;
import org.openecomp.sdc.be.resources.data.ESArtifactData;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
public class ArtifactAccessInfoTest {
- private ArtifactAccessInfo createTestSubject() {
- return new ArtifactAccessInfo();
- }
- @Test
- public void testCtor() throws Exception {
- new ArtifactAccessInfo(new ESArtifactData());
- new ArtifactAccessInfo(new ESArtifactData(), "mock");
- }
-
- @Test
- public void testGetName() throws Exception {
- ArtifactAccessInfo testSubject;
- String result;
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(ArtifactAccessInfo.class, hasValidGettersAndSetters());
+ }
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
-
-
- @Test
- public void testSetName() throws Exception {
- ArtifactAccessInfo testSubject;
- String name = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setName(name);
- }
-
-
- @Test
- public void testGetUrl() throws Exception {
- ArtifactAccessInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getUrl();
- }
-
-
- @Test
- public void testSetUrl() throws Exception {
- ArtifactAccessInfo testSubject;
- String url = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setUrl(url);
- }
-
-
- @Test
- public void testGetId() throws Exception {
- ArtifactAccessInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getId();
- }
-
-
- @Test
- public void testSetId() throws Exception {
- ArtifactAccessInfo testSubject;
- String id = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setId(id);
- }
-
-
- @Test
- public void testGetType() throws Exception {
- ArtifactAccessInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getType();
- }
-
-
- @Test
- public void testSetType() throws Exception {
- ArtifactAccessInfo testSubject;
- String type = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setType(type);
- }
-
-
- @Test
- public void testGetDescription() throws Exception {
- ArtifactAccessInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDescription();
- }
-
-
- @Test
- public void testSetDescription() throws Exception {
- ArtifactAccessInfo testSubject;
- String description = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDescription(description);
- }
-
-
- @Test
- public void testGetCreator() throws Exception {
- ArtifactAccessInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCreator();
- }
-
-
- @Test
- public void testSetCreator() throws Exception {
- ArtifactAccessInfo testSubject;
- String creator = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCreator(creator);
- }
-
-
- @Test
- public void testGetCreationTime() throws Exception {
- ArtifactAccessInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCreationTime();
- }
-
-
- @Test
- public void testSetCreationTime() throws Exception {
- ArtifactAccessInfo testSubject;
- String creationTime = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCreationTime(creationTime);
- }
-
-
- @Test
- public void testGetLastUpdater() throws Exception {
- ArtifactAccessInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getLastUpdater();
- }
-
-
- @Test
- public void testSetLastUpdater() throws Exception {
- ArtifactAccessInfo testSubject;
- String lastUpdater = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setLastUpdater(lastUpdater);
- }
-
-
- @Test
- public void testGetLastUpdateTime() throws Exception {
- ArtifactAccessInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getLastUpdateTime();
- }
-
-
- @Test
- public void testSetLastUpdateTime() throws Exception {
- ArtifactAccessInfo testSubject;
- String lastUpdateTime = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setLastUpdateTime(lastUpdateTime);
- }
-
-
- @Test
- public void testGetChecksum() throws Exception {
- ArtifactAccessInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getChecksum();
- }
-
-
- @Test
- public void testSetChecksum() throws Exception {
- ArtifactAccessInfo testSubject;
- String checksum = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setChecksum(checksum);
- }
+ @Test
+ public void testCtor() throws Exception {
+ new ArtifactAccessInfo(new ESArtifactData());
+ new ArtifactAccessInfo(new ESArtifactData(), "mock");
+ }
}
\ No newline at end of file
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 4c8da95..89be01c 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
@@ -11,7 +11,6 @@
return new ArtifactAccessList(null);
}
-
@Test
public void testGetArtifacts() throws Exception {
ArtifactAccessList testSubject;
@@ -22,7 +21,7 @@
result = testSubject.getArtifacts();
}
-
+
@Test
public void testSetArtifacts() throws Exception {
ArtifactAccessList testSubject;
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 e16540f..8b820ea 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,5 +1,6 @@
package org.openecomp.sdc.be.info;
+import java.util.LinkedList;
import java.util.List;
import org.junit.Test;
@@ -11,6 +12,10 @@
return new ArtifactTemplateInfo();
}
+ @Test
+ public void testCtor() throws Exception {
+ new ArtifactTemplateInfo("mock", "mock", "mock", new LinkedList<>());
+ }
@Test
public void testGetType() throws Exception {
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 1474d94..b129247 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,58 +1,14 @@
package org.openecomp.sdc.be.info;
-import java.util.List;
-
import org.junit.Test;
-import org.openecomp.sdc.be.model.ArtifactType;
+
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
public class ArtifactTypesInfoTest {
-
- private ArtifactTypesInfo createTestSubject() {
- return new ArtifactTypesInfo();
- }
-
-
- @Test
- public void testGetArtifactTypes() throws Exception {
- ArtifactTypesInfo testSubject;
- List<ArtifactType> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getArtifactTypes();
- }
-
-
- @Test
- public void testSetArtifactTypes() throws Exception {
- ArtifactTypesInfo testSubject;
- List<ArtifactType> artifactTypes = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setArtifactTypes(artifactTypes);
- }
-
-
- @Test
- public void testGetHeatDefaultTimeout() throws Exception {
- ArtifactTypesInfo testSubject;
- Integer result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getHeatDefaultTimeout();
- }
-
-
- @Test
- public void testSetHeatDefaultTimeout() throws Exception {
- ArtifactTypesInfo testSubject;
- Integer heatDefaultTimeout = 0;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setHeatDefaultTimeout(heatDefaultTimeout);
- }
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(ArtifactTypesInfo.class, hasValidGettersAndSetters());
+ }
}
\ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusListResponseTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusListResponseTest.java
index 488cb31..74b8fdb 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusListResponseTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusListResponseTest.java
@@ -1,34 +1,13 @@
package org.openecomp.sdc.be.info;
-import java.util.List;
-
import org.junit.Test;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
public class DistributionStatusListResponseTest {
-
- private DistributionStatusListResponse createTestSubject() {
- return new DistributionStatusListResponse();
- }
-
-
- @Test
- public void testGetDistributionStatusList() throws Exception {
- DistributionStatusListResponse testSubject;
- List<DistributionStatusInfo> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDistributionStatusList();
- }
-
-
- @Test
- public void testSetDistributionStatusList() throws Exception {
- DistributionStatusListResponse testSubject;
- List<DistributionStatusInfo> distribStatusInfoList = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDistributionStatusList(distribStatusInfoList);
- }
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(DistributionStatusListResponse.class, hasValidGettersAndSetters());
+ }
}
\ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java
index 698be20..987db46 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceInfoTest.java
@@ -2,102 +2,21 @@
import org.junit.Test;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
public class DistributionStatusOfServiceInfoTest {
- private DistributionStatusOfServiceInfo createTestSubject() {
- return new DistributionStatusOfServiceInfo();
- }
@Test
public void testCtor() throws Exception {
new DistributionStatusOfServiceInfo("","","","");
}
-
- @Test
- public void testGetDistributionID() throws Exception {
- DistributionStatusOfServiceInfo testSubject;
- String result;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDistributionID();
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(DistributionStatusOfServiceInfo.class, hasValidGettersAndSetters());
}
-
- @Test
- public void testSetDistributionID() throws Exception {
- DistributionStatusOfServiceInfo testSubject;
- String distributionID = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDistributionID(distributionID);
- }
-
-
- @Test
- public void testGetTimestamp() throws Exception {
- DistributionStatusOfServiceInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getTimestamp();
- }
-
-
- @Test
- public void testSetTimestamp() throws Exception {
- DistributionStatusOfServiceInfo testSubject;
- String timestamp = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setTimestamp(timestamp);
- }
-
-
- @Test
- public void testGetUserId() throws Exception {
- DistributionStatusOfServiceInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getUserId();
- }
-
-
- @Test
- public void testSetUserId() throws Exception {
- DistributionStatusOfServiceInfo testSubject;
- String userId = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setUserId(userId);
- }
-
-
- @Test
- public void testGetDeployementStatus() throws Exception {
- DistributionStatusOfServiceInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDeployementStatus();
- }
-
-
- @Test
- public void testSetDeployementStatus() throws Exception {
- DistributionStatusOfServiceInfo testSubject;
- String deployementStatus = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDeployementStatus(deployementStatus);
- }
}
\ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceListResponceTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceListResponceTest.java
index 4a5964a..e4d3c9b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceListResponceTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/DistributionStatusOfServiceListResponceTest.java
@@ -1,35 +1,14 @@
package org.openecomp.sdc.be.info;
-import java.util.List;
-
import org.junit.Test;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
public class DistributionStatusOfServiceListResponceTest {
-
- private DistributionStatusOfServiceListResponce createTestSubject() {
- return new DistributionStatusOfServiceListResponce();
- }
-
-
- @Test
- public void testGetDistributionStatusOfServiceList() throws Exception {
- DistributionStatusOfServiceListResponce testSubject;
- List<DistributionStatusOfServiceInfo> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDistributionStatusOfServiceList();
- }
-
-
- @Test
- public void testSetDistributionStatusOfServiceList() throws Exception {
- DistributionStatusOfServiceListResponce testSubject;
- List<DistributionStatusOfServiceInfo> distribStatusOfServiceInfoList = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDistributionStatusOfServiceList(distribStatusOfServiceInfoList);
- }
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(DistributionStatusOfServiceListResponce.class, hasValidGettersAndSetters());
+ }
}
\ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupDefinitionInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupDefinitionInfoTest.java
index 662b96c..61a2768 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupDefinitionInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupDefinitionInfoTest.java
@@ -1,245 +1,27 @@
package org.openecomp.sdc.be.info;
-import java.util.List;
-
import org.junit.Test;
-import org.openecomp.sdc.be.model.GroupProperty;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.GroupInstance;
+
+import com.google.code.beanmatchers.BeanMatchers;
+import static org.hamcrest.MatcherAssert.assertThat;
public class GroupDefinitionInfoTest {
-
- private GroupDefinitionInfo createTestSubject() {
- return new GroupDefinitionInfo();
+ @Test
+ public void testCtor() {
+ new GroupDefinitionInfo(new GroupDefinition());
+ new GroupDefinitionInfo(new GroupInstance());
}
-
@Test
- public void testGetInvariantUUID() throws Exception {
- GroupDefinitionInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getInvariantUUID();
- }
-
-
- @Test
- public void testSetInvariantUUID() throws Exception {
- GroupDefinitionInfo testSubject;
- String invariantUUID = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setInvariantUUID(invariantUUID);
- }
-
-
- @Test
- public void testGetName() throws Exception {
- GroupDefinitionInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
-
-
- @Test
- public void testSetName() throws Exception {
- GroupDefinitionInfo testSubject;
- String name = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setName(name);
- }
-
-
- @Test
- public void testGetUniqueId() throws Exception {
- GroupDefinitionInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getUniqueId();
- }
-
-
- @Test
- public void testSetUniqueId() throws Exception {
- GroupDefinitionInfo testSubject;
- String uniqueId = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setUniqueId(uniqueId);
- }
-
-
- @Test
- public void testGetGroupUUID() throws Exception {
- GroupDefinitionInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getGroupUUID();
- }
-
-
- @Test
- public void testSetGroupUUID() throws Exception {
- GroupDefinitionInfo testSubject;
- String groupUUID = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setGroupUUID(groupUUID);
- }
-
-
- @Test
- public void testGetVersion() throws Exception {
- GroupDefinitionInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getVersion();
- }
-
-
- @Test
- public void testSetVersion() throws Exception {
- GroupDefinitionInfo testSubject;
- String version = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setVersion(version);
- }
-
-
- @Test
- public void testGetCustomizationUUID() throws Exception {
- GroupDefinitionInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCustomizationUUID();
- }
-
-
- @Test
- public void testSetCustomizationUUID() throws Exception {
- GroupDefinitionInfo testSubject;
- String customizationUUID = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCustomizationUUID(customizationUUID);
- }
-
-
- @Test
- public void testGetIsBase() throws Exception {
- GroupDefinitionInfo testSubject;
- Boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getIsBase();
- }
-
-
- @Test
- public void testSetIsBase() throws Exception {
- GroupDefinitionInfo testSubject;
- Boolean isBase = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setIsBase(isBase);
- }
-
-
- @Test
- public void testGetArtifacts() throws Exception {
- GroupDefinitionInfo testSubject;
- List<ArtifactDefinitionInfo> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getArtifacts();
- }
-
-
- @Test
- public void testSetArtifacts() throws Exception {
- GroupDefinitionInfo testSubject;
- List<ArtifactDefinitionInfo> artifacts = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setArtifacts(artifacts);
- }
-
-
- @Test
- public void testGetProperties() throws Exception {
- GroupDefinitionInfo testSubject;
- List<? extends GroupProperty> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getProperties();
- }
-
-
- @Test
- public void testSetProperties() throws Exception {
- GroupDefinitionInfo testSubject;
- List<? extends GroupProperty> properties = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setProperties(properties);
- }
-
-
- @Test
- public void testGetGroupInstanceUniqueId() throws Exception {
- GroupDefinitionInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getGroupInstanceUniqueId();
- }
-
-
- @Test
- public void testSetGroupInstanceUniqueId() throws Exception {
- GroupDefinitionInfo testSubject;
- String groupInstanceUniqueId = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setGroupInstanceUniqueId(groupInstanceUniqueId);
- }
-
-
- @Test
- public void testToString() throws Exception {
- GroupDefinitionInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
- }
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(GroupDefinitionInfo.class, BeanMatchers.hasValidGettersAndSetters());
+ }
+
+ @Test
+ public void testToString() {
+ (new GroupDefinitionInfo()).toString();
+ }
}
\ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupTemplateInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupTemplateInfoTest.java
index a77c138..03573e1 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupTemplateInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/info/GroupTemplateInfoTest.java
@@ -2,76 +2,16 @@
import org.junit.Test;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
public class GroupTemplateInfoTest {
- private GroupTemplateInfo createTestSubject() {
- return new GroupTemplateInfo();
- }
-
- @Test
- public void testGetGroupName() throws Exception {
- GroupTemplateInfo testSubject;
- String result;
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(GroupTemplateInfo.class, hasValidGettersAndSetters());
+ }
- // default test
- testSubject = createTestSubject();
- result = testSubject.getGroupName();
- }
-
-
- @Test
- public void testSetGroupName() throws Exception {
- GroupTemplateInfo testSubject;
- String groupName = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setGroupName(groupName);
- }
-
-
- @Test
- public void testIsBase() throws Exception {
- GroupTemplateInfo testSubject;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.isBase();
- }
-
-
- @Test
- public void testSetBase() throws Exception {
- GroupTemplateInfo testSubject;
- boolean isBase = false;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setBase(isBase);
- }
-
-
- @Test
- public void testGetArtifactTemplateInfo() throws Exception {
- GroupTemplateInfo testSubject;
- ArtifactTemplateInfo result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getArtifactTemplateInfo();
- }
-
-
- @Test
- public void testSetArtifactTemplateInfo() throws Exception {
- GroupTemplateInfo testSubject;
- ArtifactTemplateInfo artifactTemplateInfo = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setArtifactTemplateInfo(artifactTemplateInfo);
- }
}
\ 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 ca0006d..9886058 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,35 +1,16 @@
package org.openecomp.sdc.be.info;
-import java.util.List;
-
import org.junit.Test;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
public class ServicesWrapperTest {
- private ServicesWrapper createTestSubject() {
- return new ServicesWrapper();
- }
-
- @Test
- public void testGetServices() throws Exception {
- ServicesWrapper testSubject;
- List<ServiceInfo> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getServices();
- }
-
-
- @Test
- public void testSetServices() throws Exception {
- ServicesWrapper testSubject;
- List<ServiceInfo> services = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setServices(services);
- }
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(ServicesWrapper.class, hasValidGettersAndSetters());
+ }
}
\ 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 9b0c5fc..f542019 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
@@ -2,54 +2,13 @@
import org.junit.Test;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
public class ServletJsonResponseTest {
-
- private ServletJsonResponse createTestSubject() {
- return new ServletJsonResponse();
- }
-
-
- @Test
- public void testGetDescription() throws Exception {
- ServletJsonResponse testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDescription();
- }
-
-
- @Test
- public void testSetDescription() throws Exception {
- ServletJsonResponse testSubject;
- String description = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDescription(description);
- }
-
-
- @Test
- public void testGetSource() throws Exception {
- ServletJsonResponse testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getSource();
- }
-
-
- @Test
- public void testSetSource() throws Exception {
- ServletJsonResponse testSubject;
- String source = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setSource(source);
- }
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(ServletJsonResponse.class, hasValidGettersAndSetters());
+ }
}
\ 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 c2a1e82..5642b2f 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,112 +1,21 @@
package org.openecomp.sdc.be.info;
-import java.util.List;
-
import org.junit.Test;
+import com.google.code.beanmatchers.BeanMatchers;
+import static org.hamcrest.MatcherAssert.assertThat;
+
public class ToscaNodeTypeInfoTest {
- private ToscaNodeTypeInfo createTestSubject() {
- return new ToscaNodeTypeInfo();
- }
-
- @Test
- public void testGetNodeName() throws Exception {
- ToscaNodeTypeInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getNodeName();
- }
-
-
- @Test
- public void testSetNodeName() throws Exception {
- ToscaNodeTypeInfo testSubject;
- String nodeName = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setNodeName(nodeName);
- }
-
-
- @Test
- public void testGetTemplateVersion() throws Exception {
- ToscaNodeTypeInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getTemplateVersion();
- }
-
-
- @Test
- public void testSetTemplateVersion() throws Exception {
- ToscaNodeTypeInfo testSubject;
- String templateVersion = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setTemplateVersion(templateVersion);
- }
-
-
- @Test
- public void testGetInterfaces() throws Exception {
- ToscaNodeTypeInfo testSubject;
- List<ToscaNodeTypeInterface> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getInterfaces();
- }
-
-
- @Test
- public void testSetInterfaces() throws Exception {
- ToscaNodeTypeInfo testSubject;
- List<ToscaNodeTypeInterface> interfaces = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setInterfaces(interfaces);
- }
-
-
- @Test
- public void testGetIconPath() throws Exception {
- ToscaNodeTypeInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getIconPath();
- }
-
-
- @Test
- public void testSetIconPath() throws Exception {
- ToscaNodeTypeInfo testSubject;
- String iconPath = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setIconPath(iconPath);
- }
-
-
- @Test
- public void testToString() throws Exception {
- ToscaNodeTypeInfo testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
- }
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(ToscaNodeTypeInfo.class, BeanMatchers.hasValidGettersAndSetters());
+ }
+
+ @Test
+ 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 67b0cdf..c74ce36 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,35 +1,17 @@
package org.openecomp.sdc.be.info;
-import java.util.List;
-
import org.junit.Test;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
+import static org.hamcrest.MatcherAssert.assertThat;
+
public class ToscaNodeTypeInterfaceTest {
- private ToscaNodeTypeInterface createTestSubject() {
- return new ToscaNodeTypeInterface();
- }
-
- @Test
- public void testGetScripts() throws Exception {
- ToscaNodeTypeInterface testSubject;
- List<String> result;
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(ToscaNodeTypeInterface.class, hasValidGettersAndSetters());
+ }
- // default test
- testSubject = createTestSubject();
- result = testSubject.getScripts();
- }
-
-
- @Test
- public void testSetScripts() throws Exception {
- ToscaNodeTypeInterface testSubject;
- List<String> scripts = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setScripts(scripts);
- }
}
\ No newline at end of file