Search in sources :

Example 21 with EventPublishResult

use of org.zalando.nakadi.domain.EventPublishResult in project nakadi by zalando.

the class EventPublisherTest method whenPublishIsSuccessfulThenResultIsSubmitted.

@Test
public void whenPublishIsSuccessfulThenResultIsSubmitted() throws Exception {
    final EventType eventType = buildDefaultEventType();
    final JSONArray batch = buildDefaultBatch(1);
    mockSuccessfulValidation(eventType);
    final EventPublishResult result = publisher.publish(batch.toString(), eventType.getName());
    assertThat(result.getStatus(), equalTo(EventPublishingStatus.SUBMITTED));
    verify(topicRepository, times(1)).syncPostBatch(any(), any());
}
Also used : EventPublishResult(org.zalando.nakadi.domain.EventPublishResult) TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) EventType(org.zalando.nakadi.domain.EventType) JSONArray(org.json.JSONArray) Test(org.junit.Test)

Example 22 with EventPublishResult

use of org.zalando.nakadi.domain.EventPublishResult in project nakadi by zalando.

the class EventPublisherTest method whenEventIsOneByteOverMaxSizeWithMultiByteCharsThenResultIsAborted.

@Test
public void whenEventIsOneByteOverMaxSizeWithMultiByteCharsThenResultIsAborted() throws Exception {
    final EventType eventType = buildDefaultEventType();
    final JSONArray batch = buildOneByteTooLargeBatchMultiByte(1);
    mockSuccessfulValidation(eventType);
    final EventPublishResult result = publisher.publish(batch.toString(), eventType.getName());
    assertThat(result.getStatus(), equalTo(EventPublishingStatus.ABORTED));
    verify(enrichment, times(0)).enrich(any(), any());
    verify(partitionResolver, times(0)).resolvePartition(any(), any());
    verify(topicRepository, times(0)).syncPostBatch(any(), any());
}
Also used : EventPublishResult(org.zalando.nakadi.domain.EventPublishResult) TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) EventType(org.zalando.nakadi.domain.EventType) JSONArray(org.json.JSONArray) Test(org.junit.Test)

Example 23 with EventPublishResult

use of org.zalando.nakadi.domain.EventPublishResult in project nakadi by zalando.

the class EventPublisherTest method whenEventIsExactlyMaxSizeWithMultiByteCharsThenResultIsSuccess.

@Test
public void whenEventIsExactlyMaxSizeWithMultiByteCharsThenResultIsSuccess() throws Exception {
    final EventType eventType = buildDefaultEventType();
    final JSONArray batch = buildMaxSizeBatchMultiByte(1);
    mockSuccessfulValidation(eventType);
    final EventPublishResult result = publisher.publish(batch.toString(), eventType.getName());
    assertThat(result.getStatus(), equalTo(EventPublishingStatus.SUBMITTED));
    verify(enrichment, times(1)).enrich(any(), any());
    verify(partitionResolver, times(1)).resolvePartition(any(), any());
    verify(topicRepository, times(1)).syncPostBatch(any(), any());
}
Also used : EventPublishResult(org.zalando.nakadi.domain.EventPublishResult) TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) EventType(org.zalando.nakadi.domain.EventType) JSONArray(org.json.JSONArray) Test(org.junit.Test)

Aggregations

EventPublishResult (org.zalando.nakadi.domain.EventPublishResult)23 Test (org.junit.Test)22 EventType (org.zalando.nakadi.domain.EventType)17 TestUtils.buildDefaultEventType (org.zalando.nakadi.utils.TestUtils.buildDefaultEventType)17 JSONArray (org.json.JSONArray)15 JSONObject (org.json.JSONObject)8 BatchItemResponse (org.zalando.nakadi.domain.BatchItemResponse)5 ArrayList (java.util.ArrayList)2 BatchItem (org.zalando.nakadi.domain.BatchItem)2 TestUtils.createBatchItem (org.zalando.nakadi.utils.TestUtils.createBatchItem)2 Supplier (java.util.function.Supplier)1 JSONException (org.json.JSONException)1 NakadiException (org.zalando.nakadi.exceptions.NakadiException)1 NoSuchEventTypeException (org.zalando.nakadi.exceptions.NoSuchEventTypeException)1 EventTypeMetrics (org.zalando.nakadi.metrics.EventTypeMetrics)1