2fa8725d56552782e9b45c0eac2559d37f90b37f
[so.git] /
1 package org.onap.so.simulator.scenarios.openstack;
2
3 import org.springframework.core.io.ClassPathResource;
4 import org.springframework.http.HttpStatus;
5 import org.springframework.web.bind.annotation.RequestMapping;
6 import org.springframework.web.bind.annotation.RequestMethod;
7 import org.onap.so.simulator.actions.aai.DeleteVServers;
8 import com.consol.citrus.endpoint.resolver.DynamicEndpointUriResolver;
9 import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
10 import com.consol.citrus.simulator.scenario.Scenario;
11 import com.consol.citrus.simulator.scenario.ScenarioDesigner;
12
13 @Scenario("Double-Failure-Stack-Endpoint")
14 @RequestMapping(value = "/sim/mockPublicUrl/stacks/double_failure_id/stackId")
15 public class QueryStackByIdDoubleFailure extends AbstractSimulatorScenario {
16
17
18     @Override
19     public void run(ScenarioDesigner scenario) {
20         // Create Poll Service
21         scenario.scenarioEndpoint().getEndpointConfiguration().setTimeout(300000L);
22         scenario.http().receive().get().extractFromHeader(DynamicEndpointUriResolver.REQUEST_PATH_HEADER_NAME,
23                 "correlationId");
24         scenario.echo("${correlationId}"); // step 2
25         scenario.correlation().start().onHeader(DynamicEndpointUriResolver.REQUEST_PATH_HEADER_NAME,
26                 "${correlationId}");
27
28         scenario.variable("stackName", "double_failure_id");
29         scenario.variable("cloudOwner", "cloudOwner");
30         scenario.variable("cloudRegion", "regionTwo");
31         scenario.variable("tenantId", "872f331350c54e59991a8de2cbffb40c");
32         scenario.variable("vServerId", "d29f3151-592d-4011-9356-ad047794e236");
33         scenario.variable("stack_failure_message", "The Flavor ID (nd.c6r16d20) could not be found.");
34         scenario.http().send().response(HttpStatus.OK) // step 4
35                 .payload(new ClassPathResource("openstack/gr_api/Stack_Failure.json"));
36
37         // Create Poll Retry
38         scenario.http().receive().get(); // step 5
39         scenario.http().send().response(HttpStatus.OK)
40                 .payload(new ClassPathResource("openstack/gr_api/Stack_Failure.json"));
41
42         // Rollback Delete of the stack
43         scenario.http().receive().delete(); // step 7
44         scenario.action(new DeleteVServers());
45         scenario.http().send().response(HttpStatus.NO_CONTENT);
46
47         // Rollback Poll
48         scenario.http().receive().get(); // step 10
49         scenario.http().send().response(HttpStatus.OK)
50                 .payload(new ClassPathResource("openstack/gr_api/Stack_Failure.json"));
51
52         // Rollback Poll Retry
53         scenario.http().receive().get();
54         scenario.http().send().response(HttpStatus.OK)
55                 .payload(new ClassPathResource("openstack/gr_api/Stack_Failure.json"));
56
57         // Create Poll
58         scenario.http().receive().get(); // step 14
59         scenario.http().send().response(HttpStatus.OK)
60                 .payload(new ClassPathResource("openstack/gr_api/Stack_Failure.json"));
61
62         // Create Poll Retry
63         scenario.http().receive().get();
64         scenario.http().send().response(HttpStatus.OK)
65                 .payload(new ClassPathResource("openstack/gr_api/Stack_Failure.json"));
66
67         // Rollback Delete
68         scenario.http().receive().delete();
69         scenario.action(new DeleteVServers());
70         scenario.http().send().response(HttpStatus.NO_CONTENT);
71
72         // Rollback Poll
73         scenario.http().receive().get(); // step 18
74         scenario.http().send().response(HttpStatus.OK)
75                 .payload(new ClassPathResource("openstack/gr_api/Stack_Failure.json"));
76
77         // Rollback Poll Retry
78         scenario.http().receive().get();
79         scenario.http().send().response(HttpStatus.OK)
80                 .payload(new ClassPathResource("openstack/gr_api/Stack_Failure.json"));
81
82         // Delete
83         scenario.http().receive().delete();
84         scenario.http().send().response(HttpStatus.NO_CONTENT);
85
86         // Delete Poll
87         scenario.http().receive().get();
88         scenario.http().send().response(HttpStatus.OK)
89                 .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json"));
90
91     }
92
93 }