aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org/onap/vid/services
diff options
context:
space:
mode:
authorStern, Ittay (is9613) <ittay.stern@att.com>2018-11-27 13:22:35 +0200
committerIttay Stern <ittay.stern@att.com>2018-11-27 18:53:16 +0200
commitf22f824ea86725f85b2e1c3636b69489dee9943d (patch)
treeec21d6ac6c6734d975c5d26481c65b52c75e3cb8 /vid-app-common/src/test/java/org/onap/vid/services
parentd0e33a075713cb711d97a4186f858b931ff793ef (diff)
Upgrade mockito to v2; drop incompatible powermock
Note that anyString() is not matching null values, therefore replaced with any() where relevant. Change-Id: If64944e1edc62013953e41b2645a2b78c578bbe8 Issue-ID: VID-359 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/test/java/org/onap/vid/services')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java4
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java65
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java34
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java22
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java10
5 files changed, 35 insertions, 100 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
index 7ad49a96..5ead3fce 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
@@ -23,7 +23,6 @@ package org.onap.vid.services;
import com.google.common.collect.ImmutableMap;
import io.joshworks.restclient.http.HttpResponse;
-import java.io.UnsupportedEncodingException;
import jersey.repackaged.com.google.common.collect.ImmutableList;
import org.apache.http.HttpStatus;
import org.apache.http.HttpVersion;
@@ -45,9 +44,10 @@ import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.togglz.core.manager.FeatureManager;
import javax.inject.Inject;
+import java.io.UnsupportedEncodingException;
import java.util.*;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests {
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
index 3f13c9df..9711fa85 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java
@@ -1,72 +1,9 @@
package org.onap.vid.services;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import jersey.repackaged.com.google.common.collect.ImmutableList;
-import net.javacrumbs.jsonunit.JsonAssert;
-import org.apache.commons.io.IOUtils;
-import org.hibernate.SessionFactory;
-import org.json.JSONException;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.onap.vid.aai.exceptions.InvalidAAIResponseException;
-import org.onap.vid.aai.model.ResourceType;
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.exceptions.GenericUncheckedException;
-import org.onap.vid.exceptions.MaxRetriesException;
-import org.onap.vid.exceptions.OperationNotAllowedException;
-import org.onap.vid.job.Job;
-import org.onap.vid.job.Job.JobStatus;
-import org.onap.vid.job.JobAdapter;
-import org.onap.vid.job.JobsBrokerService;
-import org.onap.vid.job.impl.JobDaoImpl;
-import org.onap.vid.model.JobAuditStatus;
-import org.onap.vid.model.JobAuditStatus.SourceStatus;
-import org.onap.vid.model.NameCounter;
-import org.onap.vid.model.ServiceInfo;
-import org.onap.vid.model.serviceInstantiation.ServiceInstantiation;
-import org.onap.vid.model.serviceInstantiation.Vnf;
-import org.onap.vid.mso.model.ServiceInstantiationRequestDetails;
-import org.onap.vid.mso.rest.AsyncRequestStatus;
-import org.onap.vid.utils.DaoUtils;
+import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.config.DataSourceConfig;
import org.onap.vid.config.MockedAaiClientAndFeatureManagerConfig;
-import org.onap.vid.mso.MsoOperationalEnvironmentTest;
-import org.onap.vid.services.AsyncInstantiationBaseTest;
-import org.onap.portalsdk.core.domain.FusionObject;
-import org.onap.portalsdk.core.service.DataAccessService;
-import org.onap.portalsdk.core.util.SystemProperties;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
-import org.testng.Assert;
-import org.testng.annotations.*;
-
-import javax.inject.Inject;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.util.*;
-import java.util.Optional;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.*;
-import static org.hamcrest.core.Every.everyItem;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-import static org.onap.vid.job.Job.JobStatus.*;
-import static org.testng.Assert.*;
@ContextConfiguration(classes = {DataSourceConfig.class, SystemProperties.class, MockedAaiClientAndFeatureManagerConfig.class})
public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseTest {
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java
index 6ac7b544..7a4263c7 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/CategoryParameterServiceImplTest.java
@@ -20,18 +20,6 @@
*/
package org.onap.vid.services;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import javax.ws.rs.ForbiddenException;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.onap.portalsdk.core.service.DataAccessService;
@@ -50,6 +38,16 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
+import javax.ws.rs.ForbiddenException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.*;
+import static org.mockito.MockitoAnnotations.initMocks;
+
public class CategoryParameterServiceImplTest {
private static final String CATEGORY_NAME = "SAMPLE_CATEGORY_NAME";
@@ -89,7 +87,7 @@ public class CategoryParameterServiceImplTest {
Assert.assertTrue(result.getErrors().isEmpty());;
verify(dataAccessService, times(1))
- .saveDomainObject(anyObject(), anyObject());
+ .saveDomainObject(any(), any());
}
@Test
@@ -162,12 +160,12 @@ public class CategoryParameterServiceImplTest {
categoryParameter.getOptions().add(categoryParameterOption);
List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
- doReturn(aList).when(dataAccessService).getList(anyObject(), anyString(), anyString(), anyObject());
+ doReturn(aList).when(dataAccessService).getList(any(), anyString(), any(), any());
testSubject.deleteCategoryOption(CATEGORY_NAME, categoryParameterOption);
verify(dataAccessService, times(1))
- .deleteDomainObject(anyObject(), anyObject());
+ .deleteDomainObject(any(), any());
}
@Test
@@ -178,7 +176,7 @@ public class CategoryParameterServiceImplTest {
categoryParameter.getOptions().add(categoryParameterOption);
List<CategoryParameter> aList = createCategoryParametersList(categoryParameter);
- doReturn(aList).when(dataAccessService).getList(anyObject(), anyString(), anyString(), anyObject());
+ doReturn(aList).when(dataAccessService).getList(any(), anyString(), any(), any());
CategoryParametersResponse response = testSubject.getCategoryParameters(Family.PARAMETER_STANDARDIZATION);
@@ -186,7 +184,7 @@ public class CategoryParameterServiceImplTest {
Assert.assertTrue(response.getCategoryParameters().containsKey(CATEGORY_NAME));
verify(dataAccessService, times(1))
- .getList(anyObject(), anyString(), anyString(), anyObject());
+ .getList(any(), anyString(), any(), any());
}
@Test
@@ -202,7 +200,7 @@ public class CategoryParameterServiceImplTest {
AddCategoryOptionResponse result = testSubject.updateCategoryParameterOption(CATEGORY_NAME, optionRepExisting);
verify(dataAccessService, times(1))
- .saveDomainObject(anyObject(), anyObject());
+ .saveDomainObject(any(), any());
}
@Test(expectedExceptions = { ForbiddenException.class })
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java
index 157f59c7..00d9e173 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceImplTest.java
@@ -1,12 +1,12 @@
package org.onap.vid.services;
import org.mockito.*;
+import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.vid.changeManagement.ChangeManagementRequest;
import org.onap.vid.changeManagement.RequestDetails;
import org.onap.vid.mso.MsoBusinessLogic;
import org.onap.vid.mso.MsoResponseWrapperInterface;
import org.onap.vid.scheduler.SchedulerRestInterfaceIfc;
-import org.onap.portalsdk.core.service.DataAccessService;
import org.springframework.http.ResponseEntity;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -54,47 +54,47 @@ public class ChangeManagementServiceImplTest {
@Test
public void doChangeManagement_requestTypeIsUpdate_MsoUpdateVnfIsCalled() throws Exception {
- Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).updateVnf(Mockito.any(),Mockito.anyString(),Mockito.anyString());
+ Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).updateVnf(Mockito.any(),Mockito.any(),Mockito.any());
RequestDetails requestDetails = callChangeManagement(ChangeManagementRequest.UPDATE);
ArgumentCaptor<RequestDetails> argumentCaptor = ArgumentCaptor.forClass(RequestDetails.class);
- verify(msoBusinessLogicMock).updateVnf(argumentCaptor.capture(),Mockito.anyString(),Mockito.anyString());
+ verify(msoBusinessLogicMock).updateVnf(argumentCaptor.capture(),Mockito.any(),Mockito.any());
assertEquals(argumentCaptor.getValue().getVnfInstanceId(),requestDetails.getVnfInstanceId());
}
@Test
public void doChangeManagement_requestTypeIsReplace_MsoUpdateVnfIsCalled() throws Exception {
- Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).replaceVnf(Mockito.any(),Mockito.anyString(),Mockito.anyString());
+ Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).replaceVnf(Mockito.any(),Mockito.any(),Mockito.any());
RequestDetails requestDetails = callChangeManagement(ChangeManagementRequest.REPLACE);
ArgumentCaptor<RequestDetails> argumentCaptor = ArgumentCaptor.forClass(RequestDetails.class);
- verify(msoBusinessLogicMock).replaceVnf(argumentCaptor.capture(),Mockito.anyString(),Mockito.anyString());
+ verify(msoBusinessLogicMock).replaceVnf(argumentCaptor.capture(),Mockito.any(),Mockito.any());
assertEquals(argumentCaptor.getValue().getVnfInstanceId(),requestDetails.getVnfInstanceId());
}
@Test
public void doChangeManagement_requestTypeIsInPlaceSoftwareUpdate_MsoUpdateVnfIsCalled() throws Exception {
- Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).updateVnfSoftware(Mockito.any(),Mockito.anyString(),Mockito.anyString());
+ Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).updateVnfSoftware(Mockito.any(),Mockito.any(),Mockito.any());
RequestDetails requestDetails = callChangeManagement(ChangeManagementRequest.VNF_IN_PLACE_SOFTWARE_UPDATE);
ArgumentCaptor<RequestDetails> argumentCaptor = ArgumentCaptor.forClass(RequestDetails.class);
- verify(msoBusinessLogicMock).updateVnfSoftware(argumentCaptor.capture(),Mockito.anyString(),Mockito.anyString());
+ verify(msoBusinessLogicMock).updateVnfSoftware(argumentCaptor.capture(),Mockito.any(),Mockito.any());
assertEquals(argumentCaptor.getValue().getVnfInstanceId(),requestDetails.getVnfInstanceId());
}
@Test
public void doChangeManagement_requestTypeIsConfigUpdate_MsoUpdateVnfIsCalled() throws Exception {
- Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).updateVnfConfig(Mockito.any(),Mockito.anyString(),Mockito.anyString());
+ Mockito.doReturn(Mockito.mock(MsoResponseWrapperInterface.class)).when(msoBusinessLogicMock).updateVnfConfig(Mockito.any(),Mockito.any(),Mockito.any());
RequestDetails requestDetails = callChangeManagement(ChangeManagementRequest.CONFIG_UPDATE);
ArgumentCaptor<RequestDetails> argumentCaptor = ArgumentCaptor.forClass(RequestDetails.class);
- verify(msoBusinessLogicMock).updateVnfConfig(argumentCaptor.capture(),Mockito.anyString(),Mockito.anyString());
+ verify(msoBusinessLogicMock).updateVnfConfig(argumentCaptor.capture(),Mockito.any(),Mockito.any());
assertEquals(argumentCaptor.getValue().getVnfInstanceId(),requestDetails.getVnfInstanceId());
}
@@ -106,8 +106,8 @@ public class ChangeManagementServiceImplTest {
updateRequest.setRequestType(requestType);
RequestDetails requestDetails = new RequestDetails();
requestDetails.setVnfInstanceId("vnfFakeId");
- Mockito.doReturn("fakeId").when(changeManagementServiceSpied).extractServiceInstanceId(Mockito.anyObject(),Mockito.anyString());
- Mockito.doReturn(requestDetails).when(changeManagementServiceSpied).findRequestByVnfName(Matchers.anyList(),Mockito.anyString());
+ Mockito.doReturn("fakeId").when(changeManagementServiceSpied).extractServiceInstanceId(Mockito.any(),Mockito.any());
+ Mockito.doReturn(requestDetails).when(changeManagementServiceSpied).findRequestByVnfName(Matchers.any(),Mockito.any());
changeManagementServiceSpied.doChangeManagement(updateRequest,"anyVnfName");
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java
index 8aafda3f..d849869b 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/ChangeManagementServiceUnitTest.java
@@ -24,6 +24,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import io.joshworks.restclient.http.HttpResponse;
import org.apache.commons.io.IOUtils;
import org.mockito.ArgumentCaptor;
+import org.onap.portalsdk.core.service.DataAccessService;
+import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.changeManagement.ChangeManagementRequest;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.client.SyncRestClient;
@@ -37,8 +39,6 @@ import org.onap.vid.mso.rest.RequestDetails;
import org.onap.vid.properties.AsdcClientConfiguration;
import org.onap.vid.scheduler.SchedulerRestInterfaceIfc;
import org.onap.vid.testUtils.RegExMatcher;
-import org.onap.portalsdk.core.service.DataAccessService;
-import org.onap.portalsdk.core.util.SystemProperties;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.springframework.context.annotation.Bean;
@@ -54,8 +54,8 @@ import java.net.URL;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;
@@ -74,7 +74,7 @@ public class ChangeManagementServiceUnitTest extends AbstractTestNGSpringContext
void testInPlaceSoftwareUpdateRequest() throws Exception {
- doReturn(new HttpResponse<>(anyObject(), RequestReferencesContainer.class, anyObject())).when(restClientUnderTest).post(anyString(), anyObject(), anyObject());
+ doReturn(new HttpResponse<>(any(), RequestReferencesContainer.class, any())).when(restClientUnderTest).post(anyString(), any(), any());
URL requestJsonUrl = this.getClass().getResource("/services/change_management_software_update_request.json");
ChangeManagementRequest changeManagementRequest = objectMapper.readValue(requestJsonUrl, ChangeManagementRequest.class);