@Then("^within (\\d+) (seconds?|minutes?), the ssh session output should (contain|satisfy) \"(.*?)\"$") public void assertSshOutputVerifies(long timeout, String timeoutUnit, String comparator, String expectedText) throws Throwable { TimeUnit unit; if (timeoutUnit.toLowerCase().startsWith("minute")) unit = TimeUnit.MINUTES; else if (timeoutUnit.toLowerCase().startsWith("second")) unit = TimeUnit.SECONDS; else { unit = TimeUnit.SECONDS; Assertions.fail("Unrecognized timeunit"); } await().atMost(timeout, unit).until(() -> { SshSession sshSession = sshWorld.peekSession(); String out = sshSession.getOut(); StringAssert stringAssert = assertThat(out); switch (comparator) { case "contain": stringAssert.contains(expectedText); break; case "satisfy": Pattern p = Pattern.compile(expectedText); assertThat(p.matcher(out).find()).isTrue(); } } ); }
@Test public void should_navigate_to_list_elements_and_perform_specific_string_assertions() { List<String> list = newArrayList("one", "two", "three"); assertThat(list, StringAssert.class).first().startsWith("o"); assertThat(list, StringAssert.class).last().endsWith("ee"); assertThat(list, StringAssert.class).element(1).contains("w"); }
@Test public void should_honor_list_assertions() { List<String> list = newArrayList("one", "two", "three"); assertThat(list, StringAssert.class).contains("one", atIndex(0)) .first().startsWith("o"); }
public StringAssert sectionId(){ return new StringAssert(actual.getSectionId()); }
public StringAssert value(){ return new StringAssert(actual.getValue()); }
public StringAssert description(){ return new StringAssert(actual.getDescription()); }
public StringAssert icon(){ return new StringAssert(actual.getIcon()); }
@Override public StringAssert createAssert(String string) { return new StringAssert(string); }
/** * Returns a {@link StringAssert} for the textual content of this element. * * @return The assert. */ public StringAssert textContent() { return new StringAssert(actual.getText()); }