diff options
author | Eylon Malin <eylon.malin@intl.att.com> | 2019-08-06 18:47:30 +0300 |
---|---|---|
committer | Eylon Malin <eylon.malin@intl.att.com> | 2019-08-06 18:47:30 +0300 |
commit | b3568581e94345f0753b060158273c57892686dd (patch) | |
tree | ec9cfd79d7ab0e269d0bd6a44022a96f93474de2 /vid-app-common/src/test/java/org | |
parent | f20517410a174c82115e289320296d0d78f57a28 (diff) |
use cache for retrieving all subscribers list
Issue-ID: VID-378
Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
Change-Id: I73fcc78ebbd8ee01349ecefa924c20014ca33907
Diffstat (limited to 'vid-app-common/src/test/java/org')
5 files changed, 29 insertions, 41 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java b/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java index aae1b0621..17e0c44e0 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java +++ b/vid-app-common/src/test/java/org/onap/vid/controller/LocalWebConfig.java @@ -71,9 +71,9 @@ public class LocalWebConfig { } @Bean - public AaiService getAaiService(AaiClientInterface aaiClient, AaiOverTLSClientInterface aaiOverTLSClient, - AaiResponseTranslator aaiResponseTranslator, AAITreeNodeBuilder aaiTreeNode, AAIServiceTree aaiServiceTree, ExecutorService executorService) { - return new AaiServiceImpl(aaiClient, aaiOverTLSClient, aaiResponseTranslator, aaiServiceTree, executorService); + public AaiService getAaiService(AaiClientInterface aaiClient, AaiResponseTranslator aaiResponseTranslator, + AAITreeNodeBuilder aaiTreeNode, AAIServiceTree aaiServiceTree, ExecutorService executorService) { + return new AaiServiceImpl(aaiClient, aaiResponseTranslator, aaiServiceTree, executorService); } @Bean diff --git a/vid-app-common/src/test/java/org/onap/vid/reports/BasicReportGeneratorTest.java b/vid-app-common/src/test/java/org/onap/vid/reports/BasicReportGeneratorTest.java index d34646dcb..cc4578bf0 100644 --- a/vid-app-common/src/test/java/org/onap/vid/reports/BasicReportGeneratorTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/reports/BasicReportGeneratorTest.java @@ -33,6 +33,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.portalsdk.core.domain.User; import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.aai.AaiClient; +import org.onap.vid.aai.AaiOverTLSClientInterface; import org.onap.vid.model.SubscriberList; import org.onap.vid.model.errorReport.ReportCreationParameters; import org.onap.vid.model.probes.ExternalComponentStatus; @@ -67,13 +68,8 @@ public class BasicReportGeneratorTest { private ProbeService probeService; @Mock - private AaiClient aaiClient; - @Mock - private SchedulerService schedulerService; - @Mock - private AaiService aaiService; - @Mock - private RoleProvider roleProvider; + AaiOverTLSClientInterface aaiOverTLSClient; + @Mock private SystemPropertiesWrapper systemPropertiesWrapper; @@ -136,7 +132,7 @@ public class BasicReportGeneratorTest { .put("headers", headers) .build(); - when(aaiService.getFullSubscriberList()).thenReturn(subscriberListResponse); + when(aaiOverTLSClient.getAllSubscribers()).thenReturn(subscriberListResponse); when(subscriberListResponse.getStatus()).thenReturn(status); when(subscriberListResponse.getBody()).thenReturn(subscriberList); when(subscriberListResponse.getHeaders()).thenReturn(headers); @@ -154,7 +150,7 @@ public class BasicReportGeneratorTest { RestClientException expectedException = mock(RestClientException.class); ImmutableMap<String, Object> expectedResult = ImmutableMap.of("exception", expectedException.toString()); - when(aaiService.getFullSubscriberList()).thenThrow(expectedException); + when(aaiOverTLSClient.getAllSubscribers()).thenThrow(expectedException); //when ImmutableMap<String, Object> actualResult = basicReportGenerator.getFullSubscriberList(); @@ -162,4 +158,4 @@ public class BasicReportGeneratorTest { //then assertThat(actualResult).isEqualTo(expectedResult); } -}
\ No newline at end of file +} diff --git a/vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java b/vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java index 6ba0e4039..c1033d2d0 100644 --- a/vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/roles/RoleProviderTest.java @@ -21,10 +21,17 @@ package org.onap.vid.roles; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + import com.google.common.collect.ImmutableMap; -import io.joshworks.restclient.http.HttpResponse; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; import org.assertj.core.util.Lists; import org.mockito.Mock; +import org.onap.vid.aai.AaiResponse; import org.onap.vid.aai.exceptions.RoleParsingException; import org.onap.vid.model.Subscriber; import org.onap.vid.model.SubscriberList; @@ -32,14 +39,6 @@ import org.onap.vid.services.AaiService; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import javax.servlet.http.HttpServletRequest; -import java.util.List; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; - public class RoleProviderTest { private static final String SAMPLE_SUBSCRIBER = "sampleSubscriber"; @@ -57,8 +56,7 @@ public class RoleProviderTest { private HttpServletRequest request; @Mock - private HttpResponse<SubscriberList> subscriberListHttpResponse; - + private AaiResponse<SubscriberList> subscriberListResponse; private RoleProvider roleProvider; @@ -150,8 +148,8 @@ public class RoleProviderTest { subscriber.subscriberName = SAMPLE_SUBSCRIBER; subscriber.globalCustomerId = SAMPLE_CUSTOMER_ID; SubscriberList subscriberList = new SubscriberList(Lists.list(subscriber)); - when(aaiService.getFullSubscriberList()).thenReturn(subscriberListHttpResponse); - when(subscriberListHttpResponse.getBody()).thenReturn(subscriberList); + when(aaiService.getFullSubscriberList()).thenReturn(subscriberListResponse); + when(subscriberListResponse.getT()).thenReturn(subscriberList); } private Map<Long, org.onap.portalsdk.core.domain.Role> createRoles() { diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AAIServiceIntegrativeTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AAIServiceIntegrativeTest.java index d42747c20..28c844cda 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/AAIServiceIntegrativeTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/AAIServiceIntegrativeTest.java @@ -68,7 +68,7 @@ public class AAIServiceIntegrativeTest extends TestWithAaiClient { null, executorService ); - return new AaiServiceImpl(aaiClient, null, null, aaiServiceTree, executorService); + return new AaiServiceImpl(aaiClient, null, aaiServiceTree, executorService); } @BeforeMethod diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java index 09a53684f..20409d327 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java @@ -34,7 +34,6 @@ import static org.onap.vid.model.aaiTree.NodeType.SERVICE_INSTANCE; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import io.joshworks.restclient.http.HttpResponse; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -54,7 +53,6 @@ import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.vid.aai.AaiClientInterface; import org.onap.vid.aai.AaiGetVnfResponse; -import org.onap.vid.aai.AaiOverTLSClientInterface; import org.onap.vid.aai.AaiResponse; import org.onap.vid.aai.AaiResponseTranslator; import org.onap.vid.aai.ServiceInstancesSearchResults; @@ -118,7 +116,7 @@ public class AaiServiceImplTest { private static final String CLOUD_TYPE = "CLOUD_TYPE"; @Mock - private HttpResponse<SubscriberList> responseAllSubscribers; + private AaiResponse<SubscriberList> responseAllSubscribers; @Mock private AaiResponse<OperationalEnvironmentList> aaiResponseOpEnvList; @Mock @@ -130,8 +128,7 @@ public class AaiServiceImplTest { @Mock private AaiClientInterface aaiClient; - @Mock - private AaiOverTLSClientInterface aaiOverTLSClient; + @Mock private AaiResponseTranslator aaiResponseTranslator; @Mock @@ -144,11 +141,8 @@ public class AaiServiceImplTest { @Test public void shouldGetFullSubscriberListWithoutValidator() { - when(aaiOverTLSClient.getAllSubscribers()).thenReturn(responseAllSubscribers); - - HttpResponse<SubscriberList> actualResponse = aaiService.getFullSubscriberList(); - - assertThat(actualResponse).isEqualTo(responseAllSubscribers); + when(aaiClient.getAllSubscribers()).thenReturn(responseAllSubscribers); + assertThat(aaiService.getFullSubscriberList()).isEqualTo(responseAllSubscribers); } @Test @@ -156,10 +150,10 @@ public class AaiServiceImplTest { Subscriber subscriber = createSubscriber(); SubscriberList subscriberList = new SubscriberList(Collections.singletonList(subscriber)); - when(aaiOverTLSClient.getAllSubscribers()).thenReturn(responseAllSubscribers); - when(responseAllSubscribers.getBody()).thenReturn(subscriberList); - when(responseAllSubscribers.getStatusText()).thenReturn(STATUS_TEXT); - when(responseAllSubscribers.getStatus()).thenReturn(HttpStatus.SC_OK); + when(aaiClient.getAllSubscribers()).thenReturn(responseAllSubscribers); + when(responseAllSubscribers.getT()).thenReturn(subscriberList); + when(responseAllSubscribers.getErrorMessage()).thenReturn(STATUS_TEXT); + when(responseAllSubscribers.getHttpCode()).thenReturn(HttpStatus.SC_OK); SubscriberFilteredResults expectedSubscribers = new SubscriberFilteredResults(roleValidator, subscriberList, STATUS_TEXT, HttpStatus.SC_OK); |