aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java
diff options
context:
space:
mode:
authorDmitry Puzikov <d.puzikov2@partner.samsung.com>2020-03-20 09:11:38 +0100
committerDmitry Puzikov <d.puzikov2@partner.samsung.com>2020-03-20 16:38:32 +0100
commit815674c947f970e9e57e06c8907758f88032b30a (patch)
treeae988c2c1195b0a4112c09259aa2121c3a2e07de /catalog-be/src/test/java
parent50f62b15c29b3760b8496ee101d46c64668aff92 (diff)
Fix unit tests
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>
Diffstat (limited to 'catalog-be/src/test/java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ApiResourceEnumTest.java12
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/RegistrationRequestTest.java73
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/ServerListResponseTest.java25
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicRegistrationResponseTest.java46
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicUnregistrationResponseTest.java12
5 files changed, 58 insertions, 110 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ApiResourceEnumTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ApiResourceEnumTest.java
index 0fe0557656..d2b7b42870 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ApiResourceEnumTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/ApiResourceEnumTest.java
@@ -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");
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/RegistrationRequestTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/RegistrationRequestTest.java
index db22c1edeb..6fa6bffad2 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/RegistrationRequestTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/RegistrationRequestTest.java
@@ -20,70 +20,41 @@
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);
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/ServerListResponseTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/ServerListResponseTest.java
index b89e96696c..d1b3853c47 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/ServerListResponseTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/ServerListResponseTest.java
@@ -20,33 +20,26 @@
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();
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicRegistrationResponseTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicRegistrationResponseTest.java
index ee75237b33..96590e6f15 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicRegistrationResponseTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicRegistrationResponseTest.java
@@ -20,51 +20,23 @@
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();
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicUnregistrationResponseTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicUnregistrationResponseTest.java
index 79088b5d5c..79e43bccb1 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicUnregistrationResponseTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/distribution/api/client/TopicUnregistrationResponseTest.java
@@ -20,22 +20,27 @@
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);
}
}