5abc9a865359d9be3656637fce51dbc2a0959bd7
[vid.git] / vid-automation / src / test / java / org / onap / vid / api / AsyncInstantiationMacroApiTest.java
1 package org.onap.vid.api;
2
3 import static java.util.stream.Collectors.counting;
4 import static java.util.stream.Collectors.groupingBy;
5 import static java.util.stream.Collectors.toList;
6 import static java.util.stream.Collectors.toMap;
7 import static org.hamcrest.CoreMatchers.hasItem;
8 import static org.hamcrest.CoreMatchers.is;
9 import static org.hamcrest.CoreMatchers.not;
10 import static org.hamcrest.CoreMatchers.startsWith;
11 import static org.hamcrest.MatcherAssert.assertThat;
12 import static org.hamcrest.Matchers.hasSize;
13 import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet.COMPLETE;
14 import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys;
15 import static org.testng.AssertJUnit.assertEquals;
16 import static org.testng.AssertJUnit.assertTrue;
17 import static vid.automation.test.infra.Features.FLAG_1906_INSTANTIATION_API_USER_VALIDATION;
18 import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets;
19 import static vid.automation.test.utils.ExtendedHamcrestMatcher.hasItemsFromCollection;
20
21 import com.fasterxml.jackson.core.JsonProcessingException;
22 import com.google.common.collect.ImmutableList;
23 import com.google.common.collect.ImmutableMap;
24 import java.util.Arrays;
25 import java.util.Collections;
26 import java.util.LinkedList;
27 import java.util.List;
28 import java.util.Map;
29 import java.util.Objects;
30 import java.util.Optional;
31 import java.util.Set;
32 import java.util.UUID;
33 import java.util.concurrent.atomic.AtomicReference;
34 import java.util.stream.IntStream;
35 import java.util.stream.Stream;
36 import net.bytebuddy.utility.RandomString;
37 import net.javacrumbs.jsonunit.JsonAssert;
38 import org.apache.commons.lang3.StringUtils;
39 import org.apache.logging.log4j.LogManager;
40 import org.apache.logging.log4j.Logger;
41 import org.hamcrest.collection.IsCollectionWithSize;
42 import org.onap.sdc.ci.tests.datatypes.UserCredentials;
43 import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
44 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId;
45 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
46 import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet;
47 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOAssignServiceInstanceGen2WithNames;
48 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2WithNames;
49 import org.onap.simulator.presetGenerator.presets.mso.PresetMSODeleteMacroService;
50 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet;
51 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGetErrorResponse;
52 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestsManyInstanceStatusesGet;
53 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2ErrorResponse;
54 import org.onap.vid.model.asyncInstantiation.JobAuditStatus;
55 import org.onap.vid.model.asyncInstantiation.ServiceInfo;
56 import org.springframework.http.HttpStatus;
57 import org.springframework.web.client.HttpClientErrorException;
58 import org.springframework.web.client.HttpServerErrorException;
59 import org.testng.Assert;
60 import org.testng.annotations.DataProvider;
61 import org.testng.annotations.Test;
62 import vid.automation.test.infra.FeatureTogglingTest;
63 import vid.automation.test.infra.Wait;
64 import vid.automation.test.model.JobStatus;
65 import vid.automation.test.model.ServiceAction;
66 import vid.automation.test.services.SimulatorApi;
67
68 public class AsyncInstantiationMacroApiTest extends AsyncInstantiationBase {
69     private static final Logger logger = LogManager.getLogger(AsyncInstantiationMacroApiTest.class);
70
71     private static final String MSO_BASE_ERROR =
72             "Received error from SDN-C: java.lang.IllegalArgumentException: All keys must be specified for class org."+
73             "opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.assignments.vf."+
74             "module.assignments.vms.VmKey. Missing key is getVmType. Supplied key is VmKey [].";
75     private static final String MSO_ERROR = MSO_BASE_ERROR + StringUtils.repeat(" and a lot of sentences for long message", 60);
76
77     private static final String INSTANCE_GROUP_ID_LABEL = "instanceGroupId";
78
79     private static final String INSTANCE_GROUP_LABEL = "instanceGroup";
80
81     private static final String DELETE_MACRO_SERVICE_FILE_NAME = "asyncInstantiation/vidRequestDeleteMacroService.json";
82
83     @Test
84     public void createBulkOfCreateInstances(){
85         Map<Keys, String> names = generateNames();
86         final int bulkSize = 3;
87         ImmutableList<BasePreset> presets = addPresetsForCreateBulkOfCreateInstances(bulkSize, names);
88         createBulkOfInstancesAndAssert(presets, false, bulkSize, JobStatus.COMPLETED, names);
89     }
90
91     @Test(dataProvider = "auditSources")
92    public void getAuditStatus_nonExistingJobId_returnsEmptyList(JobAuditStatus.SourceStatus source){
93        List<JobAuditStatus> audits = getAuditStatuses(UUID.randomUUID().toString(), source.name());
94        Assert.assertEquals(audits.size(),0);
95    }
96
97     @Test(expectedExceptions = HttpClientErrorException.class)
98     public void getAuditStatus_nonExistingSource_returnsError() {
99         try {
100             getAuditStatuses(UUID.randomUUID().toString(), new RandomString(8).nextString());
101         } catch (HttpClientErrorException e) {
102             Assert.assertEquals(e.getResponseBodyAsString(),"The parameter source must have a value among : MSO, VID");
103             assertThat(e.getStatusCode(), is(HttpStatus.BAD_REQUEST));
104             throw e;
105         }
106     }
107
108     @Test()
109     public void simulateBulkRequest_getAuditStatus_auditStatusesReturnedAccordingSource() {
110         final int bulkSize = 2;
111         final List<String> jobIds = createBulkAndWaitForBeCompleted(bulkSize);
112
113         for(String jobId: jobIds) {
114             List<JobAuditStatus> actualVidAudits = getAuditStatuses(jobId, JobAuditStatus.SourceStatus.VID.name());
115             List<JobAuditStatus> expectedVidAudits = Stream.of(JobStatus.PENDING, JobStatus.IN_PROGRESS, JobStatus.COMPLETED)
116                     .map(status-> vidAuditStatus(jobId, status.name(), status.equals(JobStatus.COMPLETED))).collect(toList());
117             assertThat(actualVidAudits, hasItemsFromCollection(expectedVidAudits));
118
119             List<JobAuditStatus> actualMsoAudits = getAuditStatuses(jobId, JobAuditStatus.SourceStatus.MSO.name());
120             List<JobAuditStatus> expectedMsoAudits = Stream.of("REQUESTED", "COMPLETE")
121                     .map(status-> new JobAuditStatus(UUID.fromString(jobId),
122                             status,
123                             JobAuditStatus.SourceStatus.MSO,
124                             UUID.fromString("c0011670-0e1a-4b74-945d-8bf5aede1d9c"),
125                             status.equals("COMPLETE") ? "Service Instance was created successfully." : null,
126                             false)).collect(toList());
127             assertThat(actualMsoAudits, is(expectedMsoAudits));
128         }
129     }
130
131
132     @Test(expectedExceptions = HttpClientErrorException.class)
133     public void addBulkAndDeleteInProgress_deletionIsRejected(){
134         try {
135             final Map<String, JobStatus> jobs = addBulkAllPendingButOneInProgress();
136             deleteOneJobHavingTheStatus(jobs, JobStatus.IN_PROGRESS);
137         } catch (HttpClientErrorException e) {
138             JsonAssert.assertJsonPartEquals(
139                 String.format(
140                     "Service status does not allow deletion from the queue (Request id: %s)",
141                     e.getResponseHeaders().getFirst("X-ECOMP-RequestID-echo")
142                 ),
143                 e.getResponseBodyAsString(),
144                 "message"
145             );
146             assertThat(e.getStatusCode(), is(HttpStatus.METHOD_NOT_ALLOWED));
147
148             throw e;
149         }
150     }
151
152     @Test
153     public void addBulkAndDeletePending_deletedIsHiddenFromServiceInfoResults(){
154         Map<String, JobStatus> statusesBefore = addBulkAllPendingButOneInProgress();
155
156         final String deletedJob = deleteOneJobHavingTheStatus(statusesBefore, JobStatus.PENDING);
157
158         final Map<String, JobStatus> statusesNow = serviceListCall().getBody().stream()
159                 .filter(si -> statusesBefore.keySet().contains(si.jobId))
160                 .collect(toMap(si -> si.jobId, si -> si.jobStatus));
161
162         statusesBefore.remove(deletedJob);
163         assertThat("deleted job shall not be present in StatusInfo response", statusesNow, is(statusesBefore));
164     }
165
166     @Test(invocationCount = 3)
167     public void createBulkOfCreateInstancesWithSinglePreset_firstOneInProgressOtherArePending(){
168         final int bulkSize = 3;
169         Map<String, JobStatus> statusMap = addBulkAllPendingButOneInProgress(bulkSize);
170         Set<String> jobIds = statusMap.keySet();
171
172         final Map<JobStatus, List<ServiceInfo>> statuses = serviceListCall().getBody().stream()
173                 .filter(si -> jobIds.contains(si.jobId))
174                 .collect(groupingBy(ServiceInfo::getJobStatus));
175
176         // Variable "statuses" contains two lists by status:
177         // IN_PROGRESS:  The ultimate first job - named with _001 - is always the only one in progress
178         // PENDING:      The other two jobs - named with _002 and _003 - are the still pending
179         assertThat(jobIds, hasSize(bulkSize));
180         assertThat(statuses.get(JobStatus.IN_PROGRESS), hasSize(1));
181
182         assertThat(statuses.get(JobStatus.PENDING), hasSize(bulkSize - 1));
183     }
184
185
186     @Test(dataProvider = "trueAndFalse" )
187     public void whenServiceInBulkFailed_otherServicesAreStopped(Boolean isPresetForCreate){
188         Map<Keys, String> names = generateNames();
189         final int bulkSize = 3;
190
191         //if there is a preset for create,  service shall failed during in_progress (upon get status)
192         //it there is no preset for create, service shall failed during pending (upon create request)
193         List<BasePreset> msoBulkPresets = isPresetForCreate ?
194                 generateMsoCreateBulkPresets(bulkSize, names) :
195                 new LinkedList<>();
196         ImmutableList<BasePreset> presets = new ImmutableList.Builder<BasePreset>()
197                 .add(new PresetGetSessionSlotCheckIntervalGet())
198                 .add(new PresetAAIGetSubscribersGet())
199                 .add(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN3_TO_ATT_SABABA)
200                 .addAll(msoBulkPresets)
201                 .add(new PresetMSOOrchestrationRequestGet("FAILED"))
202                 .build();
203         List<String> jobIds = createBulkOfMacroInstances(presets, false, bulkSize, names);
204         Assert.assertEquals(jobIds.size(),bulkSize);
205         boolean result = Wait.waitFor(x->{
206                 List<ServiceInfo> serviceInfoList = serviceListCall().getBody();
207                 Map<JobStatus, Long> statusCount = serviceInfoList.stream().filter(si->jobIds.contains(si.jobId)).collect(groupingBy(ServiceInfo::getJobStatus, counting()));
208                 return Objects.equals(statusCount.get(JobStatus.FAILED), 1L) && Objects.equals(statusCount.get(JobStatus.STOPPED), 2L);
209             }, null, 15, 1);
210         assertTrue(String.format("failed to get jobs [%s] to state of: 1 failed and 2 stopped ",
211                 String.join(",", jobIds)),result);
212     }
213
214     @Test
215     public void createBulkOfAssignInstances(){
216         Map<Keys, String> names = generateNames();
217         final int bulkSize = 2;
218         ImmutableList<BasePreset> msoBulkPresets = IntStream.rangeClosed(0, bulkSize-1)
219                 .mapToObj(i-> new PresetMSOAssignServiceInstanceGen2WithNames(names, i))
220                 .collect(ImmutableList.toImmutableList());
221         ImmutableList<BasePreset> presets = new ImmutableList.Builder<BasePreset>()
222                 .add(new PresetGetSessionSlotCheckIntervalGet())
223                 .add(new PresetAAIGetSubscribersGet())
224                 .add(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN3_TO_ATT_SABABA)
225                 .addAll(msoBulkPresets)
226                 .add(new PresetMSOOrchestrationRequestGet())
227                 .build();
228         createBulkOfInstancesAndAssert(presets, true, bulkSize, JobStatus.COMPLETED, names);
229     }  
230
231     @Test
232     public void tryToCreateBulkOfAssignInstancesErrorResponseFromMso(){
233         ImmutableList<BasePreset> presets = ImmutableList.of(
234                 new PresetGetSessionSlotCheckIntervalGet(),
235                 new PresetAAIGetSubscribersGet(),
236                 new PresetMSOServiceInstanceGen2ErrorResponse(406));
237
238         List<String> jobIds = createBulkOfInstancesAndAssert(presets, true,1, JobStatus.FAILED, generateNames());
239         String jobId  = jobIds.get(0);
240         List<JobAuditStatus> actualMsoAudits = getAuditStatuses(jobId, JobAuditStatus.SourceStatus.MSO.name());
241         JobAuditStatus expectedMsoAudit = new JobAuditStatus(UUID.fromString(jobId), "FAILED", JobAuditStatus.SourceStatus.MSO,
242                         null,
243                         "Http Code:406, \"messageId\":\"SVC0002\",\"text\":\"JSON Object Mapping Request\"" ,
244                         false);
245         assertThat(actualMsoAudits.get(0), is(expectedMsoAudit));
246     }
247
248     @Test
249     public void whenGetLongErrorMessageFromMso_ThenAuditFirst2000Chars() {
250         Map<Keys, String> names = generateNames();
251         ImmutableList<BasePreset> presets = ImmutableList.of(
252                 new PresetGetSessionSlotCheckIntervalGet(),
253                 new PresetAAIGetSubscribersGet(),
254                 new PresetMSOCreateServiceInstanceGen2WithNames(names, 0),
255                 new PresetMSOOrchestrationRequestGet("FAILED", PresetMSOOrchestrationRequestGet.DEFAULT_REQUEST_ID, MSO_ERROR));
256
257         List<String> jobIds = createBulkOfInstancesAndAssert(presets, false, 1, JobStatus.FAILED, names);
258         String jobId  = jobIds.get(0);
259         List<JobAuditStatus> actualMsoAudits = getAuditStatuses(jobId, JobAuditStatus.SourceStatus.MSO.name());
260         Optional<JobAuditStatus> jobAuditStatus = actualMsoAudits.stream().filter(x -> x.getJobStatus().equals("FAILED")).findFirst();
261         assertTrue(jobAuditStatus.isPresent());
262         assertThat(jobAuditStatus.get().getAdditionalInfo(), startsWith(MSO_BASE_ERROR));
263         assertThat(jobAuditStatus.get().getAdditionalInfo().length(), is(2000));
264     }
265
266     @Test
267     public void whenHideCompletedService_thenServiceNotReturnInServiceList(){
268         List<String> services = createBulkAndWaitForBeCompleted(2);
269         hideService(services.get(0));
270         List<String> serviceInfoList = serviceListCall().getBody().stream().map(ServiceInfo::getJobId).collect(toList());
271         assertThat(serviceInfoList, hasItem(services.get(1)));
272         assertThat(serviceInfoList, not(hasItem(services.get(0))));
273     }
274
275     @Test
276     public void errorResponseInGetStatusFromMso_getAuditStatusFromMso_errorMsgExistInAdditionalInfo(){
277         Map<Keys, String> names = generateNames();
278         ImmutableList<BasePreset> presets = new ImmutableList.Builder<BasePreset>()
279                 .add(new PresetGetSessionSlotCheckIntervalGet())
280                 .add(new PresetAAIGetSubscribersGet())
281                 .add(PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MTN3_TO_ATT_SABABA)
282                 .add(new PresetMSOAssignServiceInstanceGen2WithNames(names, 0))
283                 .add(new PresetMSOOrchestrationRequestGetErrorResponse(406))
284                 .build();
285
286         final List<String> jobIds = createBulkOfInstancesAndAssert(presets, true,1, JobStatus.IN_PROGRESS, names);
287         String jobId = jobIds.get(0);
288         Wait.waitFor(y-> getAuditStatuses(jobId, JobAuditStatus.SourceStatus.MSO.name()).stream()
289                         .anyMatch(si -> si.getJobStatus().equals("FAILED")),
290                 null, 10, 1 );
291         List<JobAuditStatus> actualMsoAudits = getAuditStatuses(jobId, JobAuditStatus.SourceStatus.MSO.name());
292         List<JobAuditStatus> expectedMsoAudits = Stream.of("REQUESTED", "FAILED")
293                 .map(status -> new JobAuditStatus(UUID.fromString(jobId),
294                         status,
295                         JobAuditStatus.SourceStatus.MSO,
296                         UUID.fromString("c0011670-0e1a-4b74-945d-8bf5aede1d9c"),
297                         status.equals("FAILED") ? "Http Code:406, \"messageId\":\"SVC0002\",\"text\":\"JSON Object Mapping Request\"" : null,
298                         false)).collect(toList());
299         assertThat(actualMsoAudits, is(expectedMsoAudits));
300
301     }
302
303     @Test
304     public void inProgressJobMoreThan24HoursIsFailedInVidAudit() throws JsonProcessingException {
305         addBulkPendingWithCustomList(Collections.singletonList(new PresetMSOOrchestrationRequestGet("IN_PROGRESS",24)));
306
307         AtomicReference<ServiceInfo> inProgressJob = new AtomicReference<>();
308         AtomicReference<List<ServiceInfo>> serviceInfoRef = new AtomicReference<>();
309         boolean isJobFound = Wait.waitFor(x->{
310             List<ServiceInfo> serviceInfoList = serviceListCall().getBody();
311             serviceInfoRef.set(serviceInfoList);
312             inProgressJob.set(serviceInfoList.stream().
313                     filter(serviceInfo -> serviceInfo.serviceInstanceId.equals(PresetMSOOrchestrationRequestGet.DEFAULT_SERVICE_INSTANCE_ID) && serviceInfo.jobStatus.equals(JobStatus.FAILED))
314                     .findFirst()
315                     .orElse(null));
316             return inProgressJob.get() != null;
317         }, null, 15, 1);
318
319         org.junit.Assert.assertTrue(
320             "Job with DEFAULT_SERVICE_INSTANCE_ID=" + PresetMSOOrchestrationRequestGet.DEFAULT_SERVICE_INSTANCE_ID
321                 + " and status FAILED should present: " + objectMapper.writeValueAsString(serviceInfoRef.get()), isJobFound);
322
323         verifyAuditStatuses(inProgressJob.get().jobId, Arrays.asList(JobStatus.PENDING.name(), JobStatus.IN_PROGRESS.name(),JobStatus.FAILED.name()), JobAuditStatus.SourceStatus.VID);
324         verifyAuditStatuses(inProgressJob.get().jobId, Arrays.asList("REQUESTED", "IN_PROGRESS"), JobAuditStatus.SourceStatus.MSO);
325     }
326
327     @Test
328     public void inProgressJobLessThan24HoursIsStillInProgressInVidAudit(){
329         addBulkPendingWithCustomList(Collections.singletonList(new PresetMSOOrchestrationRequestGet("IN_PROGRESS",23)));
330
331         AtomicReference<ServiceInfo> inProgressJob = new AtomicReference<>();
332         boolean isJobFound = Wait.waitFor(x->{
333             List<ServiceInfo> serviceInfoList = serviceListCall().getBody();
334             inProgressJob.set(serviceInfoList.stream().filter(serviceInfo -> serviceInfo.serviceInstanceId.equals(PresetMSOOrchestrationRequestGet.DEFAULT_SERVICE_INSTANCE_ID))
335                     .findFirst()
336                     .orElse(null));
337             return inProgressJob.get() != null;
338         }, null, 15, 1);
339
340         org.junit.Assert.assertTrue("Job with DEFAULT_SERVICE_INSTANCE_ID should present", isJobFound);
341         org.junit.Assert.assertEquals("Tested job status is not as expected", JobStatus.IN_PROGRESS, inProgressJob.get().getJobStatus());
342
343         verifyAuditStatuses(inProgressJob.get().jobId, Arrays.asList(JobStatus.PENDING.name(), JobStatus.IN_PROGRESS.name()), JobAuditStatus.SourceStatus.VID);
344         verifyAuditStatuses(inProgressJob.get().jobId, Arrays.asList("REQUESTED", "IN_PROGRESS"), JobAuditStatus.SourceStatus.MSO);
345     }
346
347     @Test
348     public void verifyAuditStatusOfInstanceGroupId(){
349         SimulatorApi.registerExpectationFromPreset(new PresetMSOOrchestrationRequestsManyInstanceStatusesGet(INSTANCE_GROUP_ID_LABEL, INSTANCE_GROUP_LABEL), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET);
350         final List<JobAuditStatus> expectedAuditStatusList = getAuditStatusesForInstance("VNFGROUP", "df305d54-75b4-431b-adb2-eb6b9e5460df");
351         verifyInstanceAuditStatuses(Arrays.asList(
352                 new JobAuditStatus("groupTestName", "IN_PROGRESS", UUID.fromString("28502bd2-3aff-4a03-9f2b-5a0d1cb1ca24") , INSTANCE_GROUP_LABEL+" instance creation", null, INSTANCE_GROUP_LABEL),
353                 new JobAuditStatus("groupTestName", "COMPLETE",UUID.fromString("28502bd2-3aff-4a03-9f2b-5a0d1cb1ca24") , INSTANCE_GROUP_LABEL+" instance creation", null, INSTANCE_GROUP_LABEL),
354                 new JobAuditStatus("groupTestName", "IN_PROGRESS", UUID.fromString("f711f0ff-24b6-4d7f-9314-4b4eae15f48c") , INSTANCE_GROUP_LABEL+" instance deletion", null, INSTANCE_GROUP_LABEL),
355                 new JobAuditStatus("groupTestName", "COMPLETE",UUID.fromString("f711f0ff-24b6-4d7f-9314-4b4eae15f48c")  , INSTANCE_GROUP_LABEL+" instance deletion", null, INSTANCE_GROUP_LABEL)),
356                 expectedAuditStatusList);
357     }
358
359     @Test(expectedExceptions = HttpClientErrorException.class)
360     public void verifyAuditStatusOfInstanceGroupId_notExistingVidType(){
361         try {
362             getAuditStatusesForInstance("KUKU", "df305d54-75b4-431b-adb2-eb6b9e5460df");
363         } catch (HttpClientErrorException e){ //to verify the properiatary statusCode field
364             assertThat("Code is not as expected", HttpStatus.BAD_REQUEST.equals(e.getStatusCode()));
365             throw e;
366         }
367     }
368
369     @Test(expectedExceptions = HttpServerErrorException.class)
370     public void verifyAuditStatusOfInstanceGroupId_notExistingMsoInstanceId(){
371         try {
372             getAuditStatusesForInstance("VNFGROUP", "df305d54-75b4-431b-adb2-eb6b9e5460aa");
373         } catch (HttpServerErrorException e){ //to verify the properiatary statusCode field
374             assertThat("Code is not as expected", HttpStatus.INTERNAL_SERVER_ERROR.equals(e.getStatusCode()));
375             throw e;
376         }
377     }
378
379     @DataProvider
380     public static Object[][] macroAndALaCarteBulk(){
381         return new Object[][]{{CREATE_BULK_OF_MACRO_REQUEST}, {CREATE_BULK_OF_ALACARTE_REQUEST_WITH_VNF}};
382     }
383
384     @Test(dataProvider = "macroAndALaCarteBulk", expectedExceptions = HttpClientErrorException.class)
385     @FeatureTogglingTest(FLAG_1906_INSTANTIATION_API_USER_VALIDATION)
386     public void verifyCreateBulkOfInstancesUserPermissionValidation(String requestDetailsFileName) {
387         login(new UserCredentials("em1536000", "em1536000", null, null, null));
388         try {
389             createBulkOfInstances(false, 1, Collections.EMPTY_MAP, requestDetailsFileName);
390         } catch (HttpClientErrorException e){
391             assertEquals("Code is not as expected", HttpStatus.FORBIDDEN.value(), e.getStatusCode().value());
392             throw e;
393         }
394         finally {
395             login();
396         }
397
398     }
399
400     @Test
401     public void deleteMacroService_getAuditStatus_verifyCompleted() {
402         String deleteServiceRequestId = UUID.randomUUID().toString();
403         String serviceInstanceId = "service-instance-id";
404         registerExpectationFromPresets(ImmutableList.of(
405                 new PresetAAIGetSubscribersGet(),
406                 new PresetMSODeleteMacroService(deleteServiceRequestId, serviceInstanceId),
407                 new PresetMSOOrchestrationRequestGet(COMPLETE, deleteServiceRequestId)
408         ), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET);
409
410         List<String> uuids = createBulkOfInstances(false, 1, ImmutableMap.of(), DELETE_MACRO_SERVICE_FILE_NAME);
411         assertThat(uuids, IsCollectionWithSize.hasSize(1));
412         String jobId = uuids.get(0);
413
414         assertExpectedStatusAndServiceInfo(JobStatus.COMPLETED, jobId, PATIENCE_LEVEL.FAIL_FAST, new ServiceInfo(
415                 "us16807000", JobStatus.COMPLETED, false,
416                 "d61e6f2d-12fa-4cc2-91df-7c244011d6fc", "WayneHolland", "WATKINS",
417                 "JAG1", "YUDFJULP-JAG1",
418                 "092eb9e8e4b7412e8787dd091bc58e86", "USP-SIP-IC-24335-T-01",
419                 "AAIAIC25", null,
420                 "service-instance-type", null,
421                 null, "InstanceName",
422                 "f028b2e2-7080-4b13-91b2-94944d4c42d8", "Service with VRF", "5.0",
423                 jobId, null, ServiceAction.DELETE, false)
424         );
425     }
426
427 }