Search in sources :

Example 1 with BadRequestException

use of com.azure.cosmos.implementation.BadRequestException in project kafka-connect-cosmosdb by microsoft.

the class CosmosDBSinkTaskTestNotFails method testPutMapThatFailsDoesNotStopTask.

@Test
public void testPutMapThatFailsDoesNotStopTask() throws JsonProcessingException, IllegalAccessException {
    Schema stringSchema = new ConnectSchema(Schema.Type.STRING);
    Schema mapSchema = new ConnectSchema(Schema.Type.MAP);
    when(mockContainer.upsertItem(any())).thenThrow(new BadRequestException("Something"));
    SinkRecord record = new SinkRecord(topicName, 1, stringSchema, "nokey", mapSchema, "{", 0L);
    testTask.put(List.of(record));
}
Also used : Schema(org.apache.kafka.connect.data.Schema) ConnectSchema(org.apache.kafka.connect.data.ConnectSchema) BadRequestException(com.azure.cosmos.implementation.BadRequestException) ConnectSchema(org.apache.kafka.connect.data.ConnectSchema) SinkRecord(org.apache.kafka.connect.sink.SinkRecord) Test(org.junit.Test)

Example 2 with BadRequestException

use of com.azure.cosmos.implementation.BadRequestException in project DataSpaceConnector by eclipse-dataspaceconnector.

the class LeaseContextTest method breakLease_throwsException.

@Test
void breakLease_throwsException() {
    when(cosmosDbApiMock.invokeStoredProcedure(eq("lease"), eq(TEST_PARTITION_KEY), any())).thenThrow(new BadRequestException("foo"));
    assertThatThrownBy(() -> context.breakLease("test-doc-id")).isInstanceOf(BadRequestException.class);
    verify(cosmosDbApiMock, times(1)).invokeStoredProcedure("lease", TEST_PARTITION_KEY, "test-doc-id", "me", false);
}
Also used : BadRequestException(com.azure.cosmos.implementation.BadRequestException) Test(org.junit.jupiter.api.Test)

Example 3 with BadRequestException

use of com.azure.cosmos.implementation.BadRequestException in project DataSpaceConnector by eclipse-dataspaceconnector.

the class LeaseContextTest method acquireLease_throwsException.

@Test
void acquireLease_throwsException() {
    when(cosmosDbApiMock.invokeStoredProcedure(eq("lease"), eq(TEST_PARTITION_KEY), any())).thenThrow(new BadRequestException("foo"));
    assertThatThrownBy(() -> context.acquireLease("test-doc-id")).isInstanceOf(BadRequestException.class);
    verify(cosmosDbApiMock, times(1)).invokeStoredProcedure("lease", TEST_PARTITION_KEY, "test-doc-id", "me", true);
}
Also used : BadRequestException(com.azure.cosmos.implementation.BadRequestException) Test(org.junit.jupiter.api.Test)

Example 4 with BadRequestException

use of com.azure.cosmos.implementation.BadRequestException in project DataSpaceConnector by eclipse-dataspaceconnector.

the class CosmosLeaseContextTest method acquireLease_throwsException.

@Test
void acquireLease_throwsException() {
    when(cosmosDbApiMock.invokeStoredProcedure(eq("lease"), eq(TEST_PARTITION_KEY), any())).thenThrow(new BadRequestException("foo"));
    assertThatThrownBy(() -> context.acquireLease("test-doc-id")).isInstanceOf(BadRequestException.class);
    verify(cosmosDbApiMock, times(1)).invokeStoredProcedure("lease", TEST_PARTITION_KEY, "test-doc-id", "me", true);
}
Also used : BadRequestException(com.azure.cosmos.implementation.BadRequestException) Test(org.junit.jupiter.api.Test)

Example 5 with BadRequestException

use of com.azure.cosmos.implementation.BadRequestException in project DataSpaceConnector by eclipse-dataspaceconnector.

the class CosmosLeaseContextTest method breakLease_throwsException.

@Test
void breakLease_throwsException() {
    when(cosmosDbApiMock.invokeStoredProcedure(eq("lease"), eq(TEST_PARTITION_KEY), any())).thenThrow(new BadRequestException("foo"));
    assertThatThrownBy(() -> context.breakLease("test-doc-id")).isInstanceOf(BadRequestException.class);
    verify(cosmosDbApiMock, times(1)).invokeStoredProcedure("lease", TEST_PARTITION_KEY, "test-doc-id", "me", false);
}
Also used : BadRequestException(com.azure.cosmos.implementation.BadRequestException) Test(org.junit.jupiter.api.Test)

Aggregations

BadRequestException (com.azure.cosmos.implementation.BadRequestException)10 Test (org.junit.jupiter.api.Test)4 ConnectSchema (org.apache.kafka.connect.data.ConnectSchema)3 Schema (org.apache.kafka.connect.data.Schema)3 SinkRecord (org.apache.kafka.connect.sink.SinkRecord)3 EdcException (org.eclipse.dataspaceconnector.spi.EdcException)3 Test (org.junit.Test)3 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ConnectException (org.apache.kafka.connect.errors.ConnectException)1 ContractNegotiationDocument (org.eclipse.dataspaceconnector.contract.negotiation.store.model.ContractNegotiationDocument)1 TransferProcessDocument (org.eclipse.dataspaceconnector.transfer.store.cosmos.model.TransferProcessDocument)1