use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class MetadataEnrichmentStrategyTest method setEventTypeSchemaVersion.
@Test
public void setEventTypeSchemaVersion() throws Exception {
final EventType eventType = buildDefaultEventType();
final JSONObject event = buildBusinessEvent();
final BatchItem batchItem = createBatchItem(event);
assertThat(batchItem.getEvent().getJSONObject("metadata").optString("version"), isEmptyString());
strategy.enrich(batchItem, eventType);
assertThat(batchItem.getEvent().getJSONObject("metadata").getString("version"), equalTo("1.0.0"));
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class SchemaControllerTest method testGetLatestSchemaVersionThen200.
@Test
public void testGetLatestSchemaVersionThen200() {
final EventType eventType = buildDefaultEventType();
Mockito.when(eventTypeService.get(eventType.getName())).thenReturn(Result.ok(eventType));
final ResponseEntity<?> result = new SchemaController(schemaService, eventTypeService).getSchemaVersion(eventType.getName(), "latest", nativeWebRequest);
Assert.assertEquals(HttpStatus.OK, result.getStatusCode());
Assert.assertEquals(eventType.getSchema().toString(), result.getBody().toString());
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class SchemaControllerTest method testGetLatestSchemaVersionByNumberThen200.
@Test
public void testGetLatestSchemaVersionByNumberThen200() {
final EventType eventType = buildDefaultEventType();
Mockito.when(schemaService.getSchemaVersion(eventType.getName(), eventType.getSchema().getVersion().toString())).thenReturn(Result.ok(eventType.getSchema()));
final ResponseEntity<?> result = new SchemaController(schemaService, eventTypeService).getSchemaVersion(eventType.getName(), eventType.getSchema().getVersion().toString(), nativeWebRequest);
Assert.assertEquals(HttpStatus.OK, result.getStatusCode());
Assert.assertEquals(eventType.getSchema().toString(), result.getBody().toString());
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeAuthorizationTest method whenDELETENotAuthorized200.
@Test
public void whenDELETENotAuthorized200() throws Exception {
final EventType eventType = EventTypeTestBuilder.builder().build();
final Resource resource = new EventTypeResource(eventType.getName(), eventType.getAuthorization());
doReturn(Optional.of(eventType)).when(eventTypeRepository).findByNameO(any());
doThrow(new AccessDeniedException(AuthorizationService.Operation.ADMIN, resource)).when(authorizationValidator).authorizeEventTypeAdmin(eventType);
deleteEventType(eventType.getName()).andExpect(status().isForbidden()).andExpect(content().string(matchesProblem(Problem.valueOf(Response.Status.FORBIDDEN, "Access on ADMIN event-type:" + eventType.getName() + " denied"))));
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class SchemaEvolutionService method bumpVersion.
private EventType bumpVersion(final EventType original, final EventTypeBase eventType, final Version.Level changeLevel) {
final DateTime now = new DateTime(DateTimeZone.UTC);
final String newVersion = original.getSchema().getVersion().bump(changeLevel).toString();
return new EventType(eventType, newVersion, original.getCreatedAt(), now);
}
Aggregations