summaryrefslogtreecommitdiffstats
path: root/dcaedt_tools/src
diff options
context:
space:
mode:
authorEran (ev672n), Vosk <ev672n@att.com>2018-10-16 17:33:49 +0300
committerEran (ev672n), Vosk <ev672n@att.com>2018-10-17 15:41:16 +0300
commit3fc94dd71339db72d60220add95b6b72c932abdb (patch)
treee6a3e0296f09f79be86ee76f9f3d40fcad97e8b2 /dcaedt_tools/src
parent936253bccdcebe82ed06b55025087e96bbd35551 (diff)
security check issues
recheck eun-clm updating spring version, using security check issues Change-Id: Ic9eb249b70d4e32669fc6f1f4262b0fb91c0cd70 Issue-ID: SDC-1829 Signed-off-by: Eran (ev672n), Vosk <ev672n@att.com>
Diffstat (limited to 'dcaedt_tools/src')
-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
3 files changed, 17 insertions, 19 deletions
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);