diff options
author | 2018-10-16 17:33:49 +0300 | |
---|---|---|
committer | 2018-10-17 15:41:16 +0300 | |
commit | 3fc94dd71339db72d60220add95b6b72c932abdb (patch) | |
tree | e6a3e0296f09f79be86ee76f9f3d40fcad97e8b2 /dcaedt_tools/src/test/java/BaseTest.java | |
parent | 936253bccdcebe82ed06b55025087e96bbd35551 (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/test/java/BaseTest.java')
-rw-r--r-- | dcaedt_tools/src/test/java/BaseTest.java | 29 |
1 files changed, 10 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); |