From 02a9e4499fa9bfa9e39797b07e81ac77ee423980 Mon Sep 17 00:00:00 2001 From: Aleksey Pak <1u0@users.noreply.github.com> Date: Fri, 2 Feb 2024 18:08:37 +0100 Subject: [PATCH] Minor: rename constant according to annotation name. --- .../validation/EventTypeAnnotationsValidator.java | 10 +++++----- .../EventTypeAnnotationsValidatorTest.java | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/api-metastore/src/main/java/org/zalando/nakadi/service/validation/EventTypeAnnotationsValidator.java b/api-metastore/src/main/java/org/zalando/nakadi/service/validation/EventTypeAnnotationsValidator.java index 673344e1f..60eb4efb0 100644 --- a/api-metastore/src/main/java/org/zalando/nakadi/service/validation/EventTypeAnnotationsValidator.java +++ b/api-metastore/src/main/java/org/zalando/nakadi/service/validation/EventTypeAnnotationsValidator.java @@ -24,7 +24,7 @@ public class EventTypeAnnotationsValidator { "(([1-9]|[1-9]\\d|[1][01]\\d|120)((\\smonths?)|(m)))|(([1-9]|(10))((\\syears?)|(y))))$"); static final String RETENTION_PERIOD_ANNOTATION = "datalake.zalando.org/retention-period"; static final String RETENTION_REASON_ANNOTATION = "datalake.zalando.org/retention-period-reason"; - static final String MATERIALISE_EVENTS_ANNOTATION = "datalake.zalando.org/materialize-events"; + static final String MATERIALIZE_EVENTS_ANNOTATION = "datalake.zalando.org/materialize-events"; private final FeatureToggleService featureToggleService; private final AuthorizationService authorizationService; @@ -46,13 +46,13 @@ public void validateAnnotations(final Map annotations) throws In } private void validateDataLakeAnnotations(@NotNull final Map annotations) { - final var materializeEvents = annotations.get(MATERIALISE_EVENTS_ANNOTATION); + final var materializeEvents = annotations.get(MATERIALIZE_EVENTS_ANNOTATION); final var retentionPeriod = annotations.get(RETENTION_PERIOD_ANNOTATION); if (materializeEvents != null) { if (!materializeEvents.equals("off") && !materializeEvents.equals("on")) { throw new InvalidEventTypeException( - "Annotation " + MATERIALISE_EVENTS_ANNOTATION + "Annotation " + MATERIALIZE_EVENTS_ANNOTATION + " is not valid. Provided value: \"" + materializeEvents + "\". Possible values are: \"on\" or \"off\"."); @@ -60,7 +60,7 @@ private void validateDataLakeAnnotations(@NotNull final Map anno if (materializeEvents.equals("on")) { if (retentionPeriod == null) { throw new InvalidEventTypeException("Annotation " + RETENTION_PERIOD_ANNOTATION - + " is required, when " + MATERIALISE_EVENTS_ANNOTATION + " is \"on\"."); + + " is required, when " + MATERIALIZE_EVENTS_ANNOTATION + " is \"on\"."); } } } @@ -84,7 +84,7 @@ private void validateDataLakeAnnotations(@NotNull final Map anno if (areDataLakeAnnotationsMandatory()) { if (materializeEvents == null) { - throw new InvalidEventTypeException("Annotation " + MATERIALISE_EVENTS_ANNOTATION + " is required"); + throw new InvalidEventTypeException("Annotation " + MATERIALIZE_EVENTS_ANNOTATION + " is required"); } } } diff --git a/api-metastore/src/test/java/org/zalando/nakadi/service/validation/EventTypeAnnotationsValidatorTest.java b/api-metastore/src/test/java/org/zalando/nakadi/service/validation/EventTypeAnnotationsValidatorTest.java index b875755e0..ba251728d 100644 --- a/api-metastore/src/test/java/org/zalando/nakadi/service/validation/EventTypeAnnotationsValidatorTest.java +++ b/api-metastore/src/test/java/org/zalando/nakadi/service/validation/EventTypeAnnotationsValidatorTest.java @@ -34,7 +34,7 @@ public void setUp() { @Test public void whenMaterializationEventFormatIsWrongThenFail() { final var annotations = Map.of( - EventTypeAnnotationsValidator.MATERIALISE_EVENTS_ANNOTATION, "1 day" + EventTypeAnnotationsValidator.MATERIALIZE_EVENTS_ANNOTATION, "1 day" ); try { validator.validateAnnotations(annotations); @@ -43,7 +43,7 @@ public void whenMaterializationEventFormatIsWrongThenFail() { Assert.assertTrue( "When the format of the Materialize Event annotation is wrong, the name of the annotation " + "should be present", - e.getMessage().contains(EventTypeAnnotationsValidator.MATERIALISE_EVENTS_ANNOTATION)); + e.getMessage().contains(EventTypeAnnotationsValidator.MATERIALIZE_EVENTS_ANNOTATION)); } } @@ -114,11 +114,11 @@ public void whenRetentionPeriodAndReasonThenOk() { @Test public void whenMaterializationEventsThenOk() { - final String[] validMaterialisationEventsValues = {"off", "on"}; + final String[] validMaterializationEventsValues = {"off", "on"}; - for (final var materialisationEventValue : validMaterialisationEventsValues) { + for (final var materializationEventValue : validMaterializationEventsValues) { final var annotations = Map.of( - EventTypeAnnotationsValidator.MATERIALISE_EVENTS_ANNOTATION, materialisationEventValue + EventTypeAnnotationsValidator.MATERIALIZE_EVENTS_ANNOTATION, materializationEventValue, EventTypeAnnotationsValidator.RETENTION_PERIOD_ANNOTATION, "1m", EventTypeAnnotationsValidator.RETENTION_REASON_ANNOTATION, "for testing" ); @@ -137,7 +137,7 @@ public void whenDataLakeAnnotationsEnforcedThenMaterializationIsRequired() { Assert.fail("not reachable"); } catch (InvalidEventTypeException e) { Assert.assertTrue( - e.getMessage().contains(EventTypeAnnotationsValidator.MATERIALISE_EVENTS_ANNOTATION)); + e.getMessage().contains(EventTypeAnnotationsValidator.MATERIALIZE_EVENTS_ANNOTATION)); } } @@ -145,7 +145,7 @@ public void whenDataLakeAnnotationsEnforcedThenMaterializationIsRequired() { public void whenMaterializationIsOnThenRetentionPeriodIsRequired() { try { validator.validateAnnotations(Collections.singletonMap( - EventTypeAnnotationsValidator.MATERIALISE_EVENTS_ANNOTATION, "on")); + EventTypeAnnotationsValidator.MATERIALIZE_EVENTS_ANNOTATION, "on")); Assert.fail("not reachable"); } catch (InvalidEventTypeException e) { Assert.assertTrue(