}
@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
*/
package org.onap.vid.reports;
+import static org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID;
+
import com.google.common.collect.ImmutableMap;
import io.joshworks.restclient.http.HttpResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import javax.servlet.http.HttpServletRequest;
+import org.onap.vid.aai.AaiOverTLSClientInterface;
import org.onap.vid.controller.ControllersUtils;
import org.onap.vid.model.GitRepositoryState;
import org.onap.vid.model.SubscriberList;
import org.onap.vid.model.errorReport.ReportCreationParameters;
import org.onap.vid.model.probes.ExternalComponentStatus;
-import org.onap.vid.services.AaiService;
import org.onap.vid.services.ProbeService;
import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import static org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID;
-
@Component
public class BasicReportGenerator implements ReportGenerator {
private static final String GIT_PROPERTIES_FILENAME = "git.properties";
- private final AaiService aaiService;
+ private final AaiOverTLSClientInterface aaiOverTLSClient;
private final SystemPropertiesWrapper systemPropertiesWrapper;
private final ProbeService probeService;
@Autowired
- public BasicReportGenerator(AaiService aaiService, SystemPropertiesWrapper systemPropertiesWrapper,
+ public BasicReportGenerator(AaiOverTLSClientInterface aaiOverTLSClient, SystemPropertiesWrapper systemPropertiesWrapper,
ProbeService probeService) {
- this.aaiService = aaiService;
+ this.aaiOverTLSClient = aaiOverTLSClient;
this.systemPropertiesWrapper = systemPropertiesWrapper;
this.probeService = probeService;
}
ImmutableMap<String, Object> getFullSubscriberList() {
ImmutableMap<String, Object> fullSubscriberList;
try {
- HttpResponse<SubscriberList> fullSubscriberListResponse = aaiService.getFullSubscriberList();
+ HttpResponse<SubscriberList> fullSubscriberListResponse = aaiOverTLSClient.getAllSubscribers();
fullSubscriberList = ImmutableMap.<String, Object>builder()
.put("status", fullSubscriberListResponse.getStatus())
.put("body", fullSubscriberListResponse.getBody())
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-import io.joshworks.restclient.http.HttpResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.web.support.UserUtils;
+import org.onap.vid.aai.AaiResponse;
import org.onap.vid.aai.exceptions.RoleParsingException;
import org.onap.vid.model.ModelConstants;
import org.onap.vid.model.Subscriber;
private String replaceSubscriberNameToGlobalCustomerID(String subscriberName, String logPrefix) {
// SubscriberList should be cached by cacheProvider so by calling getFullSubscriberList() method we just gat it from cache
- HttpResponse<SubscriberList> subscribersResponse = aaiService.getFullSubscriberList();
- SubscriberList subscribers = subscribersResponse.getBody();
+ AaiResponse<SubscriberList> subscribersResponse = aaiService.getFullSubscriberList();
+ SubscriberList subscribers = subscribersResponse.getT();
try {
LOG.debug(EELFLoggerDelegate.debugLogger, logPrefix + "subscribers list size is " + subscribers.customer.size() + " with the values " + om.writeValueAsString(subscribers.customer));
package org.onap.vid.services;
-import io.joshworks.restclient.http.HttpResponse;
import java.util.Collection;
import java.util.List;
import javax.ws.rs.core.Response;
AaiResponse getServiceInstanceSearchResults(String subscriberId, String instanceIdentifier, RoleValidator roleProvider, List<String> owningEntities, List<String> projects);
- HttpResponse<SubscriberList> getFullSubscriberList();
+ AaiResponse<SubscriberList> getFullSubscriberList();
AaiResponse getServices(RoleValidator roleValidator);
import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
import com.fasterxml.jackson.databind.JsonNode;
-import io.joshworks.restclient.http.HttpResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
private int indexOfSubscriberName = 6;
private AaiClientInterface aaiClient;
- private AaiOverTLSClientInterface aaiOverTLSClient;
private AaiResponseTranslator aaiResponseTranslator;
private AAIServiceTree aaiServiceTree;
private ExecutorService executorService;
@Autowired
public AaiServiceImpl(
AaiClientInterface aaiClient,
- AaiOverTLSClientInterface aaiOverTLSClient,
AaiResponseTranslator aaiResponseTranslator,
AAIServiceTree aaiServiceTree,
ExecutorService executorService)
{
this.aaiClient = aaiClient;
- this.aaiOverTLSClient = aaiOverTLSClient;
this.aaiResponseTranslator = aaiResponseTranslator;
this.aaiServiceTree = aaiServiceTree;
this.executorService = executorService;
@Override
public SubscriberFilteredResults getFullSubscriberList(RoleValidator roleValidator) {
- HttpResponse<SubscriberList> allSubscribers = aaiOverTLSClient.getAllSubscribers();
- return new SubscriberFilteredResults(
- roleValidator,
- allSubscribers.getBody(),
- allSubscribers.getStatusText(),
- allSubscribers.getStatus()
- );
+ AaiResponse<SubscriberList> subscriberResponse = aaiClient.getAllSubscribers();
+
+ return new SubscriberFilteredResults(roleValidator, subscriberResponse.getT(),
+ subscriberResponse.getErrorMessage(),
+ subscriberResponse.getHttpCode());
}
@Override
}
@Override
- public HttpResponse<SubscriberList> getFullSubscriberList() {
- return aaiOverTLSClient.getAllSubscribers();
+ public AaiResponse<SubscriberList> getFullSubscriberList() {
+ return aaiClient.getAllSubscribers();
}
@Override
}
@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
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;
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;
.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);
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();
//then
assertThat(actualResult).isEqualTo(expectedResult);
}
-}
\ No newline at end of file
+}
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;
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";
private HttpServletRequest request;
@Mock
- private HttpResponse<SubscriberList> subscriberListHttpResponse;
-
+ private AaiResponse<SubscriberList> subscriberListResponse;
private RoleProvider roleProvider;
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() {
null,
executorService
);
- return new AaiServiceImpl(aaiClient, null, null, aaiServiceTree, executorService);
+ return new AaiServiceImpl(aaiClient, null, aaiServiceTree, executorService);
}
@BeforeMethod
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;
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;
private static final String CLOUD_TYPE = "CLOUD_TYPE";
@Mock
- private HttpResponse<SubscriberList> responseAllSubscribers;
+ private AaiResponse<SubscriberList> responseAllSubscribers;
@Mock
private AaiResponse<OperationalEnvironmentList> aaiResponseOpEnvList;
@Mock
@Mock
private AaiClientInterface aaiClient;
- @Mock
- private AaiOverTLSClientInterface aaiOverTLSClient;
+
@Mock
private AaiResponseTranslator aaiResponseTranslator;
@Mock
@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
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);
package org.onap.vid.api;
+import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost.DEFAULT_REQUEST_ID;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet.COMPLETE;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.RELATED_VNF1_ACTION;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.RELATED_VNF2_ACTION;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME;
+import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.VNF_GROUP1_ACTION;
+import static vid.automation.test.services.SimulatorApi.registerExpectationFromPreset;
+import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets;
+
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Function;
import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset;
import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAISearchNodeQueryNonEmptyResult;
import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet;
-import org.onap.simulator.presetGenerator.presets.mso.*;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOAddOrRemoveOneInstanceGroupMember;
import org.onap.simulator.presetGenerator.presets.mso.PresetMSOAddOrRemoveOneInstanceGroupMember.InstanceGroupMemberAction;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateNetworkALaCarteServiceCypress2;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2WithNamesAlacarteGroupingService;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2WithNamesAlacarteService;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceMultipleVnfsServiceCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVnfALaCarteServiceCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVnfALaCarteServiceCypress2;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVnfGroup;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteBaseVfModuleCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteNetworkAlaCarteCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteService;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteVfModuleCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteVnfAlaCarteCypress;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames;
import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet;
import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet;
import org.onap.vid.model.asyncInstantiation.JobAuditStatus;
import vid.automation.test.services.SimulatorApi;
import vid.automation.test.services.SimulatorApi.RegistrationStrategy;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.function.Function;
-
-import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.allOf;
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
-import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOBaseCreateInstancePost.DEFAULT_REQUEST_ID;
-import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet.COMPLETE;
-import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.*;
-import static vid.automation.test.services.SimulatorApi.registerExpectationFromPreset;
-import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets;
-
@FeatureTogglingTest({Features.FLAG_ASYNC_ALACARTE_VNF})
public class AsyncInstantiationALaCarteApiTest3 extends AsyncInstantiationBase {
String vnfInstanceId = "VNF_INSTANCE_ID";
registerExpectationFromPresets(ImmutableList.of(
+ new PresetAAIGetSubscribersGet(),
new PresetMSODeleteVnfAlaCarteCypress(deleteVnfRequestId, serviceInstanceId, vnfInstanceId, "us16807000"),
new PresetMSOOrchestrationRequestGet(COMPLETE, deleteVnfRequestId),
new PresetMSODeleteService(deleteServiceRequestId, serviceInstanceId),