Fix unit tests 34/104034/3
authorDmitry Puzikov <d.puzikov2@partner.samsung.com>
Fri, 20 Mar 2020 08:11:38 +0000 (09:11 +0100)
committerDmitry Puzikov <d.puzikov2@partner.samsung.com>
Fri, 20 Mar 2020 15:38:32 +0000 (16:38 +0100)
Add asserts where required, fix tiny issues.

Replaced getters-setters with Lombok annotations.

Change-Id: I9d75c871870fffe82876e14dd2eb9d3585ecb916
Issue-ID: SDC-2708
Signed-off-by: Dmitry Puzikov <d.puzikov2@partner.samsung.com>
catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/ApiResourceEnum.java
catalog-be/src/main/java/org/openecomp/sdc/be/distribution/api/client/RegistrationRequest.java
catalog-be/src/main/java/org/openecomp/sdc/be/distribution/api/client/ServerListResponse.java
catalog-be/src/main/java/org/openecomp/sdc/be/distribution/api/client/TopicRegistrationResponse.java
catalog-be/src/main/java/org/openecomp/sdc/be/distribution/api/client/TopicUnregistrationResponse.java
catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ApiResourceEnumTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/RegistrationRequestTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/ServerListResponseTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicRegistrationResponseTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicUnregistrationResponseTest.java

index 1a10ac9..7f217b9 100644 (file)
 
 package org.openecomp.sdc.be.components.validation;
 
+import lombok.Getter;
+
 /**
  * Created by chaya on 11/14/2017.
  */
+@Getter
 public enum ApiResourceEnum {
 
     ENVIRONMENT_ID("Environment ID"),
@@ -34,9 +37,4 @@ public enum ApiResourceEnum {
     ApiResourceEnum(String value) {
         this.value = value;
     }
-
-    public String getValue() {
-        return this.value;
-    }
-
 }
index 8377749..1ce3621 100644 (file)
 package org.openecomp.sdc.be.distribution.api.client;
 
 import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
 
+@Getter
+@Setter
 public class RegistrationRequest {
     private String apiPublicKey;
     private String distrEnvName;
@@ -41,39 +45,4 @@ public class RegistrationRequest {
         this.distEnvEndPoints = distEnvEndPoints;
         this.isConsumerToSdcDistrStatusTopic = isConsumerToSdcDistrStatusTopic;
     }
-
-    public String getApiPublicKey() {
-        return apiPublicKey;
-    }
-
-    public String getDistrEnvName() {
-        return distrEnvName;
-    }
-
-    public Boolean getIsConsumerToSdcDistrStatusTopic() {
-        return isConsumerToSdcDistrStatusTopic;
-    }
-    public List<String> getDistEnvEndPoints() {
-        return distEnvEndPoints;
-    }
-
-    public void setDistEnvEndPoints(List<String> distEnvEndPoints) {
-        this.distEnvEndPoints = distEnvEndPoints;
-    }
-
-    public String getManagerApiPublicKey() {
-        return managerApiPublicKey;
-    }
-
-    public void setManagerApiPublicKey(String managerApiPublicKey) {
-        this.managerApiPublicKey = managerApiPublicKey;
-    }
-
-    public String getManagerApiSecretKey() {
-        return managerApiSecretKey;
-    }
-
-    public void setManagerApiSecretKey(String managerApiSecretKey) {
-        this.managerApiSecretKey = managerApiSecretKey;
-    }
 }
index 2eebedf..b0db19f 100644 (file)
 package org.openecomp.sdc.be.distribution.api.client;
 
 import java.util.List;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
 
+@Getter
+@Setter
+@NoArgsConstructor(force = true)
 public class ServerListResponse {
-
     private List<String> uebServerList;
-
-    public List<String> getUebServerList() {
-        return uebServerList;
-    }
-
-    public void setUebServerList(List<String> uebServerList) {
-        this.uebServerList = uebServerList;
-    }
 }
index 5d1b065..6b3e9e1 100644 (file)
 
 package org.openecomp.sdc.be.distribution.api.client;
 
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@Getter
+@Setter
+@NoArgsConstructor(force = true)
 public class TopicRegistrationResponse {
     String distrNotificationTopicName;
     String distrStatusTopicName;
-
-    public void setDistrNotificationTopicName(String distrNotificationTopicName) {
-        this.distrNotificationTopicName = distrNotificationTopicName;
-    }
-
-    public void setDistrStatusTopicName(String distrStatusTopicName) {
-        this.distrStatusTopicName = distrStatusTopicName;
-    }
-
-    public String getDistrNotificationTopicName() {
-        return distrNotificationTopicName;
-    }
-
-    public String getDistrStatusTopicName() {
-        return distrStatusTopicName;
-    }
 }
index 621cd37..55c3bae 100644 (file)
@@ -20,6 +20,9 @@
 
 package org.openecomp.sdc.be.distribution.api.client;
 
+import lombok.Getter;
+
+@Getter
 public class TopicUnregistrationResponse {
     String distrNotificationTopicName;
     String distrStatusTopicName;
@@ -33,20 +36,4 @@ public class TopicUnregistrationResponse {
         this.notificationUnregisterResult = notificationUnregisterResult;
         this.statusUnregisterResult = statusUnregisterResult;
     }
-
-    public String getDistrNotificationTopicName() {
-        return distrNotificationTopicName;
-    }
-
-    public String getDistrStatusTopicName() {
-        return distrStatusTopicName;
-    }
-
-    public CambriaOperationStatus getNotificationUnregisterResult() {
-        return notificationUnregisterResult;
-    }
-
-    public CambriaOperationStatus getStatusUnregisterResult() {
-        return statusUnregisterResult;
-    }
 }
index 0fe0557..d2b7b42 100644 (file)
@@ -20,6 +20,9 @@
 
 package org.openecomp.sdc.be.components.validation;
 
+
+import static org.assertj.core.api.Assertions.assertThat;
+
 import org.junit.Test;
 
 public class ApiResourceEnumTest {
@@ -28,13 +31,14 @@ public class ApiResourceEnumTest {
                return ApiResourceEnum.ENVIRONMENT_ID;
        }
 
-       @Test
-       public void testGetValue() throws Exception {
+       @Test
+       public void testApiResourceEnumConstructor() {
                ApiResourceEnum testSubject;
-               String result;
 
                // default test
                testSubject = createTestSubject();
-               result = testSubject.getValue();
+               assertThat(testSubject)
+                               .isInstanceOf(ApiResourceEnum.class)
+                               .hasFieldOrPropertyWithValue("value", "Environment ID");
        }
 }
index db22c1e..6fa6bff 100644 (file)
 
 package org.openecomp.sdc.be.distribution.api.client;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
 import org.junit.Test;
 
 import java.util.LinkedList;
 import java.util.List;
 
 public class RegistrationRequestTest {
+       private static final String API_KEY = "mock-api-key";
+       private static final String DISTR_ENV_NAME = "mock-distr-env-name";
 
        private RegistrationRequest createTestSubject() {
-               return new RegistrationRequest("", "", false);
-       }
-       
-       @Test
-       public void testConstructor() throws Exception {
-               List<String> distEnvEndPoints = new LinkedList<>();
-               new RegistrationRequest("mock", "mock", distEnvEndPoints , false);
-       }
-       
-       @Test
-       public void testGetApiPublicKey() throws Exception {
-               RegistrationRequest testSubject;
-               String result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getApiPublicKey();
+               return new RegistrationRequest(API_KEY, DISTR_ENV_NAME, false);
        }
 
        @Test
-       public void testGetDistrEnvName() throws Exception {
-               RegistrationRequest testSubject;
-               String result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getDistrEnvName();
-       }
-
-       @Test
-       public void testGetIsConsumerToSdcDistrStatusTopic() throws Exception {
-               RegistrationRequest testSubject;
-               Boolean result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getIsConsumerToSdcDistrStatusTopic();
-       }
-
-       @Test
-       public void testGetDistEnvEndPoints() throws Exception {
-               RegistrationRequest testSubject;
-               List<String> result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getDistEnvEndPoints();
+       public void testConstructorThreeArgs() throws Exception {
+               List<String> distEnvEndPoints = new LinkedList<>();
+               RegistrationRequest request = new RegistrationRequest(API_KEY, DISTR_ENV_NAME, true );
+               assertThat(request)
+                               .isInstanceOf(RegistrationRequest.class)
+                               .hasFieldOrPropertyWithValue("apiPublicKey", API_KEY)
+                               .hasFieldOrPropertyWithValue("distrEnvName", DISTR_ENV_NAME)
+                               .hasFieldOrPropertyWithValue("isConsumerToSdcDistrStatusTopic", true);
        }
 
        @Test
-       public void testSetDistEnvEndPoints() throws Exception {
-               RegistrationRequest testSubject;
-               List<String> distEnvEndPoints = null;
-
-               // default test
-               testSubject = createTestSubject();
-               testSubject.setDistEnvEndPoints(distEnvEndPoints);
+       public void testConstructorFourArgs() throws Exception {
+               List<String> distEnvEndPoints = new LinkedList<>();
+               RegistrationRequest request = new RegistrationRequest(API_KEY, DISTR_ENV_NAME, distEnvEndPoints , false);
+               assertThat(request)
+                               .isInstanceOf(RegistrationRequest.class)
+                               .hasFieldOrPropertyWithValue("apiPublicKey", API_KEY)
+                               .hasFieldOrPropertyWithValue("distrEnvName", DISTR_ENV_NAME)
+                               .hasFieldOrPropertyWithValue("distEnvEndPoints", distEnvEndPoints)
+                               .hasFieldOrPropertyWithValue("isConsumerToSdcDistrStatusTopic", false);
        }
 }
index b89e966..d1b3853 100644 (file)
 
 package org.openecomp.sdc.be.distribution.api.client;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.ArrayList;
 import org.junit.Test;
 
 import java.util.List;
 
 public class ServerListResponseTest {
-
-       private ServerListResponse createTestSubject() {
-               return new ServerListResponse();
-       }
-
        @Test
-       public void testGetUebServerList() throws Exception {
+       public void testServerResponseCOnstructor() {
                ServerListResponse testSubject;
-               List<String> result;
 
                // default test
                testSubject = createTestSubject();
-               result = testSubject.getUebServerList();
+               assertThat(testSubject)
+                               .isInstanceOf(ServerListResponse.class)
+                               .hasFieldOrPropertyWithValue("uebServerList", null);
        }
 
-       @Test
-       public void testSetUebServerList() throws Exception {
-               ServerListResponse testSubject;
-               List<String> uebServerList = null;
-
-               // default test
-               testSubject = createTestSubject();
-               testSubject.setUebServerList(uebServerList);
+       private ServerListResponse createTestSubject() {
+               return new ServerListResponse();
        }
 }
index ee75237..96590e6 100644 (file)
 
 package org.openecomp.sdc.be.distribution.api.client;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
 import org.junit.Test;
 
 public class TopicRegistrationResponseTest {
-
-       private TopicRegistrationResponse createTestSubject() {
-               return new TopicRegistrationResponse();
-       }
-
-       @Test
-       public void testSetDistrNotificationTopicName() throws Exception {
-               TopicRegistrationResponse testSubject;
-               String distrNotificationTopicName = "";
-
-               // default test
-               testSubject = createTestSubject();
-               testSubject.setDistrNotificationTopicName(distrNotificationTopicName);
-       }
-
-       @Test
-       public void testSetDistrStatusTopicName() throws Exception {
-               TopicRegistrationResponse testSubject;
-               String distrStatusTopicName = "";
-
-               // default test
-               testSubject = createTestSubject();
-               testSubject.setDistrStatusTopicName(distrStatusTopicName);
-       }
-
        @Test
-       public void testGetDistrNotificationTopicName() throws Exception {
+       public void testTopicRegistrationResponseConstructor() throws Exception {
                TopicRegistrationResponse testSubject;
-               String result;
-
                // default test
                testSubject = createTestSubject();
-               result = testSubject.getDistrNotificationTopicName();
+               assertThat(testSubject)
+                               .isInstanceOf(TopicRegistrationResponse.class)
+                               .hasFieldOrPropertyWithValue("distrNotificationTopicName", null)
+                               .hasFieldOrPropertyWithValue("distrStatusTopicName", null);
        }
 
-       @Test
-       public void testGetDistrStatusTopicName() throws Exception {
-               TopicRegistrationResponse testSubject;
-               String result;
-
-               // default test
-               testSubject = createTestSubject();
-               result = testSubject.getDistrStatusTopicName();
+       private TopicRegistrationResponse createTestSubject() {
+               return new TopicRegistrationResponse();
        }
 }
index 79088b5..79e43bc 100644 (file)
 
 package org.openecomp.sdc.be.distribution.api.client;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
 import org.junit.Test;
 
 public class TopicUnregistrationResponseTest {
+       private static final String NOTIF_TOPIC_NAME = "notif-mock-topic-name";
+       private static final String STATUS_TOPIC_NAME = "status-mock-topic-name";
 
        private TopicUnregistrationResponse createTestSubject() {
-               return new TopicUnregistrationResponse("", "", CambriaOperationStatus.AUTHENTICATION_ERROR, CambriaOperationStatus.AUTHENTICATION_ERROR);
+               return new TopicUnregistrationResponse(NOTIF_TOPIC_NAME, STATUS_TOPIC_NAME, CambriaOperationStatus.AUTHENTICATION_ERROR, CambriaOperationStatus.AUTHENTICATION_ERROR);
        }
 
        @Test
-       public void testGetDistrNotificationTopicName() throws Exception {
+       public void testTopicUnregistrationResponseConstructor() throws Exception {
                TopicUnregistrationResponse testSubject;
                String result;
 
                // default test
                testSubject = createTestSubject();
                result = testSubject.getDistrNotificationTopicName();
+               assertThat(result).isEqualTo(NOTIF_TOPIC_NAME);
        }
 
        @Test
@@ -46,6 +51,7 @@ public class TopicUnregistrationResponseTest {
                // default test
                testSubject = createTestSubject();
                result = testSubject.getDistrStatusTopicName();
+               assertThat(result).isEqualTo(STATUS_TOPIC_NAME);
        }
 
        @Test
@@ -56,6 +62,7 @@ public class TopicUnregistrationResponseTest {
                // default test
                testSubject = createTestSubject();
                result = testSubject.getNotificationUnregisterResult();
+               assertThat(result).isEqualTo(CambriaOperationStatus.AUTHENTICATION_ERROR);
        }
 
        @Test
@@ -66,5 +73,6 @@ public class TopicUnregistrationResponseTest {
                // default test
                testSubject = createTestSubject();
                result = testSubject.getStatusUnregisterResult();
+               assertThat(result).isEqualTo(CambriaOperationStatus.AUTHENTICATION_ERROR);
        }
 }