use of io.jans.scim.model.scim2.ErrorResponse in project kafka-rest by confluentinc.
the class ProduceActionIntegrationTest method produceBinaryBatchWithInvalidData_throwsMultipleBadRequests.
@Test
public void produceBinaryBatchWithInvalidData_throwsMultipleBadRequests() throws Exception {
String clusterId = testEnv.kafkaCluster().getClusterId();
ArrayList<ProduceRequest> requests = new ArrayList<>();
for (int i = 0; i < 1000; i++) {
requests.add(ProduceRequest.builder().setKey(ProduceRequestData.builder().setFormat(EmbeddedFormat.BINARY).setData(IntNode.valueOf(2 * i)).build()).setValue(ProduceRequestData.builder().setFormat(EmbeddedFormat.BINARY).setData(IntNode.valueOf(2 * i + 1)).build()).setOriginalSize(0L).build());
}
StringBuilder batch = new StringBuilder();
ObjectMapper objectMapper = testEnv.kafkaRest().getObjectMapper();
for (ProduceRequest produceRequest : requests) {
batch.append(objectMapper.writeValueAsString(produceRequest));
}
Response response = testEnv.kafkaRest().target().path("/v3/clusters/" + clusterId + "/topics/" + TOPIC_NAME + "/records").request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(batch.toString(), MediaType.APPLICATION_JSON));
assertEquals(Status.OK.getStatusCode(), response.getStatus());
List<ErrorResponse> actual = readErrorResponses(response);
for (int i = 0; i < 1000; i++) {
assertEquals(400, actual.get(i).getErrorCode());
}
}
use of io.jans.scim.model.scim2.ErrorResponse in project kafka-rest by confluentinc.
the class ProduceActionIntegrationTest method produceBinaryWithSchemaId_returnsBadRequest.
@Test
public void produceBinaryWithSchemaId_returnsBadRequest() throws Exception {
String clusterId = testEnv.kafkaCluster().getClusterId();
String request = "{ \"key\": { \"type\": \"BINARY\", \"schema_id\": 1 } }";
Response response = testEnv.kafkaRest().target().path("/v3/clusters/" + clusterId + "/topics/" + TOPIC_NAME + "/records").request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(request, MediaType.APPLICATION_JSON));
assertEquals(Status.OK.getStatusCode(), response.getStatus());
ErrorResponse actual = response.readEntity(ErrorResponse.class);
assertEquals(400, actual.getErrorCode());
}
use of io.jans.scim.model.scim2.ErrorResponse in project kafka-rest by confluentinc.
the class ProduceActionIntegrationTest method produceAvroWithRawSchemaAndSchemaVersion_returnsBadRequest.
@Test
public void produceAvroWithRawSchemaAndSchemaVersion_returnsBadRequest() throws Exception {
String clusterId = testEnv.kafkaCluster().getClusterId();
String request = "{ \"key\": { \"schema\": \"{ \\\"type\\\": \\\"string\\\" }\", \"schema_version\": 1 } }";
Response response = testEnv.kafkaRest().target().path("/v3/clusters/" + clusterId + "/topics/" + TOPIC_NAME + "/records").request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(request, MediaType.APPLICATION_JSON));
assertEquals(Status.OK.getStatusCode(), response.getStatus());
ErrorResponse actual = response.readEntity(ErrorResponse.class);
assertEquals(400, actual.getErrorCode());
}
use of io.jans.scim.model.scim2.ErrorResponse in project kafka-rest by confluentinc.
the class ProduceActionIntegrationTest method produceAvroWithTypeAndLatestSchema_returnsBadRequest.
@Test
public void produceAvroWithTypeAndLatestSchema_returnsBadRequest() throws Exception {
String clusterId = testEnv.kafkaCluster().getClusterId();
String request = "{ \"key\": { \"type\": \"AVRO\" } }";
Response response = testEnv.kafkaRest().target().path("/v3/clusters/" + clusterId + "/topics/" + TOPIC_NAME + "/records").request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(request, MediaType.APPLICATION_JSON));
assertEquals(Status.OK.getStatusCode(), response.getStatus());
ErrorResponse actual = response.readEntity(ErrorResponse.class);
assertEquals(400, actual.getErrorCode());
}
use of io.jans.scim.model.scim2.ErrorResponse in project kafka-rest by confluentinc.
the class ProduceActionIntegrationTest method produceBinaryWithSchemaSubjectStrategy_returnsBadRequest.
@Test
public void produceBinaryWithSchemaSubjectStrategy_returnsBadRequest() throws Exception {
String clusterId = testEnv.kafkaCluster().getClusterId();
String request = "{ \"key\": { \"type\": \"BINARY\", \"subject_name_strategy\": \"TOPIC\" } }";
Response response = testEnv.kafkaRest().target().path("/v3/clusters/" + clusterId + "/topics/" + TOPIC_NAME + "/records").request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(request, MediaType.APPLICATION_JSON));
assertEquals(Status.OK.getStatusCode(), response.getStatus());
ErrorResponse actual = response.readEntity(ErrorResponse.class);
assertEquals(400, actual.getErrorCode());
}
Aggregations