Search in sources :

Example 21 with StringContains

use of org.hamcrest.core.StringContains in project nextprot-api by calipho-sib.

the class XMLWebTest method shouldGetXmlWellFormatted2.

@Test
public void shouldGetXmlWellFormatted2() throws Exception {
    ResultActions result = this.mockMvc.perform(get("/entry/NX_P48730.xml"));
    result.andExpect(xpath("//publication[@id='14815724']//journal").exists());
    result.andExpect(content().string(new StringContains("& cell biology")));
}
Also used : ResultActions(org.springframework.test.web.servlet.ResultActions) StringContains(org.hamcrest.core.StringContains) MVCBaseSecurityIntegrationTest(org.nextprot.api.web.dbunit.base.mvc.MVCBaseSecurityIntegrationTest) Test(org.junit.Test)

Example 22 with StringContains

use of org.hamcrest.core.StringContains in project nextprot-api by calipho-sib.

the class AnnotationWebTest method shouldGetXML.

@Test
public void shouldGetXML() throws Exception {
    ResultActions result = this.mockMvc.perform(get("/entry/NX_P12345/annotation.xml"));
    result.andExpect(xpath("annotation-list/annotation-to-be-renamed").nodeCount(2));
    result.andExpect(xpath("annotation-list/annotation-to-be-renamed[@category='go biological process']/annotation").nodeCount(1));
    result.andExpect(xpath("annotation-list/annotation-to-be-renamed[@category='go molecular function']/annotation").nodeCount(4));
    result.andExpect(xpath("annotation-list/annotation-to-be-renamed[@category='go biological process']/annotation/description").string(new StringContains("Binds to AB1, AB5 and AB4")));
}
Also used : ResultActions(org.springframework.test.web.servlet.ResultActions) StringContains(org.hamcrest.core.StringContains) MVCDBUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.MVCDBUnitBaseTest) Test(org.junit.Test)

Example 23 with StringContains

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

the class HilaAT method testSubscriptionStatsMultiET.

@Test
public void testSubscriptionStatsMultiET() throws IOException {
    final List<EventType> eventTypes = Lists.newArrayList(createEventType(), createEventType());
    publishEvents(eventTypes.get(0).getName(), 10, i -> "{\"foo\":\"bar\"}");
    publishEvents(eventTypes.get(1).getName(), 20, i -> "{\"foo\":\"bar\"}");
    final Subscription subscription = createSubscription(RandomSubscriptionBuilder.builder().withEventTypes(eventTypes.stream().map(EventType::getName).collect(Collectors.toSet())).withStartFrom(END).build());
    // client is needed only to initialize stats
    final TestStreamingClient client = TestStreamingClient.create(URL, subscription.getId(), "batch_flush_timeout=1").start();
    waitFor(() -> assertThat(client.getBatches().isEmpty(), is(false)));
    publishEvents(eventTypes.get(0).getName(), 1, i -> "{\"foo\":\"bar\"}");
    publishEvents(eventTypes.get(1).getName(), 2, i -> "{\"foo\":\"bar\"}");
    NakadiTestUtils.getSubscriptionStat(subscription).then().content(new StringContains(JSON_TEST_HELPER.asJsonString(new SubscriptionEventTypeStats(eventTypes.get(0).getName(), Collections.singletonList(new SubscriptionEventTypeStats.Partition("0", "assigned", 1L, null, client.getSessionId(), AUTO)))))).content(new StringContains(JSON_TEST_HELPER.asJsonString(new SubscriptionEventTypeStats(eventTypes.get(1).getName(), Collections.singletonList(new SubscriptionEventTypeStats.Partition("0", "assigned", 2L, null, client.getSessionId(), AUTO))))));
    client.close();
}
Also used : TestStreamingClient(org.zalando.nakadi.webservice.utils.TestStreamingClient) NakadiTestUtils.createEventType(org.zalando.nakadi.webservice.utils.NakadiTestUtils.createEventType) EventType(org.zalando.nakadi.domain.EventType) SubscriptionEventTypeStats(org.zalando.nakadi.domain.SubscriptionEventTypeStats) Subscription(org.zalando.nakadi.domain.Subscription) NakadiTestUtils.createSubscription(org.zalando.nakadi.webservice.utils.NakadiTestUtils.createSubscription) StringContains(org.hamcrest.core.StringContains) Test(org.junit.Test)

Example 24 with StringContains

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

the class HilaAT method testGetSubscriptionStatWhenDirectAssignment.

@Test(timeout = 10000)
public void testGetSubscriptionStatWhenDirectAssignment() throws Exception {
    // connect with 1 stream directly requesting the partition
    final TestStreamingClient client = new TestStreamingClient(URL, subscription.getId(), "", Optional.empty(), Optional.of("{\"partitions\":[" + "{\"event_type\":\"" + eventType.getName() + "\",\"partition\":\"0\"}]}"));
    client.start();
    // wait for rebalance to finish
    waitFor(() -> assertThat(getNumberOfAssignedStreams(subscription.getId()), Matchers.is(1)));
    NakadiTestUtils.getSubscriptionStat(subscription).then().content(new StringContains(JSON_TEST_HELPER.asJsonString(new SubscriptionEventTypeStats(eventType.getName(), Collections.singletonList(new SubscriptionEventTypeStats.Partition("0", "assigned", 0L, null, client.getSessionId(), DIRECT))))));
}
Also used : TestStreamingClient(org.zalando.nakadi.webservice.utils.TestStreamingClient) SubscriptionEventTypeStats(org.zalando.nakadi.domain.SubscriptionEventTypeStats) StringContains(org.hamcrest.core.StringContains) Test(org.junit.Test)

Example 25 with StringContains

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

the class EventTypeControllerTest method whenGetOptionsRetentionTimeExist.

@Test
public void whenGetOptionsRetentionTimeExist() throws Exception {
    final EventType defaultEventType = TestUtils.buildDefaultEventType();
    defaultEventType.getOptions().setRetentionTime(TOPIC_RETENTION_TIME_MS);
    final String eventTypeName = defaultEventType.getName();
    doReturn(defaultEventType).when(eventTypeCache).getEventType(eventTypeName);
    getEventType(eventTypeName).andExpect(status().is2xxSuccessful()).andExpect(content().string(new StringContains("\"options\":{\"retention_time\":172800000}")));
}
Also used : EventType(org.zalando.nakadi.domain.EventType) Matchers.anyString(org.mockito.Matchers.anyString) StringContains.containsString(org.hamcrest.core.StringContains.containsString) StringContains(org.hamcrest.core.StringContains) 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