Search in sources :

Example 6 with EventTypeTestBuilder

use of org.zalando.nakadi.utils.EventTypeTestBuilder in project nakadi by zalando.

the class CompatibilityModeChangeConstraintTest method passWhenNoChanges.

@Test
public void passWhenNoChanges() throws Exception {
    final EventTypeTestBuilder builder = new EventTypeTestBuilder();
    final EventType oldET = builder.compatibilityMode(CompatibilityMode.NONE).build();
    final EventType newET = builder.compatibilityMode(CompatibilityMode.NONE).build();
    final CompatibilityModeChangeConstraint constraint = new CompatibilityModeChangeConstraint();
    assertThat(constraint.validate(oldET, newET), isAbsent());
}
Also used : EventType(org.zalando.nakadi.domain.EventType) EventTypeTestBuilder(org.zalando.nakadi.utils.EventTypeTestBuilder) Test(org.junit.Test)

Example 7 with EventTypeTestBuilder

use of org.zalando.nakadi.utils.EventTypeTestBuilder in project nakadi by zalando.

the class CompatibilityModeChangeConstraintTest method canPromoteFromNoneToForward.

@Test
public void canPromoteFromNoneToForward() throws Exception {
    final EventTypeTestBuilder builder = new EventTypeTestBuilder();
    final EventType oldET = builder.compatibilityMode(CompatibilityMode.NONE).build();
    final EventType newET = builder.compatibilityMode(CompatibilityMode.FORWARD).build();
    final CompatibilityModeChangeConstraint constraint = new CompatibilityModeChangeConstraint();
    assertThat(constraint.validate(oldET, newET), isAbsent());
}
Also used : EventType(org.zalando.nakadi.domain.EventType) EventTypeTestBuilder(org.zalando.nakadi.utils.EventTypeTestBuilder) Test(org.junit.Test)

Example 8 with EventTypeTestBuilder

use of org.zalando.nakadi.utils.EventTypeTestBuilder in project nakadi by zalando.

the class SchemaEvolutionServiceTest method checkEvolutionConstraints.

@Test(expected = InvalidEventTypeException.class)
public void checkEvolutionConstraints() throws Exception {
    final EventTypeTestBuilder builder = EventTypeTestBuilder.builder();
    final EventType oldEventType = builder.build();
    final EventType newEventType = builder.build();
    final Optional<SchemaEvolutionIncompatibility> incompatibility = Optional.of(new SchemaEvolutionIncompatibility("incompatible"));
    Mockito.doReturn(incompatibility).when(evolutionConstraint).validate(oldEventType, newEventType);
    service.evolve(oldEventType, newEventType);
}
Also used : EventType(org.zalando.nakadi.domain.EventType) EventTypeTestBuilder(org.zalando.nakadi.utils.EventTypeTestBuilder) SchemaEvolutionIncompatibility(org.zalando.nakadi.validation.schema.SchemaEvolutionIncompatibility) Test(org.junit.Test)

Example 9 with EventTypeTestBuilder

use of org.zalando.nakadi.utils.EventTypeTestBuilder in project nakadi by zalando.

the class SchemaEvolutionServiceTest method whenNoSemanticalChangesButTextualChangedBumpPatch.

@Test
public void whenNoSemanticalChangesButTextualChangedBumpPatch() throws Exception {
    final EventTypeTestBuilder builder = EventTypeTestBuilder.builder();
    final EventType oldEventType = builder.schema("{\"default\":\"this\"}").build();
    final EventType newEventType = builder.schema("{\"default\":\"that\"}").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.1"))));
    verify(evolutionConstraint).validate(oldEventType, newEventType);
}
Also used : EventType(org.zalando.nakadi.domain.EventType) Version(org.zalando.nakadi.domain.Version) EventTypeTestBuilder(org.zalando.nakadi.utils.EventTypeTestBuilder) Test(org.junit.Test)

Example 10 with EventTypeTestBuilder

use of org.zalando.nakadi.utils.EventTypeTestBuilder in project nakadi by zalando.

the class SchemaEvolutionServiceTest method whenCompatibleModeDoNotAllowMajorChanges.

@Test(expected = InvalidEventTypeException.class)
public void whenCompatibleModeDoNotAllowMajorChanges() 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(MAJOR).when(compatibleChanges).get(any());
    Mockito.doReturn(Lists.newArrayList(new SchemaChange(TITLE_CHANGED, "#/"))).when(schemaDiff).collectChanges(any(), any());
    service.evolve(oldEventType, newEventType);
}
Also used : EventType(org.zalando.nakadi.domain.EventType) SchemaChange(org.zalando.nakadi.domain.SchemaChange) EventTypeTestBuilder(org.zalando.nakadi.utils.EventTypeTestBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 EventType (org.zalando.nakadi.domain.EventType)14 EventTypeTestBuilder (org.zalando.nakadi.utils.EventTypeTestBuilder)14 Version (org.zalando.nakadi.domain.Version)6 SchemaChange (org.zalando.nakadi.domain.SchemaChange)5 InvalidEventTypeException (org.zalando.nakadi.exceptions.InvalidEventTypeException)1 TestUtils.buildDefaultEventType (org.zalando.nakadi.utils.TestUtils.buildDefaultEventType)1 SchemaEvolutionIncompatibility (org.zalando.nakadi.validation.schema.SchemaEvolutionIncompatibility)1