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\""));
}
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")));
}
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))));
}
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());
}
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.");
}
}
Aggregations