From 0da4b293ff13ebb29eddbee5ec8ad2d7f9b8916e Mon Sep 17 00:00:00 2001 From: Vyacheslav Stepanov Date: Wed, 14 Jun 2017 17:27:45 +0200 Subject: [PATCH] ARUHA-838: Added min length for owning_application. --- api/nakadi-event-bus-api.yaml | 1 + .../java/org/zalando/nakadi/domain/SubscriptionBase.java | 1 + .../controller/PostSubscriptionControllerTest.java | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/api/nakadi-event-bus-api.yaml b/api/nakadi-event-bus-api.yaml index 40bc60d62d..3284d43c4f 100644 --- a/api/nakadi-event-bus-api.yaml +++ b/api/nakadi-event-bus-api.yaml @@ -2044,6 +2044,7 @@ definitions: example: 'gizig' description: | The id of application owning the subscription. + minLength: 1 event_types: type: array items: diff --git a/src/main/java/org/zalando/nakadi/domain/SubscriptionBase.java b/src/main/java/org/zalando/nakadi/domain/SubscriptionBase.java index 97dcb6e5a3..a851c81d68 100644 --- a/src/main/java/org/zalando/nakadi/domain/SubscriptionBase.java +++ b/src/main/java/org/zalando/nakadi/domain/SubscriptionBase.java @@ -22,6 +22,7 @@ public enum InitialPosition { } @NotNull + @Size(min = 1, message = "must contain at least one character") private String owningApplication; @NotNull diff --git a/src/test/java/org/zalando/nakadi/controller/PostSubscriptionControllerTest.java b/src/test/java/org/zalando/nakadi/controller/PostSubscriptionControllerTest.java index eb3f4f7c26..bcae170326 100644 --- a/src/test/java/org/zalando/nakadi/controller/PostSubscriptionControllerTest.java +++ b/src/test/java/org/zalando/nakadi/controller/PostSubscriptionControllerTest.java @@ -145,6 +145,15 @@ public void whenCreateSubscriptionWithEmptyConsumerGroupThenUnprocessableEntity( checkForProblem(postSubscription(subscriptionBase), expectedProblem); } + @Test + public void whenCreateSubscriptionWithEmptyOwningApplicationThenUnprocessableEntity() throws Exception { + final SubscriptionBase subscriptionBase = builder() + .withOwningApplication("") + .buildSubscriptionBase(); + final Problem expectedProblem = invalidProblem("owning_application", "must contain at least one character"); + checkForProblem(postSubscription(subscriptionBase), expectedProblem); + } + @Test public void whenOwningApplicationIsNullThenUnprocessableEntity() throws Exception { final SubscriptionBase subscriptionBase = builder()