Search in sources :

Example 1 with EventTypeSchema

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

the class SchemaServiceTest method testNonExistingVersionNumber.

@Test
public void testNonExistingVersionNumber() throws Exception {
    final EventType eventType = buildDefaultEventType();
    Mockito.when(schemaRepository.getSchemaVersion(eventType.getName(), eventType.getSchema().getVersion().bump(Version.Level.MINOR).toString())).thenThrow(NoSuchSchemaException.class);
    final Result<EventTypeSchema> result = schemaService.getSchemaVersion(eventType.getName(), eventType.getSchema().getVersion().bump(Version.Level.MINOR).toString());
    Assert.assertFalse(result.isSuccessful());
    Assert.assertEquals(Response.Status.NOT_FOUND, result.getProblem().getStatus());
}
Also used : EventTypeSchema(org.zalando.nakadi.domain.EventTypeSchema) EventType(org.zalando.nakadi.domain.EventType) TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) Test(org.junit.Test)

Example 2 with EventTypeSchema

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

the class SchemaServiceTest method testIllegalVersionNumber.

@Test
public void testIllegalVersionNumber() throws Exception {
    final EventType eventType = buildDefaultEventType();
    Mockito.when(schemaRepository.getSchemaVersion(eventType.getName() + "wrong", eventType.getSchema().getVersion().toString())).thenThrow(NoSuchSchemaException.class);
    final Result<EventTypeSchema> result = schemaService.getSchemaVersion(eventType.getName() + "wrong", eventType.getSchema().getVersion().toString());
    Assert.assertFalse(result.isSuccessful());
    Assert.assertEquals(Response.Status.NOT_FOUND, result.getProblem().getStatus());
}
Also used : EventTypeSchema(org.zalando.nakadi.domain.EventTypeSchema) EventType(org.zalando.nakadi.domain.EventType) TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) Test(org.junit.Test)

Example 3 with EventTypeSchema

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

the class SchemaRepositoryTest method whenGetOldSchemaReturnOld.

@Test
public void whenGetOldSchemaReturnOld() throws Exception {
    final String name = randomUUID();
    buildEventWithMultipleSchemas(name);
    final EventTypeSchema schema = repository.getSchemaVersion(name, "1.0.2");
    Assert.assertEquals("1.0.2", schema.getVersion().toString());
    Assert.assertEquals("schema", schema.getSchema());
}
Also used : EventTypeSchema(org.zalando.nakadi.domain.EventTypeSchema) Test(org.junit.Test)

Example 4 with EventTypeSchema

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

the class SchemaRepositoryTest method whenGetLatestSchemaReturnLatest.

@Test
public void whenGetLatestSchemaReturnLatest() throws Exception {
    final String name = randomUUID();
    buildEventWithMultipleSchemas(name);
    final EventTypeSchema schema = repository.getSchemaVersion(name, "10.0.0");
    Assert.assertEquals("10.0.0", schema.getVersion().toString());
    Assert.assertEquals("schema", schema.getSchema());
}
Also used : EventTypeSchema(org.zalando.nakadi.domain.EventTypeSchema) Test(org.junit.Test)

Example 5 with EventTypeSchema

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

the class SchemaRepositoryTest method whenListVersionsListedOrdered.

@Test
public void whenListVersionsListedOrdered() throws Exception {
    final String name = randomUUID();
    buildEventWithMultipleSchemas(name);
    final List<EventTypeSchema> schemas = repository.getSchemas(name, 0, 3);
    Assert.assertEquals(3, schemas.size());
    Assert.assertEquals(new Version("10.0.0"), schemas.get(0).getVersion());
    Assert.assertEquals(new Version("2.10.3"), schemas.get(1).getVersion());
    Assert.assertEquals(new Version("1.0.2"), schemas.get(2).getVersion());
    final int count = repository.getSchemasCount(name);
    Assert.assertEquals(3, count);
}
Also used : EventTypeSchema(org.zalando.nakadi.domain.EventTypeSchema) Version(org.zalando.nakadi.domain.Version) Test(org.junit.Test)

Aggregations

EventTypeSchema (org.zalando.nakadi.domain.EventTypeSchema)8 Test (org.junit.Test)7 EventType (org.zalando.nakadi.domain.EventType)5 TestUtils.buildDefaultEventType (org.zalando.nakadi.utils.TestUtils.buildDefaultEventType)4 SqlRowSet (org.springframework.jdbc.support.rowset.SqlRowSet)1 EventTypeSchemaBase (org.zalando.nakadi.domain.EventTypeSchemaBase)1 Version (org.zalando.nakadi.domain.Version)1