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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations