summaryrefslogtreecommitdiffstats
path: root/dcaedt_tools
diff options
context:
space:
mode:
Diffstat (limited to 'dcaedt_tools')
-rw-r--r--dcaedt_tools/pom.xml6
-rw-r--r--dcaedt_tools/src/test/java/BaseTest.java29
-rw-r--r--dcaedt_tools/src/test/java/DeployTemplateTest.java5
-rw-r--r--dcaedt_tools/src/test/java/TemplateContainerTest.java2
4 files changed, 20 insertions, 22 deletions
diff --git a/dcaedt_tools/pom.xml b/dcaedt_tools/pom.xml
index 2109bc9..0d2c31f 100644
--- a/dcaedt_tools/pom.xml
+++ b/dcaedt_tools/pom.xml
@@ -217,13 +217,13 @@
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
- <version>1.6.4</version>
+ <version>2.0.0-beta.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <version>1.6.4</version>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <version>2.0.0-beta.5</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/dcaedt_tools/src/test/java/BaseTest.java b/dcaedt_tools/src/test/java/BaseTest.java
index d3a6ed5..16372e0 100644
--- a/dcaedt_tools/src/test/java/BaseTest.java
+++ b/dcaedt_tools/src/test/java/BaseTest.java
@@ -1,7 +1,6 @@
import org.junit.Before;
-import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
import org.onap.sdc.dcae.composition.restmodels.sdc.Resource;
import org.onap.sdc.dcae.composition.restmodels.sdc.ResourceDetailed;
import utilities.IDcaeRestClient;
@@ -12,11 +11,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
abstract class BaseTest {
static final String USER_ID = "userId";
static final String TEMPLATE_INFO_NAME = "templateInfoName";
@@ -44,31 +41,26 @@ abstract class BaseTest {
@Before
public void setup() {
- when(dcaeRestClient.getUserId()).thenReturn(USER_ID);
- mockGetAllVfcmt();
+ MockitoAnnotations.initMocks(this);
+
mockGetCatalog();
- mockGetItemModel();
- mockGetItemType();
- mockCheckoutVfcmtAndCreateResource();
- when(dcaeRestClient.saveComposition(anyString(), anyString())).thenReturn("Composition Created");
}
- private void mockCheckoutVfcmtAndCreateResource() {
+ void mockCheckoutVfcmtAndCreateResource() {
ResourceDetailed resourceDetailed = new ResourceDetailed();
resourceDetailed.setName(VFCMT_NAME1);
resourceDetailed.setUuid(UUID1);
resourceDetailed.setLifecycleState("NOT_CERTIFIED_CHECKOUT");
resourceDetailed.setLastUpdaterUserId(USER_ID);
- when(dcaeRestClient.checkoutVfcmt(anyString())).thenReturn(resourceDetailed);
when(dcaeRestClient.createResource(any())).thenReturn(resourceDetailed);
}
- private void mockGetItemType() {
- when(dcaeRestClient.getItemType(anyString(), anyString())).thenReturn("{\"data\":{\"type\":{\"itemId\":\"e45ec9d7-01df-4cb1-896f-aff2a6ca5a8b/tosca.dcae.nodes.cdapApp.Map\", \"typeinfo\":\"typeInfo\"}}}");
+ void mockGetItemType() {
+ when(dcaeRestClient.getItemType(any(), any())).thenReturn("{\"data\":{\"type\":{\"itemId\":\"e45ec9d7-01df-4cb1-896f-aff2a6ca5a8b/tosca.dcae.nodes.cdapApp.Map\", \"typeinfo\":\"typeInfo\"}}}");
}
- private void mockGetItemModel() {
- when(dcaeRestClient.getItemModel(anyString())).thenReturn("{\"data\":{\"model\":{\"itemId\":\"\",\"nodes\":[{\"capability\":{\"type\":\"someType\"}, \"type\":\"type\", \"name\":\"SomeNameFromRequirement\", \"requirements\":[{\"name\":\"SomeNameFromRequirement\"}], \"properties\":[{}], \"capabilities\":[{\"name\":\"SomeNameToCapability\"}],\"type\":\"type\"}]}}}",
+ void mockGetItemModel() {
+ when(dcaeRestClient.getItemModel(any())).thenReturn("{\"data\":{\"model\":{\"itemId\":\"\",\"nodes\":[{\"capability\":{\"type\":\"someType\"}, \"type\":\"type\", \"name\":\"SomeNameFromRequirement\", \"requirements\":[{\"name\":\"SomeNameFromRequirement\"}], \"properties\":[{}], \"capabilities\":[{\"name\":\"SomeNameToCapability\"}],\"type\":\"type\"}]}}}",
"{\"data\":{\"model\":{\"itemId\":\"\",\"nodes\":[{\"capability\":{\"type\":\"someType\"}, \"type\":\"type\", \"name\":\"SomeNameToCapability\", \"requirements\":[{\"name\":\"SomeNameFromRequirement\"}], \"properties\":[{}], \"capabilities\":[{\"name\":\"SomeNameToCapability\"}],\"type\":\"type\"}]}}}");
}
@@ -88,11 +80,10 @@ abstract class BaseTest {
item.setName(ITEM_NAME3);
items.add(item);
catalog.put(ELEMENT_NAME3, items);
- when(dcaeRestClient.getDcaeCatalog()).thenReturn(catalog);
}
- private void mockGetAllVfcmt() {
+ void mockGetAllVfcmt() {
List<ResourceDetailed> resourceDetaileds = new ArrayList<>();
ResourceDetailed resourceDetailed = new ResourceDetailed();
resourceDetailed.setName(VFCMT_NAME1);
diff --git a/dcaedt_tools/src/test/java/DeployTemplateTest.java b/dcaedt_tools/src/test/java/DeployTemplateTest.java
index 6a8a019..0dc35f9 100644
--- a/dcaedt_tools/src/test/java/DeployTemplateTest.java
+++ b/dcaedt_tools/src/test/java/DeployTemplateTest.java
@@ -7,6 +7,7 @@ import tools.DeployTemplate;
import java.util.*;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -23,6 +24,10 @@ public class DeployTemplateTest extends BaseTest {
@Override
public void setup() {
super.setup();
+ super.mockGetAllVfcmt();
+ super.mockCheckoutVfcmtAndCreateResource();
+ when(dcaeRestClient.getUserId()).thenReturn(USER_ID);
+ when(dcaeRestClient.saveComposition(any(), any())).thenReturn("Composition Created");
templateInfoToJsonObjectMap = new HashMap<>();
TemplateInfo templateInfo = new TemplateInfo();
templateInfo.setName(VFCMT_NAME1);
diff --git a/dcaedt_tools/src/test/java/TemplateContainerTest.java b/dcaedt_tools/src/test/java/TemplateContainerTest.java
index 6b09991..d4053a1 100644
--- a/dcaedt_tools/src/test/java/TemplateContainerTest.java
+++ b/dcaedt_tools/src/test/java/TemplateContainerTest.java
@@ -25,6 +25,8 @@ public class TemplateContainerTest extends BaseTest {
@Override
public void setup() {
super.setup();
+ super.mockGetItemModel();
+ super.mockGetItemType();
templateInfos = new ArrayList<>();
TemplateInfo templateInfo = new TemplateInfo();
templateInfo.setName(TEMPLATE_INFO_NAME);