Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #680 from zalando/ARUHA-838-empty-consumer-group-v…
Browse files Browse the repository at this point in the history
…alidation

ARUHA-838: Added validation of empty consumer group
  • Loading branch information
rcillo authored Jun 20, 2017
2 parents ade1d15 + 0da4b29 commit 9a2249a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
11 changes: 7 additions & 4 deletions api/nakadi-event-bus-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ paths:
description: |
Offset to query for unconsumed events. Depends on `partition` parameter. When present adds the property
`unconsumed_events` to the response partition object.
type: string
responses:
'200':
description: OK
Expand Down Expand Up @@ -817,7 +818,7 @@ paths:
- if the `shift` provided leads to a cursor that is not yet existent, i.e. it's pointing to
some cursor yet to be generated in the future.
schema:
- $ref: '#/definitions/Problem'
$ref: '#/definitions/Problem'

/subscriptions:
post:
Expand Down Expand Up @@ -1889,13 +1890,13 @@ definitions:
- final_cursor
properties:
initial_cursor:
- $ref: "/definitions/Cursor"
$ref: "#/definitions/Cursor"
final_cursor:
- $ref: "/definitions/Cursor"
$ref: "#/definitions/Cursor"

CursorDistanceResult:
allOf:
- $ref: '/definitions/CursorDistanceQuery'
- $ref: '#/definitions/CursorDistanceQuery'
required:
- distance
properties:
Expand Down Expand Up @@ -2043,6 +2044,7 @@ definitions:
example: 'gizig'
description: |
The id of application owning the subscription.
minLength: 1
event_types:
type: array
items:
Expand All @@ -2059,6 +2061,7 @@ definitions:
The value describing the use case of this subscription.
In general that is an additional identifier used to differ subscriptions having the same
owning_application and event_types.
minLength: 1
default: 'default'
created_at:
type: string
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/zalando/nakadi/domain/SubscriptionBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ public enum InitialPosition {
}

@NotNull
@Size(min = 1, message = "must contain at least one character")
private String owningApplication;

@NotNull
@Size(min = 1, message = "must contain at least one element")
private Set<String> eventTypes;

@NotNull
@Size(min = 1, message = "must contain at least one character")
private String consumerGroup = "default";

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,24 @@ public void whenCreateSubscriptionWithUnknownApplicationThenUnprocessableEntity(
.andExpect(content().contentTypeCompatibleWith("application/problem+json"));
}

@Test
public void whenCreateSubscriptionWithEmptyConsumerGroupThenUnprocessableEntity() throws Exception {
final SubscriptionBase subscriptionBase = builder()
.withConsumerGroup("")
.buildSubscriptionBase();
final Problem expectedProblem = invalidProblem("consumer_group", "must contain at least one character");
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()
Expand Down

0 comments on commit 9a2249a

Please sign in to comment.