Search in sources :

Example 11 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(), Matchers.hasSize(15)));
    List<SubscriptionEventTypeStats> subscriptionStats = Collections.singletonList(new SubscriptionEventTypeStats(eventType.getName(), Collections.singletonList(new SubscriptionEventTypeStats.Partition("0", "assigned", 15L, null, 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, null, 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 12 with StringContains

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

the class ValidationHelper method findProblems.

public List<Problem> findProblems(ValidationProblem validationProblem) {
    StringContains regexpMatcher = new StringContains(validationProblem.getMessage());
    MarkerDescriptionMatcher descriptionMatcher = new MarkerDescriptionMatcher(regexpMatcher);
    List<Problem> filteredProblems = new ArrayList<Problem>();
    try {
        /**
         * Sometimes happens that marker is displayed and suddenly is hidden and displayed again,
         * so it is better to wait and doublecheck.
         */
        new WaitUntil(new ProblemExists(validationProblem.getProblemType(), descriptionMatcher), TimePeriod.LONG);
        new WaitWhile(new ProblemExists(validationProblem.getProblemType(), descriptionMatcher), TimePeriod.getCustom(5), false);
        new WaitUntil(new ProblemExists(validationProblem.getProblemType(), descriptionMatcher), TimePeriod.DEFAULT);
        ProblemsView pw = new ProblemsView();
        pw.open();
        new WaitUntil(new ProblemExists(ProblemType.ALL), TimePeriod.MEDIUM, false);
        filteredProblems = pw.getProblems(validationProblem.getProblemType(), descriptionMatcher);
    } catch (WaitTimeoutExpiredException ex) {
        log.warn(validationProblem.toString() + " not found.");
    }
    logProblemViewStatus(filteredProblems);
    return filteredProblems;
}
Also used : WaitWhile(org.eclipse.reddeer.common.wait.WaitWhile) ProblemExists(org.eclipse.reddeer.eclipse.condition.ProblemExists) WaitTimeoutExpiredException(org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException) ArrayList(java.util.ArrayList) Problem(org.eclipse.reddeer.eclipse.ui.problems.Problem) ValidationProblem(org.jboss.tools.cdi.reddeer.validators.ValidationProblem) MarkerDescriptionMatcher(org.eclipse.reddeer.eclipse.ui.markers.matcher.MarkerDescriptionMatcher) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) ProblemsView(org.eclipse.reddeer.eclipse.ui.views.markers.ProblemsView) StringContains(org.hamcrest.core.StringContains)

Example 13 with StringContains

use of org.hamcrest.core.StringContains in project reddeer by eclipse.

the class NewRuntimeWizardPage method selectType.

/**
 * Select type.
 *
 * @param type the type
 */
public NewRuntimeWizardPage selectType(String... type) {
    new WaitUntil(new NamedThreadHasStatus(new StringContains("Initializing Servers view"), Thread.State.TERMINATED, true));
    new DefaultTreeItem(new DefaultTree(this), type).select();
    return this;
}
Also used : DefaultTree(org.eclipse.reddeer.swt.impl.tree.DefaultTree) NamedThreadHasStatus(org.eclipse.reddeer.core.condition.NamedThreadHasStatus) DefaultTreeItem(org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) StringContains(org.hamcrest.core.StringContains)

Example 14 with StringContains

use of org.hamcrest.core.StringContains in project reddeer by eclipse.

the class NewServerWizardPage method selectType.

/**
 * Select type.
 *
 * @param type
 *            the type
 */
public NewServerWizardPage selectType(String... type) {
    new GroupWait(waitUntil(new NamedThreadHasStatus(new StringContains("Initializing Servers view"), Thread.State.TERMINATED, true)), waitUntil(new TreeContainsItem(new DefaultTree(this), type)));
    new DefaultTreeItem(new DefaultTree(this), type).select();
    new WaitUntil(new ControlIsEnabled(new NextButton(this)));
    return this;
}
Also used : DefaultTree(org.eclipse.reddeer.swt.impl.tree.DefaultTree) NamedThreadHasStatus(org.eclipse.reddeer.core.condition.NamedThreadHasStatus) NextButton(org.eclipse.reddeer.swt.impl.button.NextButton) ControlIsEnabled(org.eclipse.reddeer.swt.condition.ControlIsEnabled) DefaultTreeItem(org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem) TreeContainsItem(org.eclipse.reddeer.swt.condition.TreeContainsItem) GroupWait(org.eclipse.reddeer.common.wait.GroupWait) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) StringContains(org.hamcrest.core.StringContains)

Example 15 with StringContains

use of org.hamcrest.core.StringContains in project hive by apache.

the class TestMetastoreConf method dumpConfig.

@Test
public void dumpConfig() throws IOException {
    createConfFile("metastore-site.xml", true, "METASTORE_HOME", instaMap("test.long", "23"));
    conf = MetastoreConf.newMetastoreConf();
    String dump = MetastoreConf.dumpConfig(conf);
    Assert.assertThat(dump, new StringContains("Used metastore-site file: file:/"));
    Assert.assertThat(dump, new StringContains("Key: <test.long> old hive key: <hive.test.long>  value: <23>"));
    Assert.assertThat(dump, new StringContains("Key: <test.str> old hive key: <hive.test.str>  value: <defaultval>"));
    Assert.assertThat(dump, new StringEndsWith("Finished MetastoreConf object.\n"));
    // Make sure the hidden keys didn't get published
    Assert.assertThat(dump, CoreMatchers.not(new StringContains(ConfVars.PWD.getVarname())));
}
Also used : StringEndsWith(org.hamcrest.core.StringEndsWith) StringContains(org.hamcrest.core.StringContains) MetastoreUnitTest(org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest) Test(org.junit.Test)

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