use of org.zalando.nakadi.domain.EventTypeSchema in project nakadi by zalando.
the class SchemaRepositoryTest method buildEventWithMultipleSchemas.
private void buildEventWithMultipleSchemas(final String name) throws Exception {
final EventTypeSchemaBase schemaBase = new EventTypeSchemaBase(EventTypeSchemaBase.Type.JSON_SCHEMA, "schema");
final EventType eventType = EventTypeTestBuilder.builder().name(name).build();
insertEventType(eventType);
eventType.setSchema(new EventTypeSchema(schemaBase, "1.0.2", DateTime.parse("2016-12-07T10:44:16.378+01:00")));
insertSchema(eventType);
eventType.setSchema(new EventTypeSchema(schemaBase, "2.10.3", DateTime.parse("2016-12-07T10:54:16.778+01:00")));
insertSchema(eventType);
eventType.setSchema(new EventTypeSchema(schemaBase, "10.0.0", DateTime.parse("2016-12-07T10:57:16.200+01:00")));
insertSchema(eventType);
}
use of org.zalando.nakadi.domain.EventTypeSchema in project nakadi by zalando.
the class EventTypeDbRepositoryTest method whenCreateNewEventTypeAlsoInsertIntoSchemaTable.
@Test
public void whenCreateNewEventTypeAlsoInsertIntoSchemaTable() throws Exception {
final EventType eventType = buildDefaultEventType();
repository.saveEventType(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(1));
final SqlRowSet rs = template.queryForRowSet("SELECT ets_schema_object FROM zn_data.event_type_schema where ets_event_type_name=?", eventType.getName());
rs.next();
final EventTypeSchema persisted = TestUtils.OBJECT_MAPPER.readValue(rs.getString(1), EventTypeSchema.class);
assertThat(persisted.getVersion(), equalTo(eventType.getSchema().getVersion()));
assertThat(persisted.getCreatedAt(), notNullValue());
assertThat(persisted.getSchema(), equalTo(eventType.getSchema().getSchema()));
assertThat(persisted.getType(), equalTo(eventType.getSchema().getType()));
}
use of org.zalando.nakadi.domain.EventTypeSchema in project nakadi by zalando.
the class SchemaServiceTest method testGetSchemaSuccess.
@Test
public void testGetSchemaSuccess() throws Exception {
final EventType eventType = buildDefaultEventType();
Mockito.when(schemaRepository.getSchemaVersion(eventType.getName(), eventType.getSchema().getVersion().toString())).thenReturn(eventType.getSchema());
final Result<EventTypeSchema> result = schemaService.getSchemaVersion(eventType.getName(), eventType.getSchema().getVersion().toString());
Assert.assertTrue(result.isSuccessful());
Assert.assertEquals(eventType.getSchema().getVersion().toString(), result.getValue().getVersion().toString());
Assert.assertEquals(eventType.getSchema().getSchema(), result.getValue().getSchema());
}
Aggregations