1 package vid.automation.test.test;
3 import static org.hamcrest.MatcherAssert.assertThat;
4 import static org.hamcrest.Matchers.containsString;
5 import static org.hamcrest.Matchers.equalTo;
6 import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET;
8 import com.fasterxml.jackson.databind.ObjectMapper;
9 import com.google.common.collect.ImmutableList;
10 import java.io.IOException;
11 import java.util.Collection;
13 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
14 import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
15 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
16 import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet;
17 import org.openqa.selenium.remote.RemoteWebElement;
18 import org.testng.annotations.DataProvider;
19 import org.testng.annotations.Test;
20 import vid.automation.test.infra.Click;
21 import vid.automation.test.infra.Get;
22 import vid.automation.test.sections.VidBasePage;
23 import vid.automation.test.services.SimulatorApi;
25 public class HealthStatusTest extends VidBaseTestCase {
27 private VidBasePage vidBasePage = new VidBasePage();
30 public static Object[][] aaiHealthStatusProvider() {
31 return new Object[][]{
32 {ImmutableList.of(new PresetGetSessionSlotCheckIntervalGet()),
33 "border-not-ok", "No subscriber received", 404},
34 {ImmutableList.of(new PresetGetSessionSlotCheckIntervalGet(), new PresetAAIGetSubscribersGet()),
35 "border-is-ok", "OK", 200}
41 @Test(dataProvider = "aaiHealthStatusProvider")
42 public void testAaiHealthStatus(Collection<BasePreset> presets, String cssName, String description, int httpCode) throws IOException {
43 SimulatorApi.registerExpectationFromPresets(presets, CLEAR_THEN_SET);
45 GeneralUIUtils.ultimateWait(); //instead of assertTrue(Wait.waitByClassAndTextXpathOnly(cssName, "AAI", 10))
46 RemoteWebElement componentName = (RemoteWebElement)Get.byTestId("component-name-AAI");
47 assertThat("Wrong component name", componentName.getText(), equalTo("AAI"));
48 assertThat("Wrong css for component name", componentName.getAttribute("class"), containsString(cssName));
49 ObjectMapper objectMapper = new ObjectMapper();
50 RemoteWebElement componentMetadata = ((RemoteWebElement) Get.byTestId("component-metadata-AAI"));
51 assertThat("Wrong css for component details", componentName.getAttribute("class"), containsString(cssName));
52 Map<String, Object> details = objectMapper.readValue(componentMetadata.findElementsByTagName("pre").get(0).getText(), Map.class);
53 assertThat(details.get("description"), equalTo(description));
54 assertThat(details.get("httpMethod"), equalTo("GET"));
55 assertThat(details.get("httpCode"), equalTo(httpCode));
58 private void refreshStatus() {
59 vidBasePage.navigateTo("app/ui/#/healthStatus");
60 GeneralUIUtils.ultimateWait();
61 Click.byClass("icon-refresh");