Search in sources :

Example 6 with ErrorResponse

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());
    }
}
Also used : Response(javax.ws.rs.core.Response) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) ProduceResponse(io.confluent.kafkarest.entities.v3.ProduceResponse) ProduceRequest(io.confluent.kafkarest.entities.v3.ProduceRequest) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) Test(org.junit.jupiter.api.Test)

Example 7 with ErrorResponse

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());
}
Also used : Response(javax.ws.rs.core.Response) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) ProduceResponse(io.confluent.kafkarest.entities.v3.ProduceResponse) ByteString(com.google.protobuf.ByteString) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) Test(org.junit.jupiter.api.Test)

Example 8 with ErrorResponse

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());
}
Also used : Response(javax.ws.rs.core.Response) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) ProduceResponse(io.confluent.kafkarest.entities.v3.ProduceResponse) ByteString(com.google.protobuf.ByteString) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) Test(org.junit.jupiter.api.Test)

Example 9 with ErrorResponse

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());
}
Also used : Response(javax.ws.rs.core.Response) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) ProduceResponse(io.confluent.kafkarest.entities.v3.ProduceResponse) ByteString(com.google.protobuf.ByteString) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) Test(org.junit.jupiter.api.Test)

Example 10 with ErrorResponse

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());
}
Also used : Response(javax.ws.rs.core.Response) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) ProduceResponse(io.confluent.kafkarest.entities.v3.ProduceResponse) ByteString(com.google.protobuf.ByteString) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) Test(org.junit.jupiter.api.Test)

Aggregations

ErrorResponse (io.confluent.kafkarest.exceptions.v3.ErrorResponse)23 Test (org.junit.jupiter.api.Test)23 ProduceResponse (io.confluent.kafkarest.entities.v3.ProduceResponse)21 Response (javax.ws.rs.core.Response)20 ByteString (com.google.protobuf.ByteString)19 ProduceRequest (io.confluent.kafkarest.entities.v3.ProduceRequest)8 RequestRateLimiter (io.confluent.kafkarest.ratelimit.RequestRateLimiter)3 ChunkedOutputFactory (io.confluent.kafkarest.response.ChunkedOutputFactory)3 FakeAsyncResponse (io.confluent.kafkarest.response.FakeAsyncResponse)3 ResultOrError (io.confluent.kafkarest.response.StreamingResponse.ResultOrError)3 Properties (java.util.Properties)3 RateLimitExceededException (io.confluent.kafkarest.ratelimit.RateLimitExceededException)2 ArrayList (java.util.ArrayList)2 ErrorResponse (org.gluu.oxtrust.model.scim2.ErrorResponse)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ProtobufSchema (io.confluent.kafka.schemaregistry.protobuf.ProtobufSchema)1 ErrorResponse (io.jans.scim.model.scim2.ErrorResponse)1