Search in sources :

Example 76 with EventType

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

the class EventTypeAT method assertRetentionTime.

private void assertRetentionTime(final Long checkingRetentionTime, final String etName) throws IOException {
    final EventType eventType = NakadiTestUtils.getEventType(etName);
    Assert.assertEquals(checkingRetentionTime, eventType.getOptions().getRetentionTime());
    TIMELINE_REPOSITORY.listTimelinesOrdered(eventType.getName()).stream().map(Timeline::getTopic).forEach(topic -> waitFor(() -> Assert.assertEquals(checkingRetentionTime, KafkaTestHelper.getTopicRetentionTime(topic, ZOOKEEPER_URL))));
}
Also used : TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) EventType(org.zalando.nakadi.domain.EventType)

Example 77 with EventType

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

the class EventTypeAT method whenDELETEEventTypeThenOK.

@Test
public void whenDELETEEventTypeThenOK() throws JsonProcessingException, NoSuchEventTypeException {
    // ARRANGE //
    final EventType eventType = buildDefaultEventType();
    postEventType(eventType);
    final List<String> topics = getTopicsForEventType(eventType.getName());
    // ACT //
    deleteEventTypeAndOK(eventType);
    // ASSERT //
    checkEventTypeIsDeleted(eventType, topics);
}
Also used : TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) EventType(org.zalando.nakadi.domain.EventType) TestUtils.resourceAsString(org.zalando.nakadi.utils.TestUtils.resourceAsString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 78 with EventType

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

the class EventTypeAT method whenDELETEEventTypeWithOneTimelineThenOK.

@Test
public void whenDELETEEventTypeWithOneTimelineThenOK() throws JsonProcessingException, NoSuchEventTypeException {
    final EventType eventType = buildDefaultEventType();
    postEventType(eventType);
    postTimeline(eventType);
    final List<String> topics = getTopicsForEventType(eventType.getName());
    // ACT //
    deleteEventTypeAndOK(eventType);
    // ASSERT //
    checkEventTypeIsDeleted(eventType, topics);
}
Also used : TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) EventType(org.zalando.nakadi.domain.EventType) TestUtils.resourceAsString(org.zalando.nakadi.utils.TestUtils.resourceAsString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 79 with EventType

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

the class EventTypeAT method whenUpdateETAuthObjectThen422.

@Test
public void whenUpdateETAuthObjectThen422() throws Exception {
    final ResourceAuthorization auth = new ResourceAuthorization(Collections.singletonList(new ResourceAuthorizationAttribute("type1", "value1")), Collections.singletonList(new ResourceAuthorizationAttribute("type2", "value2")), Collections.singletonList(new ResourceAuthorizationAttribute("type3", "value3")));
    final EventType eventType = EventTypeTestBuilder.builder().authorization(auth).build();
    NakadiTestUtils.createEventTypeInNakadi(eventType);
    eventType.setAuthorization(null);
    given().body(MAPPER.writeValueAsString(eventType)).contentType(JSON).put("/event-types/" + eventType.getName()).then().statusCode(HttpStatus.SC_UNPROCESSABLE_ENTITY).body(equalTo(MAPPER.writer().writeValueAsString(Problem.valueOf(MoreStatus.UNPROCESSABLE_ENTITY, "Changing authorization object to `null` is not possible due to existing one"))));
}
Also used : ResourceAuthorization(org.zalando.nakadi.domain.ResourceAuthorization) TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) EventType(org.zalando.nakadi.domain.EventType) ResourceAuthorizationAttribute(org.zalando.nakadi.domain.ResourceAuthorizationAttribute) Test(org.junit.Test)

Example 80 with EventType

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

the class EventTypeAT method whenUpdatePartitioningStrategyToNonExistingStrategyThen422.

@Test
public void whenUpdatePartitioningStrategyToNonExistingStrategyThen422() throws JsonProcessingException {
    final EventType eventType = buildDefaultEventType();
    final String bodyRandom = MAPPER.writer().writeValueAsString(eventType);
    given().body(bodyRandom).header("accept", "application/json").contentType(JSON).post(ENDPOINT);
    eventType.setPartitionStrategy("random1");
    final String bodyUserDefined = MAPPER.writer().writeValueAsString(eventType);
    given().body(bodyUserDefined).header("accept", "application/json").contentType(JSON).put(ENDPOINT + "/" + eventType.getName()).then().statusCode(HttpStatus.SC_UNPROCESSABLE_ENTITY);
}
Also used : TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) EventType(org.zalando.nakadi.domain.EventType) TestUtils.resourceAsString(org.zalando.nakadi.utils.TestUtils.resourceAsString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

EventType (org.zalando.nakadi.domain.EventType)216 Test (org.junit.Test)183 TestUtils.buildDefaultEventType (org.zalando.nakadi.utils.TestUtils.buildDefaultEventType)138 JSONObject (org.json.JSONObject)40 Problem (org.zalando.problem.Problem)21 InternalNakadiException (org.zalando.nakadi.exceptions.InternalNakadiException)18 Matchers.containsString (org.hamcrest.Matchers.containsString)17 JSONArray (org.json.JSONArray)17 EventPublishResult (org.zalando.nakadi.domain.EventPublishResult)17 TestUtils.invalidProblem (org.zalando.nakadi.utils.TestUtils.invalidProblem)17 ThrowableProblem (org.zalando.problem.ThrowableProblem)17 Timeline (org.zalando.nakadi.domain.Timeline)16 NoSuchEventTypeException (org.zalando.nakadi.exceptions.NoSuchEventTypeException)14 EventTypeTestBuilder (org.zalando.nakadi.utils.EventTypeTestBuilder)14 BatchItem (org.zalando.nakadi.domain.BatchItem)12 TestUtils.resourceAsString (org.zalando.nakadi.utils.TestUtils.resourceAsString)12 List (java.util.List)11 Subscription (org.zalando.nakadi.domain.Subscription)11 TestUtils.createBatchItem (org.zalando.nakadi.utils.TestUtils.createBatchItem)11 Collectors (java.util.stream.Collectors)9