use of org.zalando.nakadi.utils.EventTypeTestBuilder in project nakadi by zalando.
the class SchemaEvolutionServiceTest method whenMinorChangesBumpVersion.
@Test
public void whenMinorChangesBumpVersion() throws Exception {
final EventTypeTestBuilder builder = EventTypeTestBuilder.builder();
final EventType oldEventType = builder.build();
final EventType newEventType = builder.build();
Mockito.doReturn(Optional.empty()).when(evolutionConstraint).validate(oldEventType, newEventType);
Mockito.doReturn(MINOR).when(compatibleChanges).get(any());
Mockito.doReturn(Lists.newArrayList(new SchemaChange(TITLE_CHANGED, "#/"))).when(schemaDiff).collectChanges(any(), any());
final EventType eventType = service.evolve(oldEventType, newEventType);
assertThat(eventType.getSchema().getVersion(), is(equalTo(new Version("1.1.0"))));
verify(evolutionConstraint).validate(oldEventType, newEventType);
}
use of org.zalando.nakadi.utils.EventTypeTestBuilder in project nakadi by zalando.
the class SchemaEvolutionServiceTest method whenNoChangesKeepVersion.
@Test
public void whenNoChangesKeepVersion() throws Exception {
final EventTypeTestBuilder builder = EventTypeTestBuilder.builder();
final EventType oldEventType = builder.build();
final EventType newEventType = builder.build();
Mockito.doReturn(Optional.empty()).when(evolutionConstraint).validate(oldEventType, newEventType);
final EventType eventType = service.evolve(oldEventType, newEventType);
assertThat(eventType.getSchema().getVersion(), is(equalTo(new Version("1.0.0"))));
verify(evolutionConstraint).validate(oldEventType, newEventType);
}
use of org.zalando.nakadi.utils.EventTypeTestBuilder in project nakadi by zalando.
the class CompatibilityModeChangeConstraintTest method cannotDowngradeCompatibilityMode.
@Test
public void cannotDowngradeCompatibilityMode() throws Exception {
final EventTypeTestBuilder builder = new EventTypeTestBuilder();
final EventType oldET = builder.compatibilityMode(CompatibilityMode.COMPATIBLE).build();
final EventType newET = builder.compatibilityMode(CompatibilityMode.NONE).build();
final CompatibilityModeChangeConstraint constraint = new CompatibilityModeChangeConstraint();
assertThat(constraint.validate(oldET, newET), isPresent());
}
use of org.zalando.nakadi.utils.EventTypeTestBuilder in project nakadi by zalando.
the class CompatibilityModeChangeConstraintTest method canPromoteFromForwardToCompatible.
@Test
public void canPromoteFromForwardToCompatible() throws Exception {
final EventTypeTestBuilder builder = new EventTypeTestBuilder();
final EventType oldET = builder.compatibilityMode(CompatibilityMode.FORWARD).build();
final EventType newET = builder.compatibilityMode(CompatibilityMode.COMPATIBLE).build();
final CompatibilityModeChangeConstraint constraint = new CompatibilityModeChangeConstraint();
assertThat(constraint.validate(oldET, newET), isAbsent());
}
Aggregations