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