use of io.cucumber.java.en.Then in project syndesis-qe by syndesisio.
the class MetricsSteps method checkDateFrom.
/*e.g. Since Dec 19th 10:42*/
@Then("^check that startdate for ([^\"]*) pod is valid$")
public void checkDateFrom(String integration) throws ParseException, InterruptedException {
String startTime = metricsTab.getStartTime();
Date uiStartDate = parseUiSinceDate(startTime);
// UI date and start date cannot be same, Issue: gh-4303
int timeout = 0;
while (isSameAsCurrentDate(uiStartDate)) {
timeout++;
log.info("UI time is same as actual, probably the issue: gh-4303. Waiting 30 seconds and refresh UI. " + timeout + ". attempt.");
Thread.sleep(30000);
refresh();
startTime = metricsTab.getStartTime();
uiStartDate = parseUiSinceDate(startTime);
if (timeout == 10) {
fail("UI time is same as actual time which is impossible");
}
}
Optional<Pod> pod = OpenShiftUtils.getPodByPartialName(integration);
if (pod.isPresent()) {
String openshiftTime = pod.get().getStatus().getStartTime();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
format.setTimeZone(TimeZone.getTimeZone("UTC"));
Date openshiftStartDate = format.parse(openshiftTime);
Calendar uiDate = Calendar.getInstance();
uiDate.setTime(uiStartDate);
uiDate.clear(Calendar.SECOND);
Calendar openshiftDate = Calendar.getInstance();
openshiftDate.setTime(openshiftStartDate);
// because UI doesn't contains seconds and minutes are rounded e.g. 8:23:42 is in UI 8:24
openshiftDate = DateUtils.round(openshiftDate, Calendar.MINUTE);
openshiftDate.clear(Calendar.SECOND);
assertThat(uiDate.getTime()).as("Check that UI date of pod '%s' is same as date in the openshift '%s'.", startTime, openshiftTime).isCloseTo(openshiftDate.getTime(), // UI sometimes round time UP sometimes not
60000L);
} else {
fail("Pod with name " + integration + " doesn't exist!");
}
}
use of io.cucumber.java.en.Then in project syndesis-qe by syndesisio.
the class MetricsSteps method checkUptime.
@Then("^check that uptime for ([^\"]*) pod is valid$")
public void checkUptime(String integration) throws ParseException, InterruptedException {
Optional<Pod> pod = OpenShiftUtils.getPodByPartialName(integration);
if (pod.isPresent()) {
refresh();
// To minimize inaccuracy they should be called together
String uptime = metricsTab.getUpTime();
String openshiftTime = pod.get().getStatus().getStartTime();
if (uptime.contains("No Data Available")) {
// gh-5100
TestUtils.sleepIgnoreInterrupt(61000);
refresh();
uptime = metricsTab.getUpTime();
openshiftTime = pod.get().getStatus().getStartTime();
}
Pattern pattern = Pattern.compile("^(\\d{1,2}) (second|minute)(s)?$");
Matcher matcher = pattern.matcher(uptime);
if (!matcher.find()) {
fail("UI uptime " + uptime + " doesn't match pattern.");
}
Long uiMinute = (matcher.group(2).contains("second")) ? 1 : Long.parseLong(matcher.group(1));
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
format.setTimeZone(TimeZone.getTimeZone("UTC"));
Date openShiftStartDate = format.parse(openshiftTime);
long diff = new Date().getTime() - openShiftStartDate.getTime();
long openShiftMinutes = TimeUnit.MILLISECONDS.toMinutes(diff);
assertThat(uiMinute).as("Check that UI uptime '%s' is same as openshift uptime '%s'.", uiMinute, openShiftMinutes).isCloseTo(openShiftMinutes, // 1-second inaccuracy can happen
within(Long.valueOf(1)));
} else {
fail("Pod with name " + integration + " doesn't exist!");
}
}
use of io.cucumber.java.en.Then in project syndesis-qe by syndesisio.
the class DocsVerificationSteps method checkVersion.
@Then("^check version in about page$")
public void checkVersion() {
By versionOnAboutPage = By.cssSelector("[data-testid=\"about-modal-content-version-list-item\"]");
assertThat($(versionOnAboutPage).shouldBe(visible).getText()).isNotEmpty();
assertThat($(versionOnAboutPage).getText()).isEqualTo(TestUtils.getSyndesisVersion());
}
use of io.cucumber.java.en.Then in project syndesis-qe by syndesisio.
the class DocsVerificationSteps method verifyDocsVersion.
@Then("verify whether the docs has right version")
public void verifyDocsVersion() {
Selenide.switchTo().window(1);
TestUtils.waitFor(() -> url().contains(".redhat.com"), 1, 15, "URL was not found");
if (TestUtils.isProdBuild()) {
assertThat(url().split("/")[6]).isEqualTo(currentVersion);
} else {
assertThat(url().split("/")[6]).isEqualTo(latestReleasedVersion);
By versionOnUserGuide = By.cssSelector(".productnumber");
assertThat($(versionOnUserGuide).shouldBe(visible).getText()).isNotEmpty();
assertThat($(versionOnUserGuide).getText()).isEqualTo(latestReleasedVersion);
}
Selenide.closeWindow();
}
use of io.cucumber.java.en.Then in project syndesis-qe by syndesisio.
the class ODataSteps method oDataServiceDoesntContain.
@Then("^.*check that entity \"([^\"]*)\" is not present in \"([^\"]*)\" collection on OData( V2)? service$")
public void oDataServiceDoesntContain(final String entityKey, final String collection, String v2) {
HTTPResponse response = HTTPUtils.doGetRequest((v2 != null && !v2.isEmpty() ? ODataUtils.getCurrentV2Url() : ODataUtils.getV4OpenshiftRoute()) + collection + "(" + entityKey + ")");
assertThat(response.getCode()).isEqualTo(404);
}
Aggregations