Search in sources :

Example 16 with StringContains

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();
}
Also used : HasToString(org.hamcrest.object.HasToString) IOException(java.io.IOException) Throws(org.llorllale.cactoos.matchers.Throws) StringContains(org.hamcrest.core.StringContains) Test(org.junit.jupiter.api.Test)

Example 17 with StringContains

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));
}
Also used : MicrodataHtmlClient(org.apache.sling.hapi.client.impl.microdata.MicrodataHtmlClient) Document(org.apache.sling.hapi.client.Document) StringContains(org.hamcrest.core.StringContains) Test(org.junit.Test)

Example 18 with StringContains

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));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) List(java.util.List) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) StringContains(org.hamcrest.core.StringContains) Test(org.junit.Test)

Example 19 with StringContains

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
    }
}
Also used : RedDeerException(org.eclipse.reddeer.common.exception.RedDeerException) BrowserEditor(org.eclipse.reddeer.eclipse.ui.browser.BrowserEditor) StringContains(org.hamcrest.core.StringContains)

Example 20 with StringContains

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);
    }
}
Also used : ContextMenuItem(org.eclipse.reddeer.swt.impl.menu.ContextMenuItem) WaitTimeoutExpiredException(org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException) BrowserContainsText(org.jboss.tools.openshift.reddeer.condition.BrowserContainsText) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) OpenShiftExplorerView(org.jboss.tools.openshift.reddeer.view.OpenShiftExplorerView) OpenShiftResourceExists(org.jboss.tools.openshift.reddeer.condition.OpenShiftResourceExists) StringContains(org.hamcrest.core.StringContains)

Aggregations

StringContains (org.hamcrest.core.StringContains)30 Test (org.junit.Test)21 WaitUntil (org.eclipse.reddeer.common.wait.WaitUntil)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 Logger (java.util.logging.Logger)5 WaitTimeoutExpiredException (org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException)5 OutputStream (java.io.OutputStream)4 LengthOf (org.cactoos.scalar.LengthOf)3 WaitWhile (org.eclipse.reddeer.common.wait.WaitWhile)3 EventType (org.zalando.nakadi.domain.EventType)3 StringContainsProto (androidx.test.espresso.proto.matcher13.HamcrestMatchersv13.StringContainsProto)2 GenericRemoteMessage (androidx.test.espresso.remote.GenericRemoteMessage)2 SmallTest (androidx.test.filters.SmallTest)2 Path (java.nio.file.Path)2 BytesOf (org.cactoos.bytes.BytesOf)2 NamedThreadHasStatus (org.eclipse.reddeer.core.condition.NamedThreadHasStatus)2 Problem (org.eclipse.reddeer.eclipse.ui.problems.Problem)2 ProblemsView (org.eclipse.reddeer.eclipse.ui.views.markers.ProblemsView)2 ShellIsAvailable (org.eclipse.reddeer.swt.condition.ShellIsAvailable)2 ContextMenuItem (org.eclipse.reddeer.swt.impl.menu.ContextMenuItem)2