1 package vid.automation.test.test;
3 import com.google.common.collect.ImmutableMap;
4 import org.junit.Assert;
5 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
6 import org.openqa.selenium.WebElement;
7 import org.springframework.http.HttpStatus;
8 import org.testng.annotations.BeforeMethod;
9 import org.testng.annotations.DataProvider;
10 import org.testng.annotations.Test;
11 import vid.automation.test.Constants;
12 import vid.automation.test.infra.*;
13 import vid.automation.test.model.Environment;
14 import vid.automation.test.sections.SideMenu;
15 import vid.automation.test.sections.TestEnvironmentPage;
16 import vid.automation.test.sections.VidBasePage;
17 import vid.automation.test.services.SimulatorApi;
18 import vid.automation.test.utils.ReadFile;
20 import java.util.List;
23 import static org.junit.Assert.*;
24 import static vid.automation.test.Constants.TestEnvironments.REFRESH_BUTTON;
31 i. Polling screen is displayed
32 ii. Environment status become active in environments table
33 iii. Button become deactivation
34 iv. Attach file button is shown
35 b. Non JSON file content – error is shown
36 c. Invalid manifest format in the JSON – error is shown
37 d. MSO Error – 500/400 – error is shown
40 i. Polling screen is displayed
41 b. MSO Error – 500/400 – error is shown
45 i. Polling screen is displayed
46 ii. Environment status become inactive in environments table
47 iii. Button become activation
48 iv. Attach file button is not shown
49 b. MSO Error – 500/400 – error is shown
53 public class EnvironmentsTest extends VidBaseTestCase {
55 public static final String GET_EMPTY_OPERATIONAL_ENVIRONMENT_JSON = "get_empty_operational_environment.json";
56 public static final String GET_OPERATIONAL_ENVIRONMENT_JSON = "get_operational_environment.json";
57 public static final String GET_FULL_OPERATIONAL_ENVIRONMENT_JSON = "get_full_operational_environment.json";
58 public static final String GET_ERROR_OPERATIONAL_ENVIRONMENT_JSON = "get_error_operational_environment.json";
59 public static final String POST_OPERATIONAL_ENVIRONMENT_JSON = "post_operational_environment.json";
60 static final String ENVIRONMENTS_CONF = "environments";
61 static final String NEW_ENVIRONMENT_CONF = "newEnvironment";
63 public static final String ENV_ID_FOR_ACTIVATION = "f07ca256-96dd-40ad-b4d2-7a77e2a974eb";
64 public static final String ENV_ID_FOR_DEACTIVATION = "f07ca256-96dd-40ad-b4d2-7a77e2a974ec";
65 private VidBasePage vidBasePage = new VidBasePage();
67 public enum FailureType {
74 //Sometimes we clear registration while we are in view/edit page
75 //And there is alert so we can not navigate any more.
76 //So we first navigate to welcome page, and only the, clear registration
77 public void navigateToWelcome() {
78 SideMenu.navigateToWelcomePage();
82 private void clearAllSimulatorExpectations() {
83 SimulatorApi.clearAll();
84 SimulatorApi.registerExpectation("ecompportal_getSessionSlotCheckInterval.json", SimulatorApi.RegistrationStrategy.APPEND);
88 public void testLeftPanelTestEnvironmentButton() {
89 List<WebElement> leftPanelButtons = Get.byClass(Constants.SideMenu.buttonClass);
90 Assert.assertTrue(Wait.byText(Constants.SideMenu.TEST_ENVIRONMENTS));
94 public void testEnvironmentHeaderLine() {
95 SideMenu.navigateToTestEnvironmentsPage();
96 Assert.assertTrue(Exists.byTestId(Constants.TestEnvironments.PAGE_HEADLINE));
97 Assert.assertTrue(Exists.byTestId(Constants.TestEnvironments.HEADLINE_NEW_BUTTON));
98 Assert.assertTrue(Exists.byTestId(Constants.TestEnvironments.HEADLINE_SEARCH_INPUT));
102 public void testTable() {
103 SimulatorApi.registerExpectation(GET_OPERATIONAL_ENVIRONMENT_JSON, SimulatorApi.RegistrationStrategy.APPEND);
104 vidBasePage.refreshPage();
105 Map <String, List<String>> file = ReadFile.getJsonFile(ENVIRONMENTS_CONF, Map.class);
106 String tableId = Constants.TestEnvironments.ENVIRONMENTS_TABLE;
107 SideMenu.navigateToTestEnvironmentsPage();
108 boolean emptyTableMessage = Exists.byTestId(Constants.TestEnvironments.NO_DATA_MESSAGE);
109 boolean errorMessage = Exists.byTestId(Constants.TestEnvironments.ERROR_MESSAGE);
110 Assert.assertFalse(emptyTableMessage || errorMessage);
111 List<String> headers = Get.tableHeaderValuesByTestId(tableId);
112 Assert.assertEquals(file.get(Constants.TestEnvironments.HEADERS_LIST), headers);
113 List<List<String>> body = Get.tableBodyValuesByTestId(tableId);
114 Assert.assertEquals(file.get(Constants.TestEnvironments.BASIC_LIST), body);
118 public void testSortTable() {
119 SimulatorApi.registerExpectation(GET_OPERATIONAL_ENVIRONMENT_JSON, SimulatorApi.RegistrationStrategy.APPEND);
120 vidBasePage.refreshPage();
121 Map <String, List<String>> file = ReadFile.getJsonFile(ENVIRONMENTS_CONF, Map.class);
122 String tableId = Constants.TestEnvironments.ENVIRONMENTS_TABLE;
123 SideMenu.navigateToTestEnvironmentsPage();
124 Click.byClass(Constants.TestEnvironments.TABLE_HEADER_ASC);
125 GeneralUIUtils.ultimateWait();
126 List<List<String>> body = Get.tableBodyValuesByTestId(tableId);
127 Assert.assertEquals(file.get(Constants.TestEnvironments.SORTED_LIST), body);
128 GeneralUIUtils.ultimateWait();
132 public void testFilterTable() {
133 SimulatorApi.registerExpectation(GET_OPERATIONAL_ENVIRONMENT_JSON, SimulatorApi.RegistrationStrategy.APPEND);
134 vidBasePage.refreshPage();
135 Map <String, List<String>> file = ReadFile.getJsonFile(ENVIRONMENTS_CONF, Map.class);
136 String tableId = Constants.TestEnvironments.ENVIRONMENTS_TABLE;
137 SideMenu.navigateToTestEnvironmentsPage();
138 Input.text(Constants.TestEnvironments.TEXT_TO_FILTER, Constants.TestEnvironments.SEARCH_INPUT);
139 GeneralUIUtils.ultimateWait();
140 List<List<String>> body = Get.tableBodyValuesByTestId(tableId);
141 Assert.assertEquals(file.get(Constants.TestEnvironments.FILTERED_LIST), body);
142 GeneralUIUtils.ultimateWait();
147 public void testEmptyTableMessage() {
148 SimulatorApi.registerExpectation(GET_EMPTY_OPERATIONAL_ENVIRONMENT_JSON, SimulatorApi.RegistrationStrategy.APPEND);
149 vidBasePage.refreshPage();
150 SideMenu.navigateToTestEnvironmentsPage();
151 boolean emptyTableMessage = Exists.byTestId(Constants.TestEnvironments.NO_DATA_MESSAGE);
152 Assert.assertTrue(emptyTableMessage);
153 Assert.assertFalse(Exists.byTestId(Constants.TestEnvironments.TRY_AGAIN_BUTTON));
154 Assert.assertFalse(Exists.byTestId(Constants.TestEnvironments.ENVIRONMENTS_TABLE));
155 GeneralUIUtils.ultimateWait();
159 public void testErrorMessage() {
160 SimulatorApi.registerExpectation(GET_ERROR_OPERATIONAL_ENVIRONMENT_JSON, SimulatorApi.RegistrationStrategy.APPEND);
161 vidBasePage.refreshPage();
162 SideMenu.navigateToTestEnvironmentsPage();
163 boolean errorMessage = Exists.byTestId(Constants.TestEnvironments.ERROR_MESSAGE);
164 Assert.assertTrue(errorMessage);
165 Assert.assertTrue(Exists.byTestId(Constants.TestEnvironments.TRY_AGAIN_BUTTON));
166 Assert.assertFalse(Exists.byTestId(Constants.TestEnvironments.ENVIRONMENTS_TABLE));
167 GeneralUIUtils.ultimateWait();
171 public void testNewEnvironmentPopup() {
172 SimulatorApi.registerExpectation(GET_OPERATIONAL_ENVIRONMENT_JSON, SimulatorApi.RegistrationStrategy.APPEND);
173 SimulatorApi.registerExpectation(POST_OPERATIONAL_ENVIRONMENT_JSON, SimulatorApi.RegistrationStrategy.APPEND);
174 SimulatorApi.registerExpectation("environment/status/get_cloud_resources_request_status.json",
175 ImmutableMap.of("status_message", Constants.TestEnvironments.environmentCreatedSuccesfullyMessage,
176 "REQUEST-TYPE","Create"), SimulatorApi.RegistrationStrategy.APPEND);
177 vidBasePage.refreshPage();
178 Environment environment = ReadFile.getJsonFile(NEW_ENVIRONMENT_CONF, Environment.class);
179 SideMenu.navigateToTestEnvironmentsPage();
180 Click.byTestId(Constants.TestEnvironments.HEADLINE_NEW_BUTTON);
181 Wait.modalToBeDisplayed();
182 Assert.assertTrue(Exists.byTestId(Constants.TestEnvironments.NEW_ENVIRONMENT_FORM));
184 boolean errorMessage = Exists.byTestId(Constants.TestEnvironments.POPUP_ERROR_MESSAGE);
185 Assert.assertFalse(errorMessage);
187 Assert.assertFalse(Get.byTestId(Constants.TestEnvironments.SUBMIT_BUTTON).isEnabled());
188 Input.text(environment.operationalEnvironmentName, Constants.TestEnvironments.INSTANCE_NAME_INPUT);
190 GeneralUIUtils.ultimateWait();
191 SelectOption.byTestIdAndVisibleText(environment.EcompEnvironmentId, Constants.TestEnvironments.ECOMP_ID_DROP_DOWN);
193 String ecompNameText = Input.getValueByTestId(Constants.TestEnvironments.ECOMP_NAME_INPUT);
194 Assert.assertEquals(environment.EcompEnvironmentName, ecompNameText);
196 String tenantContextText = Input.getValueByTestId(Constants.TestEnvironments.TENANT_CONTEXT_INPUT);
197 Assert.assertEquals(environment.tenantContext, tenantContextText);
199 String environmentTypeDefault = Get.selectedOptionText(Constants.TestEnvironments.ENVIRONMENT_TYPE_DROP_DOWN);
200 Assert.assertEquals(environment.operationalEnvironmentType, environmentTypeDefault);
202 if (Features.FLAG_1908_RELEASE_TENANT_ISOLATION.isActive()) {
203 SelectOption.byTestIdAndVisibleText(environment.release, Constants.TestEnvironments.ENVIRONMENT_RELEASE);
204 environment.workloadContext = environment.workloadContext.concat("_" + environment.release);
206 SelectOption.byTestIdAndVisibleText(environment.workloadContext, Constants.TestEnvironments.WORKLOAD_CONTEXT_DROP_DOWN);
208 WebElement submitButton = Get.byTestId(Constants.TestEnvironments.SUBMIT_BUTTON);
209 Assert.assertTrue(submitButton.isEnabled());
210 Click.byTestId(Constants.TestEnvironments.SUBMIT_BUTTON);
211 boolean waitForTextResult = Wait.waitByClassAndText("status", Constants.TestEnvironments.environmentCreatedSuccesfullyMessage, 60);
212 assertTrue(Constants.TestEnvironments.environmentCreatedSuccesfullyMessage + " message didn't appear on time", waitForTextResult);
214 vidBasePage.clickCloseButton();
215 GeneralUIUtils.ultimateWait();
218 Map <String, List<List<String>>> file = ReadFile.getJsonFile(ENVIRONMENTS_CONF, Map.class);
219 String tableId = Constants.TestEnvironments.ENVIRONMENTS_TABLE;
220 SimulatorApi.registerExpectation(GET_FULL_OPERATIONAL_ENVIRONMENT_JSON,
221 ImmutableMap.of("new_name", environment.operationalEnvironmentName, "new_tenant", environment.tenantContext, "new_ecomp_id", environment.EcompEnvironmentId, "new_ecomp_name", environment.EcompEnvironmentName, "new_workload_context", environment.workloadContext), SimulatorApi.RegistrationStrategy.APPEND);
222 Click.byTestId(REFRESH_BUTTON);
223 Wait.angularHttpRequestsLoaded();
224 List<List<String>> body = Get.tableBodyValuesByTestId(tableId);
225 Assert.assertEquals(file.get(fullListId()), body);
226 GeneralUIUtils.ultimateWait();
230 public void testAaiErrorNewEnvironmentPopup() {
231 SimulatorApi.registerExpectation(GET_ERROR_OPERATIONAL_ENVIRONMENT_JSON, SimulatorApi.RegistrationStrategy.APPEND);
232 vidBasePage.refreshPage();
233 SideMenu.navigateToTestEnvironmentsPage();
234 Click.byTestId(Constants.TestEnvironments.HEADLINE_NEW_BUTTON);
235 Wait.modalToBeDisplayed();
236 Assert.assertTrue(Exists.byTestId(Constants.TestEnvironments.NEW_ENVIRONMENT_FORM));
237 GeneralUIUtils.ultimateWait();
238 boolean errorMessage = Exists.byTestId(Constants.TestEnvironments.POPUP_ERROR_MESSAGE);
239 Assert.assertTrue(errorMessage);
240 Click.byTestId(Constants.TestEnvironments.CANCEL_BUTTON);
241 Wait.modalToDisappear();
242 GeneralUIUtils.ultimateWait();
246 public void testCancelNewPopup() {
247 SideMenu.navigateToTestEnvironmentsPage();
248 Click.byTestId(Constants.TestEnvironments.HEADLINE_NEW_BUTTON);
249 Assert.assertTrue(Exists.modal());
250 Click.byTestId(Constants.TestEnvironments.CANCEL_BUTTON);
251 Wait.modalToDisappear();
252 Assert.assertFalse(Exists.modal());
253 GeneralUIUtils.ultimateWait();
257 public void testCloseNewPopup() {
258 SideMenu.navigateToTestEnvironmentsPage();
259 Click.byTestId(Constants.TestEnvironments.HEADLINE_NEW_BUTTON);
260 Wait.modalToBeDisplayed();
261 Assert.assertTrue(Exists.modal());
262 GeneralUIUtils.ultimateWait();
263 Click.byClass(Constants.TestEnvironments.MODAL_CLOSE_BUTTON_CLASS);
264 Wait.modalToDisappear();
265 GeneralUIUtils.ultimateWait();
266 Assert.assertFalse(Exists.modal());
267 GeneralUIUtils.ultimateWait();
271 public void testApplicationEnvironmentActivation() {
272 String envId = ENV_ID_FOR_ACTIVATION;
273 SimulatorApi.registerExpectation("environment/activate/get_operational_environments_aai1.json", SimulatorApi.RegistrationStrategy.APPEND);
274 SimulatorApi.registerExpectation("environment/activate/post_activate_operational_environment.json",
275 ImmutableMap.of("ENV-UUID", envId), SimulatorApi.RegistrationStrategy.APPEND);
276 SimulatorApi.registerExpectation("environment/status/get_cloud_resources_request_status.json",
277 ImmutableMap.of("status_message", Constants.TestEnvironments.environmentActivatedSuccesfullyMessage,
278 "REQUEST-TYPE","Activate"), SimulatorApi.RegistrationStrategy.APPEND);
279 clickOnActivationButtonAndUploadFile(envId, "manifest.json");
281 Click.byId(Constants.generalSubmitButtonId);
282 SimulatorApi.registerExpectation("environment/activate/get_operational_environments_aai1.json",
283 ImmutableMap.of("INACTIVE", "ACTIVE"), SimulatorApi.RegistrationStrategy.APPEND);
285 boolean waitForTextResult = Wait.waitByClassAndText("status", Constants.TestEnvironments.environmentActivatedSuccesfullyMessage, 60);
286 assertTrue(Constants.TestEnvironments.environmentActivatedSuccesfullyMessage + " message didn't appear on time", waitForTextResult);
288 vidBasePage.clickCloseButton();
290 GeneralUIUtils.ultimateWait();
292 WebElement deactivationButton = TestEnvironmentPage.getTestEnvironmentDeactivationButton(envId);
293 assertTrue("Failed to find Deactivate button for test env with id: "+envId, deactivationButton.isDisplayed());
295 WebElement status = Get.byId(Constants.TestEnvironments.environmentStatusIdPrefix + envId);
296 assertEquals("ACTIVE", status.getText());
298 WebElement attachButton = TestEnvironmentPage.getTestEnvironmentAttachButton(envId);
299 assertTrue("Failed to find Attach button for test env with id: "+envId, attachButton.isDisplayed());
301 //make sure page is clickable
302 SideMenu.navigateToTestEnvironmentsPage();
306 public void testApplicationEnvironmentDeactivation() {
307 String envId = ENV_ID_FOR_DEACTIVATION;
308 SimulatorApi.registerExpectation("environment/activate/get_operational_environments_aai1.json", SimulatorApi.RegistrationStrategy.APPEND);
309 SimulatorApi.registerExpectation("environment/deactivate/post_deactivate_operational_environment.json",
310 ImmutableMap.of("ENV-UUID", envId), SimulatorApi.RegistrationStrategy.APPEND);
311 SimulatorApi.registerExpectation("environment/status/get_cloud_resources_request_status.json",
312 ImmutableMap.of("status_message", Constants.TestEnvironments.environmentDeactivatedSuccesfullyMessage,
313 "REQUEST-TYPE","Deactivate"), SimulatorApi.RegistrationStrategy.APPEND);
314 deactivateEnv(envId);
316 SimulatorApi.registerExpectation("environment/deactivate/get_operational_environments_aai1.json", SimulatorApi.RegistrationStrategy.APPEND);
317 GeneralUIUtils.findAndWaitByText(Constants.TestEnvironments.environmentDeactivatedSuccesfullyMessage, 60);
319 vidBasePage.clickCloseButton();
321 GeneralUIUtils.ultimateWait();
323 WebElement activationButton = TestEnvironmentPage.getTestEnvironmentActivationButton(envId);
324 assertTrue("Failed to find Activate button for test env with id: "+envId, activationButton.isDisplayed());
326 WebElement status = Get.byId(Constants.TestEnvironments.environmentStatusIdPrefix + envId);
327 assertEquals("INACTIVE", status.getText());
329 WebElement attachButton = TestEnvironmentPage.getTestEnvironmentAttachButton(envId);
330 assertFalse("attach button shouldn't be displayed for test env with id: "+envId, attachButton.isDisplayed());
332 SideMenu.navigateToTestEnvironmentsPage();
335 private void deactivateEnv(String envId) {
336 vidBasePage.refreshPage();
337 SideMenu.navigateToTestEnvironmentsPage();
338 WebElement deactivationButton = TestEnvironmentPage.getTestEnvironmentDeactivationButton(envId);
339 assertTrue("Failed to find Deactivation button for test env with id: "+envId, deactivationButton.isDisplayed());
340 deactivationButton.click();
344 public static Object[][] badManifestProvider() {
345 return new Object[][]{
346 {"bad_manifest_structure.json","Manifest structure is wrong"},
347 {"manifest_with_wrong_recovery_action.json", "Wrong value for RecoveryAction in manifest. Allowed options are: abort,retry,skip. Wrong value is: leave"}
352 public void testApplicationEnvironmentActivationBadManifestStructure() throws Exception {
353 testApplicationEnvironmentActivationBadManifestStructure("bad_manifest_structure.json", "Manifest structure is wrong");
354 testApplicationEnvironmentActivationBadManifestStructure("manifest_with_wrong_recovery_action.json",
355 "Wrong value for RecoveryAction in manifest. Allowed options are: abort, retry, skip. Wrong value is: leave");
358 //@Test(dataProvider = "badManifestProvider") TODO : use data provider here (for some reason not work with ui-ci framework)
359 public void testApplicationEnvironmentActivationBadManifestStructure(String badManifestFileName, String exceptedErrorMsg) {
360 SimulatorApi.registerExpectation("environment/activate/get_operational_environments_aai1.json", SimulatorApi.RegistrationStrategy.APPEND);
361 clickOnActivationButtonAndUploadFile(ENV_ID_FOR_ACTIVATION, badManifestFileName);
362 WebElement attachButton = Get.byId("submit");
363 assertEquals("Wrong text for submit button in activate modal", "Attach", attachButton.getText());
364 attachButton.click();
365 boolean waitForTextResult = Wait.waitByClassAndText("error", exceptedErrorMsg, 30);
366 assertTrue(exceptedErrorMsg+ " message didn't appear on time", waitForTextResult);
367 GeneralUIUtils.ultimateWait();
368 vidBasePage.clickCloseButton();
369 Wait.modalToDisappear();
370 SideMenu.navigateToTestEnvironmentsPage();
374 public void testApplicationEnvironmentActivationNonJsonManifest() {
375 SimulatorApi.registerExpectation("environment/activate/get_operational_environments_aai1.json", SimulatorApi.RegistrationStrategy.APPEND);
376 String fileName = "non_valid_json.json";
377 clickOnActivationButtonAndUploadFile(ENV_ID_FOR_ACTIVATION, fileName);
378 WebElement errorLabel = Get.byId("errorLabel");
379 assertEquals("wrong error message for non valid json file", "file: " + fileName + " is not a valid JSON", errorLabel.getText());
380 vidBasePage.clickCancelButton();
381 GeneralUIUtils.ultimateWait();
384 private void clickOnActivationButtonAndUploadFile(String envId, String inputFileName) {
385 vidBasePage.refreshPage();
386 SideMenu.navigateToTestEnvironmentsPage();
387 WebElement activationButton = TestEnvironmentPage.getTestEnvironmentActivationButton(envId);
388 assertTrue("Failed to find Activate button for test env with id: "+envId, activationButton.isDisplayed());
389 activationButton.click();
390 updateEnvManifestFile(inputFileName);
391 assertTrue("Manifest file name is wrong in test environment activation modal",
392 Wait.waitByIdAndText("manifestFileName", inputFileName, 10));
395 private void updateEnvManifestFile(String inputFileName) {
396 GeneralUIUtils.ultimateWait();
397 Input.file("applicationEnvironment/"+inputFileName, "testEnvManifestFileInput");
398 GeneralUIUtils.ultimateWait();
402 public void testAttachManifestFileHappyFlow() {
403 String envId = ENV_ID_FOR_ACTIVATION;
404 SimulatorApi.registerExpectation("environment/activate/post_activate_operational_environment.json",
405 ImmutableMap.of("ENV-UUID", envId), SimulatorApi.RegistrationStrategy.APPEND);
406 SimulatorApi.registerExpectation("environment/attachManifest/get_attachable_operational_environment.json", SimulatorApi.RegistrationStrategy.APPEND);
407 SimulatorApi.registerExpectation("environment/status/get_cloud_resources_request_status.json",
408 ImmutableMap.of("status_message", Constants.TestEnvironments.environmentActivatedSuccesfullyMessage), SimulatorApi.RegistrationStrategy.APPEND);
409 vidBasePage.refreshPage();
410 SideMenu.navigateToTestEnvironmentsPage();
411 WebElement attachButton = TestEnvironmentPage.getTestEnvironmentAttachButton(ENV_ID_FOR_ACTIVATION);
412 attachButton.click();
414 updateEnvManifestFile("manifest.json");
416 Click.byId(Constants.generalSubmitButtonId);
418 boolean waitForTextResult = Wait.waitByClassAndText("status", Constants.TestEnvironments.environmentActivatedSuccesfullyMessage, 60);
419 assertTrue(Constants.TestEnvironments.environmentActivatedSuccesfullyMessage + " message didn't appear on time", waitForTextResult);
421 vidBasePage.clickCloseButton();
424 public void testApplicationEnvironmentActivationErrorResponseFromMso() throws Exception {
425 String payload = "ERROR_PAYLOAD";
426 testApplicationEnvironmentActivationErrorResponseFromMso(HttpStatus.INTERNAL_SERVER_ERROR, payload, FailureType.ACTIVATION_FAILURE);
427 testApplicationEnvironmentActivationErrorResponseFromMso(HttpStatus.BAD_REQUEST, payload, FailureType.ACTIVATION_FAILURE);
428 testApplicationEnvironmentActivationErrorResponseFromMso(HttpStatus.INTERNAL_SERVER_ERROR, payload, FailureType.GET_STATUS_FAILURE);
429 testApplicationEnvironmentActivationErrorResponseFromMso(HttpStatus.BAD_REQUEST, payload, FailureType.GET_STATUS_FAILURE);
433 public void testApplicationEnvironmentActivationErrorResponseFromMso(HttpStatus errorStatus, String payload, FailureType failureType) {
435 String envId = ENV_ID_FOR_ACTIVATION;
436 SimulatorApi.registerExpectation("environment/activate/get_operational_environments_aai1.json", SimulatorApi.RegistrationStrategy.APPEND);
437 switch (failureType) {
438 case ACTIVATION_FAILURE:
439 SimulatorApi.registerExpectation("environment/activate/mso_error_response_for_post_operational_environment.json",
440 ImmutableMap.of("ERROR_CODE", errorStatus.value(), "ENV-UUID", envId), SimulatorApi.RegistrationStrategy.APPEND);
442 case GET_STATUS_FAILURE:
443 SimulatorApi.registerExpectation("environment/activate/post_activate_operational_environment.json",
444 ImmutableMap.of("ENV-UUID", envId), SimulatorApi.RegistrationStrategy.APPEND);
448 SimulatorApi.registerExpectation("environment/status/get_cloud_resources_request_status_bad_response.json",
449 ImmutableMap.of("ERROR_CODE", errorStatus.value(), "ENV-UUID", envId), SimulatorApi.RegistrationStrategy.APPEND);
451 clickOnActivationButtonAndUploadFile(envId, "manifest.json");
452 Click.byId(Constants.generalSubmitButtonId);
453 Wait.waitByClassAndText("error", "System failure", 60);
454 Wait.waitByClassAndText("log", errorStatus.getReasonPhrase(), 60);
455 Wait.waitByClassAndText("log", payload, 60);
456 vidBasePage.clickCloseButton();
458 GeneralUIUtils.waitForAngular();
460 WebElement status = Get.byId(Constants.TestEnvironments.environmentStatusIdPrefix + envId);
461 assertEquals(Constants.INACTIVE, status.getText());
462 //make sure page is clickable
463 SideMenu.navigateToTestEnvironmentsPage();
467 public void testApplicationEnvironmentDeactivationErrorResponseFromMso() throws Exception {
468 String payload = "<html><head><title>Error</title></head><body>REASON</body></html>";
469 testApplicationEnvironmentDeactivationErrorResponseFromMso(HttpStatus.INTERNAL_SERVER_ERROR, payload, FailureType.DEACTIVATION_FAILURE);
470 testApplicationEnvironmentDeactivationErrorResponseFromMso(HttpStatus.BAD_REQUEST, payload, FailureType.DEACTIVATION_FAILURE);
471 testApplicationEnvironmentDeactivationErrorResponseFromMso(HttpStatus.INTERNAL_SERVER_ERROR, payload, FailureType.GET_STATUS_FAILURE);
472 testApplicationEnvironmentDeactivationErrorResponseFromMso(HttpStatus.BAD_REQUEST, payload, FailureType.GET_STATUS_FAILURE);
475 public void testApplicationEnvironmentDeactivationErrorResponseFromMso(HttpStatus errorStatus, String payload, FailureType failureType) {
476 String envId = ENV_ID_FOR_DEACTIVATION;
477 payload = payload.replace("REASON", errorStatus.getReasonPhrase());
478 SimulatorApi.registerExpectation("environment/activate/get_operational_environments_aai1.json", SimulatorApi.RegistrationStrategy.APPEND);
479 switch (failureType) {
480 case DEACTIVATION_FAILURE:
481 SimulatorApi.registerExpectation("environment/deactivate/error_deactivate_operational_environment.json",
482 ImmutableMap.of("ERROR_CODE", errorStatus.value(), "ENV-UUID", envId,"ERROR_PAYLOAD", payload), SimulatorApi.RegistrationStrategy.APPEND);
484 case GET_STATUS_FAILURE:
485 SimulatorApi.registerExpectation("environment/deactivate/post_deactivate_operational_environment.json",
486 ImmutableMap.of("ENV-UUID", envId), SimulatorApi.RegistrationStrategy.APPEND);
489 SimulatorApi.registerExpectation("environment/status/get_cloud_resources_request_status_bad_response.json",
490 ImmutableMap.of("ERROR_CODE", errorStatus.value(), "ENV-UUID", envId, "ERROR_PAYLOAD", payload), SimulatorApi.RegistrationStrategy.APPEND);
491 deactivateEnv(envId);
493 Wait.waitByClassAndText("error", "System failure", 60);
494 Wait.waitByClassAndText("log", errorStatus.getReasonPhrase(), 60);
495 Wait.waitByClassAndText("log", payload, 60);
496 vidBasePage.clickCloseButton();
498 GeneralUIUtils.ultimateWait();
500 WebElement status = Get.byId(Constants.TestEnvironments.environmentStatusIdPrefix + envId);
501 assertEquals(Constants.ACTIVE, status.getText());
502 //make sure page is clickable
503 SideMenu.navigateToTestEnvironmentsPage();
506 private String fullListId() {
507 return Features.FLAG_1908_RELEASE_TENANT_ISOLATION.isActive() ?
508 Constants.TestEnvironments.FULL_LIST : Constants.TestEnvironments.FULL_LIST_WITHOUT_RELEASE_LABEL;