summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-03-25 20:51:48 +0000
committerVasyl Razinkov <vasyl.razinkov@est.tech>2021-03-25 20:52:52 +0000
commit714493fb9588598b969711bf761f301ba8ebe286 (patch)
treefa10ba6312784131ec708ba592b8d58088045c9b /openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest
parenta45577d6d9e5a67ea8313b760b5180c974fc63d7 (diff)
Improve test coverage
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: I88e5bf627510b72322d061df5d34bc3600c47eb5 Issue-ID: SDC-3428
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntityTest.java60
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntityTest.java60
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/ServiceArtifactEntityTest.java60
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/ServiceTemplateEntityTest.java60
4 files changed, 108 insertions, 132 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntityTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntityTest.java
index b201e9d24d..dfd0b887f5 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntityTest.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/EnrichedServiceArtifactEntityTest.java
@@ -20,45 +20,45 @@
package org.openecomp.core.model.types;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.mock;
+
+import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.openecomp.sdc.common.errors.SdcRuntimeException;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.io.IOException;
-
-import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.mock;
-
public class EnrichedServiceArtifactEntityTest {
- private static final byte[] BYTE_ARRAY = new byte[] {0xA, 0xB, 0xC, 0xD};
+ private static final byte[] BYTE_ARRAY = new byte[]{0xA, 0xB, 0xC, 0xD};
- @Test
- public void shouldHaveValidGettersAndSetters() {
- assertThat(EnrichedServiceArtifactEntity.class,
- hasValidGettersAndSettersExcluding("entityType", "firstClassCitizenId", "serviceArtifact"));
+ private static ServiceArtifact createServiceArtifact() {
+ ServiceArtifact serviceArtifact = new ServiceArtifact();
+ serviceArtifact.setVspId("someIdd");
+ serviceArtifact.setVersion(new Version("best"));
+ serviceArtifact.setName("name");
+ serviceArtifact.setContentData(BYTE_ARRAY);
+ return serviceArtifact;
}
@Test
public void shouldReturnNonEmptyEntityType() {
EnrichedServiceArtifactEntity entity =
- new EnrichedServiceArtifactEntity();
+ new EnrichedServiceArtifactEntity();
assertTrue(StringUtils.isNoneEmpty(entity.getEntityType()));
}
@Test
public void shouldHaveFirstClassCitizenIdEqualToVspId() {
EnrichedServiceArtifactEntity entity =
- new EnrichedServiceArtifactEntity(createServiceArtifact());
+ new EnrichedServiceArtifactEntity(createServiceArtifact());
assertEquals(entity.getId(), entity.getFirstClassCitizenId());
}
@@ -66,7 +66,7 @@ public class EnrichedServiceArtifactEntityTest {
public void serviceArtifactGetterShouldReturnCorrectData() throws IOException {
ServiceArtifact serviceArtifact = createServiceArtifact();
EnrichedServiceArtifactEntity entity =
- new EnrichedServiceArtifactEntity(serviceArtifact);
+ new EnrichedServiceArtifactEntity(serviceArtifact);
ServiceArtifact actual = entity.getServiceArtifact();
@@ -76,20 +76,14 @@ public class EnrichedServiceArtifactEntityTest {
assertArrayEquals(IOUtils.toByteArray(serviceArtifact.getContent()), IOUtils.toByteArray(actual.getContent()));
}
- @Test(expected = SdcRuntimeException.class)
+ @Test
public void shouldFailOnNullContentBytesSupplied() {
ServiceArtifact serviceArtifactMock = mock(ServiceArtifact.class);
- given(serviceArtifactMock.getContent()).willAnswer(invocation -> { throw new IOException("Test exception"); } );
- EnrichedServiceArtifactEntity entity =
- new EnrichedServiceArtifactEntity(serviceArtifactMock);
- }
-
- private static ServiceArtifact createServiceArtifact() {
- ServiceArtifact serviceArtifact = new ServiceArtifact();
- serviceArtifact.setVspId("someIdd");
- serviceArtifact.setVersion(new Version("best"));
- serviceArtifact.setName("name");
- serviceArtifact.setContentData(BYTE_ARRAY);
- return serviceArtifact;
+ given(serviceArtifactMock.getContent()).willAnswer(invocation -> {
+ throw new IOException("Test exception");
+ });
+ assertThrows(SdcRuntimeException.class, () -> {
+ new EnrichedServiceArtifactEntity(serviceArtifactMock);
+ });
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntityTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntityTest.java
index 671a0a2d88..6654436e72 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntityTest.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/EnrichedServiceTemplateEntityTest.java
@@ -20,45 +20,45 @@
package org.openecomp.core.model.types;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.mock;
+
+import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.openecomp.sdc.common.errors.SdcRuntimeException;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.io.IOException;
-
-import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.mock;
-
public class EnrichedServiceTemplateEntityTest {
- private static final byte[] BYTE_ARRAY = new byte[] {0xA, 0xB, 0xC, 0xD};
+ private static final byte[] BYTE_ARRAY = new byte[]{0xA, 0xB, 0xC, 0xD};
- @Test
- public void shouldHaveValidGettersAndSetters() {
- assertThat(EnrichedServiceTemplateEntity.class,
- hasValidGettersAndSettersExcluding("entityType", "firstClassCitizenId", "serviceTemplate"));
+ private static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate serviceTemplate = new ServiceTemplate();
+ serviceTemplate.setVspId("someIdd");
+ serviceTemplate.setVersion(new Version("best"));
+ serviceTemplate.setName("name");
+ serviceTemplate.setContentData(BYTE_ARRAY);
+ return serviceTemplate;
}
@Test
public void shouldReturnNonEmptyEntityType() {
EnrichedServiceTemplateEntity entity =
- new EnrichedServiceTemplateEntity();
+ new EnrichedServiceTemplateEntity();
assertTrue(StringUtils.isNoneEmpty(entity.getEntityType()));
}
@Test
public void shouldHaveFirstClassCitizenIdEqualToVspId() {
EnrichedServiceTemplateEntity entity =
- new EnrichedServiceTemplateEntity(createServiceTemplate());
+ new EnrichedServiceTemplateEntity(createServiceTemplate());
assertEquals(entity.getId(), entity.getFirstClassCitizenId());
}
@@ -66,7 +66,7 @@ public class EnrichedServiceTemplateEntityTest {
public void serviceTemplateGetterShouldReturnCorrectData() throws IOException {
ServiceTemplate serviceTemplate = createServiceTemplate();
EnrichedServiceTemplateEntity entity =
- new EnrichedServiceTemplateEntity(serviceTemplate);
+ new EnrichedServiceTemplateEntity(serviceTemplate);
ServiceTemplate actual = entity.getServiceTemplate();
@@ -76,20 +76,14 @@ public class EnrichedServiceTemplateEntityTest {
assertArrayEquals(IOUtils.toByteArray(serviceTemplate.getContent()), IOUtils.toByteArray(actual.getContent()));
}
- @Test(expected = SdcRuntimeException.class)
+ @Test
public void shouldFailOnNullContentBytesSupplied() {
ServiceTemplate serviceTemplateMock = mock(ServiceTemplate.class);
- given(serviceTemplateMock.getContent()).willAnswer(invocation -> { throw new IOException("Test exception"); } );
- EnrichedServiceTemplateEntity entity =
- new EnrichedServiceTemplateEntity(serviceTemplateMock);
- }
-
- private static ServiceTemplate createServiceTemplate() {
- ServiceTemplate serviceTemplate = new ServiceTemplate();
- serviceTemplate.setVspId("someIdd");
- serviceTemplate.setVersion(new Version("best"));
- serviceTemplate.setName("name");
- serviceTemplate.setContentData(BYTE_ARRAY);
- return serviceTemplate;
+ given(serviceTemplateMock.getContent()).willAnswer(invocation -> {
+ throw new IOException("Test exception");
+ });
+ assertThrows(SdcRuntimeException.class, () -> {
+ new EnrichedServiceTemplateEntity(serviceTemplateMock);
+ });
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/ServiceArtifactEntityTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/ServiceArtifactEntityTest.java
index 291abee7f9..109f8d0bee 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/ServiceArtifactEntityTest.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/ServiceArtifactEntityTest.java
@@ -20,45 +20,45 @@
package org.openecomp.core.model.types;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.mock;
+
+import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.openecomp.sdc.common.errors.SdcRuntimeException;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.io.IOException;
-
-import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.mock;
-
public class ServiceArtifactEntityTest {
- private static final byte[] BYTE_ARRAY = new byte[] {0xA, 0xB, 0xC, 0xD};
+ private static final byte[] BYTE_ARRAY = new byte[]{0xA, 0xB, 0xC, 0xD};
- @Test
- public void shouldHaveValidGettersAndSetters() {
- assertThat(ServiceArtifactEntity.class,
- hasValidGettersAndSettersExcluding("entityType", "firstClassCitizenId", "serviceArtifact"));
+ private static ServiceArtifact createServiceArtifact() {
+ ServiceArtifact serviceArtifact = new ServiceArtifact();
+ serviceArtifact.setVspId("someIdd");
+ serviceArtifact.setVersion(new Version("best"));
+ serviceArtifact.setName("name");
+ serviceArtifact.setContentData(BYTE_ARRAY);
+ return serviceArtifact;
}
@Test
public void shouldReturnNonEmptyEntityType() {
ServiceArtifactEntity entity =
- new ServiceArtifactEntity();
+ new ServiceArtifactEntity();
assertTrue(StringUtils.isNoneEmpty(entity.getEntityType()));
}
@Test
public void shouldHaveFirstClassCitizenIdEqualToVspId() {
ServiceArtifactEntity entity =
- new ServiceArtifactEntity(createServiceArtifact());
+ new ServiceArtifactEntity(createServiceArtifact());
assertEquals(entity.getId(), entity.getFirstClassCitizenId());
}
@@ -66,7 +66,7 @@ public class ServiceArtifactEntityTest {
public void serviceArtifactGetterShouldReturnCorrectData() throws IOException {
ServiceArtifact serviceArtifact = createServiceArtifact();
ServiceArtifactEntity entity =
- new ServiceArtifactEntity(serviceArtifact);
+ new ServiceArtifactEntity(serviceArtifact);
ServiceArtifact actual = entity.getServiceArtifact();
@@ -76,20 +76,14 @@ public class ServiceArtifactEntityTest {
assertArrayEquals(IOUtils.toByteArray(serviceArtifact.getContent()), IOUtils.toByteArray(actual.getContent()));
}
- @Test(expected = SdcRuntimeException.class)
+ @Test
public void shouldFailOnNullContentBytesSupplied() {
ServiceArtifact serviceArtifactMock = mock(ServiceArtifact.class);
- given(serviceArtifactMock.getContent()).willAnswer(invocation -> { throw new IOException("Test exception"); } );
- ServiceArtifactEntity entity =
- new ServiceArtifactEntity(serviceArtifactMock);
- }
-
- private static ServiceArtifact createServiceArtifact() {
- ServiceArtifact serviceArtifact = new ServiceArtifact();
- serviceArtifact.setVspId("someIdd");
- serviceArtifact.setVersion(new Version("best"));
- serviceArtifact.setName("name");
- serviceArtifact.setContentData(BYTE_ARRAY);
- return serviceArtifact;
+ given(serviceArtifactMock.getContent()).willAnswer(invocation -> {
+ throw new IOException("Test exception");
+ });
+ assertThrows(SdcRuntimeException.class, () -> {
+ new ServiceArtifactEntity(serviceArtifactMock);
+ });
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/ServiceTemplateEntityTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/ServiceTemplateEntityTest.java
index f64c04874e..ad4d6b1fe4 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/ServiceTemplateEntityTest.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/test/java/org/openecomp/core/model/types/ServiceTemplateEntityTest.java
@@ -20,45 +20,45 @@
package org.openecomp.core.model.types;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.mock;
+
+import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.openecomp.sdc.common.errors.SdcRuntimeException;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.io.IOException;
-
-import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.mock;
-
public class ServiceTemplateEntityTest {
- private static final byte[] BYTE_ARRAY = new byte[] {0xA, 0xB, 0xC, 0xD};
+ private static final byte[] BYTE_ARRAY = new byte[]{0xA, 0xB, 0xC, 0xD};
- @Test
- public void shouldHaveValidGettersAndSetters() {
- assertThat(ServiceTemplateEntity.class,
- hasValidGettersAndSettersExcluding("entityType", "firstClassCitizenId", "serviceTemplate"));
+ private static ServiceTemplate createServiceTemplate() {
+ ServiceTemplate serviceTemplate = new ServiceTemplate();
+ serviceTemplate.setVspId("someIdd");
+ serviceTemplate.setVersion(new Version("best"));
+ serviceTemplate.setName("name");
+ serviceTemplate.setContentData(BYTE_ARRAY);
+ return serviceTemplate;
}
@Test
public void shouldReturnNonEmptyEntityType() {
ServiceTemplateEntity entity =
- new ServiceTemplateEntity();
+ new ServiceTemplateEntity();
assertTrue(StringUtils.isNoneEmpty(entity.getEntityType()));
}
@Test
public void shouldHaveFirstClassCitizenIdEqualToVspId() {
ServiceTemplateEntity entity =
- new ServiceTemplateEntity(createServiceTemplate());
+ new ServiceTemplateEntity(createServiceTemplate());
assertEquals(entity.getId(), entity.getFirstClassCitizenId());
}
@@ -66,7 +66,7 @@ public class ServiceTemplateEntityTest {
public void serviceTemplateGetterShouldReturnCorrectData() throws IOException {
ServiceTemplate serviceTemplate = createServiceTemplate();
ServiceTemplateEntity entity =
- new ServiceTemplateEntity(serviceTemplate);
+ new ServiceTemplateEntity(serviceTemplate);
ServiceTemplate actual = entity.getServiceTemplate();
@@ -76,20 +76,14 @@ public class ServiceTemplateEntityTest {
assertArrayEquals(IOUtils.toByteArray(serviceTemplate.getContent()), IOUtils.toByteArray(actual.getContent()));
}
- @Test(expected = SdcRuntimeException.class)
+ @Test
public void shouldFailOnNullContentBytesSupplied() {
ServiceTemplate serviceTemplateMock = mock(ServiceTemplate.class);
- given(serviceTemplateMock.getContent()).willAnswer(invocation -> { throw new IOException("Test exception"); } );
- ServiceTemplateEntity entity =
- new ServiceTemplateEntity(serviceTemplateMock);
- }
-
- private static ServiceTemplate createServiceTemplate() {
- ServiceTemplate serviceTemplate = new ServiceTemplate();
- serviceTemplate.setVspId("someIdd");
- serviceTemplate.setVersion(new Version("best"));
- serviceTemplate.setName("name");
- serviceTemplate.setContentData(BYTE_ARRAY);
- return serviceTemplate;
+ given(serviceTemplateMock.getContent()).willAnswer(invocation -> {
+ throw new IOException("Test exception");
+ });
+ assertThrows(SdcRuntimeException.class, () -> {
+ new ServiceTemplateEntity(serviceTemplateMock);
+ });
}
}