Search in sources :

Example 96 with EventType

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

the class EventTypeDbRepositoryTest method unknownAttributesAreIgnoredWhenDesserializing.

@Test
public void unknownAttributesAreIgnoredWhenDesserializing() throws Exception {
    final EventType eventType = buildDefaultEventType();
    final ObjectNode node = (ObjectNode) TestUtils.OBJECT_MAPPER.readTree(TestUtils.OBJECT_MAPPER.writeValueAsString(eventType));
    node.set("unknown_attribute", new TextNode("will just be ignored"));
    final String eventTypeName = eventType.getName();
    final String insertSQL = "INSERT INTO zn_data.event_type (et_name, et_event_type_object) " + "VALUES (?, to_json(?::json))";
    template.update(insertSQL, eventTypeName, TestUtils.OBJECT_MAPPER.writeValueAsString(node));
    final EventType persistedEventType = repository.findByName(eventTypeName);
    assertThat(persistedEventType, notNullValue());
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) EventType(org.zalando.nakadi.domain.EventType) TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) TextNode(com.fasterxml.jackson.databind.node.TextNode) Test(org.junit.Test)

Example 97 with EventType

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

the class EventTypeDbRepositoryTest method whenCreateDuplicatedNamesThrowAnError.

@Test(expected = DuplicatedEventTypeNameException.class)
public void whenCreateDuplicatedNamesThrowAnError() throws Exception {
    final EventType eventType = buildDefaultEventType();
    repository.saveEventType(eventType);
    repository.saveEventType(eventType);
}
Also used : EventType(org.zalando.nakadi.domain.EventType) TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) Test(org.junit.Test)

Example 98 with EventType

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

the class EventTypeDbRepositoryTest method whenUpdateDifferentSchemaVersionThenInsertIt.

@Test
public void whenUpdateDifferentSchemaVersionThenInsertIt() throws NakadiException, IOException {
    final EventType eventType = buildDefaultEventType();
    repository.saveEventType(eventType);
    eventType.getSchema().setVersion(new Version("1.1.0"));
    repository.update(eventType);
    final int rows = template.queryForObject("SELECT count(*) FROM zn_data.event_type_schema where ets_event_type_name=?", Integer.class, eventType.getName());
    assertThat("Number of rows should increase", rows, equalTo(2));
}
Also used : EventType(org.zalando.nakadi.domain.EventType) TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) Version(org.zalando.nakadi.domain.Version) Test(org.junit.Test)

Example 99 with EventType

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

the class PartitionsControllerAT method testBeginShownForNoEvents.

@Test
public void testBeginShownForNoEvents() throws IOException {
    final EventType eventType = NakadiTestUtils.createEventType();
    when().get(String.format("/event-types/%s/partitions", eventType.getName())).then().statusCode(HttpStatus.OK.value()).body("oldest_available_offset[0]", equalTo("001-0001-000000000000000000")).body("newest_available_offset[0]", equalTo("001-0001--1"));
    when().get(String.format("/event-types/%s/partitions/%d", eventType.getName(), 0)).then().statusCode(HttpStatus.OK.value()).body("oldest_available_offset", equalTo("001-0001-000000000000000000")).body("newest_available_offset", equalTo("001-0001--1"));
}
Also used : EventType(org.zalando.nakadi.domain.EventType) Test(org.junit.Test)

Example 100 with EventType

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

the class SettingsControllerAT method testGetFlooders.

@Test
public void testGetFlooders() throws Exception {
    final EventType eventType = NakadiTestUtils.createEventType();
    blacklist(eventType.getName(), BlacklistService.Type.CONSUMER_ET);
    TestUtils.waitFor(() -> given().contentType(ContentType.JSON).get(BLACKLIST_URL).then().statusCode(HttpStatus.SC_OK).body("consumers.event_types", hasItems(eventType.getName())), 1000, 200);
}
Also used : EventType(org.zalando.nakadi.domain.EventType) 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