aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/pom.xml14
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/ComponentInputsMergeBLTest.java11
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java55
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverterTest.java9
4 files changed, 59 insertions, 30 deletions
diff --git a/catalog-be/pom.xml b/catalog-be/pom.xml
index 66e9dc0173..27d5d6d861 100644
--- a/catalog-be/pom.xml
+++ b/catalog-be/pom.xml
@@ -578,6 +578,20 @@
</dependency>
<dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <version>${junitJupiter.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <version>${mockitoJupiter.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/ComponentInputsMergeBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/ComponentInputsMergeBLTest.java
index 954e6094c1..9868e66ff7 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/ComponentInputsMergeBLTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/input/ComponentInputsMergeBLTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -23,6 +23,7 @@ package org.openecomp.sdc.be.components.merge.input;
import fj.data.Either;
import org.junit.Before;
import org.junit.Test;
+import org.junit.jupiter.api.DisplayName;
import org.mockito.Mockito;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
import org.openecomp.sdc.be.components.utils.ObjectGenerator;
@@ -60,6 +61,7 @@ public class ComponentInputsMergeBLTest extends BaseComponentInputsMerge {
}
@Test
+ @DisplayName("When old component has no inputs then return ok")
public void whenOldComponentHasNoInputs_returnOk() {
ActionStatus actionStatus = testInstance.mergeComponents(new Resource(), new Resource());
assertThat(actionStatus).isEqualTo(ActionStatus.OK);
@@ -67,6 +69,7 @@ public class ComponentInputsMergeBLTest extends BaseComponentInputsMerge {
}
@Test
+ @DisplayName("When current resource has no properties no redeclaration of inputs required")
public void whenCurrResourceHasNoProperties_noRedeclarationOFInputsRequired() {
Resource newResource = new ResourceBuilder().setUniqueId(RESOURCE_ID).build();
when(toscaOperationFacade.updateInputsToComponent(emptyList(), RESOURCE_ID)).thenReturn(Either.left(null));
@@ -77,6 +80,7 @@ public class ComponentInputsMergeBLTest extends BaseComponentInputsMerge {
}
@Test
+ @DisplayName("When current resource has no inputs no merge required, update resource with inputs declared in previous version")
public void whenCurrResourceHasNoInputs_noMergeRequired_updateResourceWithInputsDeclaredInPrevVersion() {
List<InputDefinition> prevDeclaredInputs = ObjectGenerator.buildInputs("declared1", "declared2");
currResource.setInputs(null);
@@ -90,6 +94,7 @@ public class ComponentInputsMergeBLTest extends BaseComponentInputsMerge {
}
@Test
+ @DisplayName("Find inputs declared from properties and merge them into new component")
public void findInputsDeclaredFromPropertiesAndMergeThemIntoNewComponent() {
List<InputDefinition> prevDeclaredInputs = ObjectGenerator.buildInputs("declared1", "declared2");
List<InputDefinition> currInputsPreMerge = new ArrayList<>(currResource.getInputs());
@@ -104,6 +109,7 @@ public class ComponentInputsMergeBLTest extends BaseComponentInputsMerge {
}
@Test
+ @DisplayName("Identify already existing inputs and don't merge them into new component")
public void identifyAlreadyExistingInputsAndDontMergeThemIntoNewComponent() {
List<InputDefinition> prevDeclaredInputs = ObjectGenerator.buildInputs("declared1", "declared2", "input1");
List<InputDefinition> prevDeclaredInputsNotPresentInCurrent = ObjectGenerator.buildInputs("declared1", "declared2");
@@ -121,6 +127,7 @@ public class ComponentInputsMergeBLTest extends BaseComponentInputsMerge {
@Test
+ @DisplayName("When failing to update inputs propagate the error")
public void whenFailingToUpdateInputs_propagateTheError() {
Resource newResource = new ResourceBuilder().setUniqueId(RESOURCE_ID).build();
when(toscaOperationFacade.updateInputsToComponent(emptyList(), RESOURCE_ID)).thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java
index 8db8450e87..778552d485 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java
@@ -23,7 +23,8 @@ package org.openecomp.sdc.be.ecomp;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
import org.onap.portalsdk.core.restful.domain.EcompRole;
@@ -40,69 +41,75 @@ public class EcompIntImplTest {
return new EcompIntImpl();
}
- @Test(expected=PortalAPIException.class)
- public void testPushUser() throws Exception {
+ @Test
+ public void testPushUser() {
EcompIntImpl testSubject;
EcompUser user = null;
// default test
testSubject = createTestSubject();
- testSubject.pushUser(user);
+ Assertions.assertThrows(PortalAPIException.class, () -> {
+ testSubject.pushUser(user);
+ });
}
- @Test(expected=PortalAPIException.class)
- public void testEditUser() throws Exception {
+ @Test
+ public void testEditUser() {
EcompIntImpl testSubject;
String loginId = "";
EcompUser user = null;
// default test
testSubject = createTestSubject();
- testSubject.editUser(loginId, user);
+ Assertions.assertThrows(PortalAPIException.class, () -> {
+ testSubject.editUser(loginId, user);
+ });
}
- @Test(expected=PortalAPIException.class)
- public void testGetUser() throws Exception {
+ @Test
+ public void testGetUser() {
EcompIntImpl testSubject;
String loginId = "";
- EcompUser result;
// default test
testSubject = createTestSubject();
- result = testSubject.getUser(loginId);
+ Assertions.assertThrows(PortalAPIException.class, () -> {
+ EcompUser result = testSubject.getUser(loginId);
+ });
}
- @Test(expected=PortalAPIException.class)
- public void testGetUsers() throws Exception {
+ @Test
+ public void testGetUsers() {
EcompIntImpl testSubject;
- List<EcompUser> result;
// default test
testSubject = createTestSubject();
- result = testSubject.getUsers();
+ Assertions.assertThrows(PortalAPIException.class, () -> {
+ List<EcompUser> result = testSubject.getUsers();
+ });
+
}
@Test
- public void testGetAvailableRoles() throws Exception {
+ public void testGetAvailableRoles() throws PortalAPIException{
EcompIntImpl testSubject;
- List<EcompRole> result;
// default test
testSubject = createTestSubject();
- result = testSubject.getAvailableRoles("mock-id");
- assertThat(result).hasSameSizeAs(Role.values());
+ List<EcompRole> result = testSubject.getAvailableRoles("mock-id");
+ assertThat(result).hasSameSizeAs(Role.values());
}
-
- @Test(expected= PortalAPIException.class)
- public void testGetUserRoles() throws Exception {
+ @Test
+ public void testGetUserRoles() {
EcompIntImpl testSubject;
String loginId = "";
- List<EcompRole> result;
// default test
testSubject = createTestSubject();
- result = testSubject.getUserRoles(loginId);
+ Assertions.assertThrows(PortalAPIException.class, () -> {
+ List<EcompRole> result = testSubject.getUserRoles(loginId);
+ });
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverterTest.java
index bbe0c176c8..68e23ceb66 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverterTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverterTest.java
@@ -22,7 +22,8 @@ package org.openecomp.sdc.be.ecomp.converters;
import static org.assertj.core.api.Assertions.assertThat;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
import org.onap.portalsdk.core.restful.domain.EcompRole;
import org.openecomp.sdc.be.user.Role;
@@ -42,10 +43,10 @@ public class EcompRoleConverterTest {
}
}
- @Test(expected = PortalAPIException.class)
- public void testConvertEcompRoleToRoleFailure() throws PortalAPIException {
+ @Test
+ public void testConvertEcompRoleToRoleFailure() {
EcompRole ecompRole = new EcompRole();
ecompRole.setName("mock-name");
- EcompRoleConverter.convertEcompRoleToRole(ecompRole);
+ Assertions.assertThrows(PortalAPIException.class, () -> EcompRoleConverter.convertEcompRoleToRole(ecompRole));
}
}