Skip to content

Commit

Permalink
chore: add test for extra keys in request body
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilT-d11 committed Mar 28, 2024
1 parent ee2fa51 commit 50001f6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/test/java/com/dream11/rest/RestApiIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ void positiveBodyTest() {
assertThat(response.statusCode()).isEqualTo(200);
}

@Test
void extraFieldsTest() {
// arrange
String path = String.format("%s", Constants.VALIDATION_ROUTE_PATH);
JsonObject body = new JsonObject().put("resourceId", "1").put("extraKey", "extraValue");
// act
HttpResponse<Buffer> response = this.makePostRequest(path, body)
.blockingGet();
// assert
assertThat(response.statusCode()).isEqualTo(200);
}

@Test
void routeNotFoundTest() {
// arrange
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/com/dream11/rest/verticle/RestVerticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import com.dream11.rest.Constants;
import com.dream11.rest.injector.GuiceInjector;
import com.dream11.rest.util.SharedDataUtil;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.core.json.jackson.DatabindCodec;

public class RestVerticle extends AbstractRestVerticle {

Expand All @@ -18,4 +21,9 @@ public RestVerticle() {
protected ClassInjector getInjector() {
return SharedDataUtil.getInstance(this.vertx.getDelegate(), GuiceInjector.class);
}

@Override
protected ObjectMapper getMapper() {
return DatabindCodec.mapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
}
}

0 comments on commit 50001f6

Please sign in to comment.