use of org.hamcrest.core.StringContains in project cactoos by yegor256.
the class UncheckedTextTest method rethrowsCheckedToUncheckedException.
@Test
void rethrowsCheckedToUncheckedException() {
final String msg = "intended";
new Assertion<>("Must throw an exception when something goes wrong", new UncheckedText(() -> {
throw new IOException(msg);
})::asString, new Throws<>(new StringContains(msg), RuntimeException.class)).affirm();
}
use of org.hamcrest.core.StringContains in project sling by apache.
the class GetPostTest method testValidGet.
@Test
public void testValidGet() throws ClientException, URISyntaxException {
MicrodataHtmlClient client = new MicrodataHtmlClient(httpServer.getURI().toString());
Document doc = client.get(GET_URL);
Assert.assertThat("GET request failed", doc.toString(), new StringContains(OK_RESPONSE));
}
use of org.hamcrest.core.StringContains in project verify-hub by alphagov.
the class TransactionConfigEntityDataTest method shouldThrowExceptionWhenLoadingConfigFileWithInvalidUserAccountAttributes.
@Test
public void shouldThrowExceptionWhenLoadingConfigFileWithInvalidUserAccountAttributes() throws IOException {
String badAttribute = "[ \"FIRST_NAME\", \"FIRST_NAME_VERIFIED\", \"INVALID_ATTRIBUTE\" ]";
InputStream badAttributeStream = new ByteArrayInputStream(badAttribute.getBytes());
ObjectMapper mapper = new ObjectMapper();
exception.expect(InvalidFormatException.class);
StringContains matcher = new StringContains("\"INVALID_ATTRIBUTE\": value not one of declared Enum instance names: [MIDDLE_NAME_VERIFIED, MIDDLE_NAME, DATE_OF_BIRTH, CURRENT_ADDRESS_VERIFIED, FIRST_NAME, SURNAME, SURNAME_VERIFIED, FIRST_NAME_VERIFIED, CURRENT_ADDRESS, DATE_OF_BIRTH_VERIFIED, ADDRESS_HISTORY, CYCLE_3]");
exception.expectMessage(matcher);
mapper.readValue(badAttributeStream, mapper.getTypeFactory().constructCollectionType(List.class, UserAccountCreationAttribute.class));
}
use of org.hamcrest.core.StringContains in project jbosstools-openshift by jbosstools.
the class DeployDockerImageTest method closeBrowser.
public static void closeBrowser() {
try {
BrowserEditor browser = new BrowserEditor(new StringContains("hello"));
browser.close();
} catch (RedDeerException ex) {
// do nothing, browser is not opened
}
}
use of org.hamcrest.core.StringContains in project jbosstools-openshift by jbosstools.
the class AbstractDockerImageTest method verifyDeployedDockerImageInBrowser.
/**
* Verifies whether an application pod has been created and application is
* running successfully.
*/
protected void verifyDeployedDockerImageInBrowser(String projectName, String podName, String expectedTextInBrowser, OpenShiftConnectionRequirement openshiftConnectionRequirement) {
new OpenShiftExplorerView().getOpenShift3Connection(openshiftConnectionRequirement.getConnection()).refresh();
try {
new WaitUntil(new OpenShiftResourceExists(Resource.POD, new StringContains(podName), ResourceState.RUNNING, projectName, openshiftConnectionRequirement.getConnection()), TimePeriod.VERY_LONG);
} catch (WaitTimeoutExpiredException ex) {
fail("There should be a running application pod for a deployed docker image, " + "but it does not exist.");
}
new OpenShiftExplorerView().getOpenShift3Connection(openshiftConnectionRequirement.getConnection()).refresh();
new OpenShiftExplorerView().getOpenShift3Connection(openshiftConnectionRequirement.getConnection()).getProject(projectName).getOpenShiftResources(Resource.ROUTE).get(0).select();
new ContextMenuItem(OpenShiftLabel.ContextMenu.SHOW_IN_BROWSER).select();
try {
new WaitUntil(new BrowserContainsText(expectedTextInBrowser), TimePeriod.VERY_LONG);
} catch (WaitTimeoutExpiredException ex) {
fail("Browser does not contain text:" + expectedTextInBrowser);
}
}
Aggregations