Search in sources :

Example 1 with StringContains

use of org.hamcrest.core.StringContains in project cactoos by yegor256.

the class TextHasStringTest method hasClearDescriptionForFailedTest.

@Test
public void hasClearDescriptionForFailedTest() throws Exception {
    final HexOf hex = new HexOf(new Md5DigestOf(new InputOf("Hello World!")));
    final Description description = new StringDescription();
    final TextHasString matcher = new TextHasString("ed076287532e86365e841e92bfc50d8c6");
    matcher.matchesSafely(hex);
    matcher.describeMismatchSafely(hex, description);
    MatcherAssert.assertThat("Description is not clear ", description.toString(), new StringContains("Text with \"ed076287532e86365e841e92bfc50d8c\""));
}
Also used : Md5DigestOf(org.cactoos.io.Md5DigestOf) Description(org.hamcrest.Description) StringDescription(org.hamcrest.StringDescription) HexOf(org.cactoos.text.HexOf) StringDescription(org.hamcrest.StringDescription) InputOf(org.cactoos.io.InputOf) StringContains(org.hamcrest.core.StringContains) Test(org.junit.Test)

Example 2 with StringContains

use of org.hamcrest.core.StringContains in project nakadi by zalando.

the class EventTypeControllerTest method whenPostOptionsRetentionTimeSmallerThanMin.

@Test
public void whenPostOptionsRetentionTimeSmallerThanMin() throws Exception {
    final EventType defaultEventType = buildDefaultEventType();
    defaultEventType.getOptions().setRetentionTime(86399999L);
    postEventType(defaultEventType).andExpect(status().is4xxClientError()).andExpect(content().string(new StringContains("Field \\\"options.retention_time\\\" can not be less than 86400000")));
}
Also used : TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) EventType(org.zalando.nakadi.domain.EventType) StringContains(org.hamcrest.core.StringContains) Test(org.junit.Test)

Example 3 with StringContains

use of org.hamcrest.core.StringContains in project nakadi by zalando.

the class HilaAT method testGetSubscriptionStat.

@Test(timeout = 10000)
public void testGetSubscriptionStat() throws Exception {
    publishEvents(eventType.getName(), 15, i -> "{\"foo\":\"bar\"}");
    final TestStreamingClient client = TestStreamingClient.create(URL, subscription.getId(), "max_uncommitted_events=20").start();
    waitFor(() -> assertThat(client.getBatches(), hasSize(15)));
    List<SubscriptionEventTypeStats> subscriptionStats = Collections.singletonList(new SubscriptionEventTypeStats(eventType.getName(), Collections.singletonList(new SubscriptionEventTypeStats.Partition("0", "assigned", 15L, client.getSessionId(), AUTO))));
    NakadiTestUtils.getSubscriptionStat(subscription).then().content(new StringContains(JSON_TEST_HELPER.asJsonString(new ItemsWrapper<>(subscriptionStats))));
    final String partition = client.getBatches().get(0).getCursor().getPartition();
    final SubscriptionCursor cursor = new SubscriptionCursor(partition, "9", eventType.getName(), "token");
    commitCursors(subscription.getId(), ImmutableList.of(cursor), client.getSessionId());
    subscriptionStats = Collections.singletonList(new SubscriptionEventTypeStats(eventType.getName(), Collections.singletonList(new SubscriptionEventTypeStats.Partition("0", "assigned", 5L, client.getSessionId(), AUTO))));
    NakadiTestUtils.getSubscriptionStat(subscription).then().content(new StringContains(JSON_TEST_HELPER.asJsonString(new ItemsWrapper<>(subscriptionStats))));
}
Also used : SubscriptionCursor(org.zalando.nakadi.view.SubscriptionCursor) TestStreamingClient(org.zalando.nakadi.webservice.utils.TestStreamingClient) SubscriptionEventTypeStats(org.zalando.nakadi.domain.SubscriptionEventTypeStats) StringContains(org.hamcrest.core.StringContains) Test(org.junit.Test)

Example 4 with StringContains

use of org.hamcrest.core.StringContains in project jbosstools-openshift by jbosstools.

the class CreateServerAdapterTest method finishNewServerAdapterWizardAndVerifyExistence.

public void finishNewServerAdapterWizardAndVerifyExistence() {
    new FinishButton().click();
    new WaitWhile(new ShellIsAvailable(OpenShiftLabel.Shell.ADAPTER));
    boolean jobExists = false;
    try {
        new WaitUntil(new JobIsRunning(new StringContains(JOB_NAME)), TimePeriod.getCustom(5));
        jobExists = true;
    } catch (WaitTimeoutExpiredException e) {
    // job is not running, do nothing
    }
    if (jobExists) {
        new WaitUntil(new JobIsKilled(JOB_NAME), TimePeriod.VERY_LONG);
    }
    assertTrue("OpenShift 3 server adapter was not created.", new ServerAdapterExists(Version.OPENSHIFT3, "eap-app", "Service").test());
}
Also used : ShellIsAvailable(org.eclipse.reddeer.swt.condition.ShellIsAvailable) FinishButton(org.eclipse.reddeer.swt.impl.button.FinishButton) WaitWhile(org.eclipse.reddeer.common.wait.WaitWhile) ServerAdapterExists(org.jboss.tools.openshift.reddeer.condition.ServerAdapterExists) WaitTimeoutExpiredException(org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException) JobIsKilled(org.eclipse.reddeer.workbench.core.condition.JobIsKilled) JobIsRunning(org.eclipse.reddeer.workbench.core.condition.JobIsRunning) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) StringContains(org.hamcrest.core.StringContains)

Example 5 with StringContains

use of org.hamcrest.core.StringContains in project jbosstools-openshift by jbosstools.

the class DeployDockerImageTest method verifyDeployedHelloWorldDockerImage.

/**
 * Verifies whether an application pod has been created and application is running successfully.
 */
private void verifyDeployedHelloWorldDockerImage(String projectName) {
    new OpenShiftExplorerView().getOpenShift3Connection(openshiftConnectionRequirement.getConnection()).refresh();
    try {
        new WaitUntil(new OpenShiftResourceExists(Resource.POD, new StringContains("hello-openshift"), 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 {
        // getRouteURL("hello-openshift", projectName),
        new WaitUntil(new BrowserContainsText("Hello OpenShift!"), TimePeriod.VERY_LONG);
    } catch (WaitTimeoutExpiredException ex) {
        fail("Browser does not contain hello world content.");
    }
}
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)22 Test (org.junit.Test)18 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 Logger (java.util.logging.Logger)5 OutputStream (java.io.OutputStream)4 EventType (org.zalando.nakadi.domain.EventType)4 LengthOf (org.cactoos.scalar.LengthOf)3 ResultActions (org.springframework.test.web.servlet.ResultActions)3 SubscriptionEventTypeStats (org.zalando.nakadi.domain.SubscriptionEventTypeStats)3 TestUtils.buildDefaultEventType (org.zalando.nakadi.utils.TestUtils.buildDefaultEventType)3 TestStreamingClient (org.zalando.nakadi.webservice.utils.TestStreamingClient)3 Path (java.nio.file.Path)2 BytesOf (org.cactoos.bytes.BytesOf)2 WaitTimeoutExpiredException (org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException)2 WaitUntil (org.eclipse.reddeer.common.wait.WaitUntil)2 AllOf (org.hamcrest.core.AllOf)2 MVCBaseSecurityIntegrationTest (org.nextprot.api.web.dbunit.base.mvc.MVCBaseSecurityIntegrationTest)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1