Skip to content

Commit

Permalink
Fixing acceptance test and the message
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Abraham committed Jul 28, 2021
1 parent b92ff7a commit 0a462e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ public void whenUpdateCleanupPolicyDeleteToDeleteCompactJourney() throws Excepti

// publish an event to the event type (without partition compaction key)
given().body("[{\"metadata\":{" +
"\"occurred_at\":\"1992-08-03T10:00:00Z\"," +
"\"eid\":\"329ed3d2-8366-11e8-adc0-fa7ae01bbebc\"}}]")
"\"occurred_at\":\"1992-08-03T10:00:00Z\"," +
"\"eid\":\"329ed3d2-8366-11e8-adc0-fa7ae01bbebc\"}}]")
.contentType(JSON)
.post(ENDPOINT + "/" + eventType.getName() + "/events")
.then()
Expand Down Expand Up @@ -374,8 +374,8 @@ public void whenUpdateCleanupPolicyDeleteToDeleteCompactJourney() throws Excepti

// publish event with missing compaction key and expect 422
given().body("[{\"metadata\":{" +
"\"occurred_at\":\"1992-08-03T10:00:00Z\"," +
"\"eid\":\"329ed3d2-8366-11e8-adc0-fa7ae01bbebc\"}}]")
"\"occurred_at\":\"1992-08-03T10:00:00Z\"," +
"\"eid\":\"329ed3d2-8366-11e8-adc0-fa7ae01bbebc\"}}]")
.contentType(JSON)
.post(ENDPOINT + "/" + eventType.getName() + "/events")
.then()
Expand Down Expand Up @@ -428,8 +428,8 @@ public void compactedEventTypeJourney() throws IOException, ExecutionException,

// publish event with missing compaction key and expect 422
given().body("[{\"metadata\":{" +
"\"occurred_at\":\"1992-08-03T10:00:00Z\"," +
"\"eid\":\"329ed3d2-8366-11e8-adc0-fa7ae01bbebc\"}}]")
"\"occurred_at\":\"1992-08-03T10:00:00Z\"," +
"\"eid\":\"329ed3d2-8366-11e8-adc0-fa7ae01bbebc\"}}]")
.contentType(JSON)
.post(ENDPOINT + "/" + eventType.getName() + "/events")
.then()
Expand Down Expand Up @@ -605,8 +605,9 @@ public void whenPOSTEventTypeWithInvalidAnnotationOrLabelThenError() throws Json
given().body(MAPPER.writer().writeValueAsString(eventType))
.header("accept", "application/json")
.contentType(JSON).when().post(ENDPOINT).then()
.body(containsString("Field \"annotations[]\" Key name should start with letter or digit " +
"and end with letter\nField \"annotations[]\" Key cannot be empty"))
.body(containsString("Field \\\"annotations[]\\\" Key cannot be empty"))
.body(containsString("Field \\\"annotations[]\\\" Key name should start and end " +
"with a letter or a digit"))
.statusCode(HttpStatus.SC_UNPROCESSABLE_ENTITY);

final Map<String, String> labels = new HashMap<>();
Expand All @@ -617,8 +618,9 @@ public void whenPOSTEventTypeWithInvalidAnnotationOrLabelThenError() throws Json
given().body(MAPPER.writer().writeValueAsString(eventType))
.header("accept", "application/json")
.contentType(JSON).when().post(ENDPOINT).then()
.body(containsString("Field \"labels[]\" Key name should start with letter or digit " +
"and end with letter\nField \"labels[]\" Key cannot be empty"))
.body(containsString("Field \\\"labels[]\\\" Key cannot be empty"))
.body(containsString("Field \\\"labels[]\\\" Key name should start and end " +
"with a letter or a digit"))
.statusCode(HttpStatus.SC_UNPROCESSABLE_ENTITY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@Pattern(regexp = "^([-.a-z0-9]+/)?[^/]{0,63}$",
message = "Key name cannot be more than 63 characters.")
@Pattern(regexp = "^([^/]+/)?[a-zA-Z0-9]([a-zA-Z0-9_.-]*[a-zA-Z0-9])?$",
message = "Key name should start with letter or digit and end with letter")
message = "Key name should start and end with a letter or a digit")
@Constraint(validatedBy = {})
public @interface AnnotationKey {
String message() default "{org.zalando.nakadi.annotations.validation.AnnotationKey.message}}";
Expand Down

0 comments on commit 0a462e9

Please sign in to comment.