Search in sources :

Example 1 with CarrierBucketConfigResponse

use of com.couchbase.client.core.msg.kv.CarrierBucketConfigResponse in project couchbase-jvm-clients by couchbase.

the class KeyValueBucketLoaderTest method errorsIfNonSuccessful.

@Test
void errorsIfNonSuccessful() {
    CarrierBucketConfigResponse response = mock(CarrierBucketConfigResponse.class);
    when(response.status()).thenReturn(ResponseStatus.UNKNOWN);
    doAnswer(i -> {
        ((CarrierBucketConfigRequest) i.getArgument(0)).succeed(response);
        return null;
    }).when(core).send(any(CarrierBucketConfigRequest.class));
    assertThrows(ConfigException.class, () -> loader.discoverConfig(SEED, BUCKET).block());
}
Also used : CarrierBucketConfigResponse(com.couchbase.client.core.msg.kv.CarrierBucketConfigResponse) CarrierBucketConfigRequest(com.couchbase.client.core.msg.kv.CarrierBucketConfigRequest) Test(org.junit.jupiter.api.Test)

Example 2 with CarrierBucketConfigResponse

use of com.couchbase.client.core.msg.kv.CarrierBucketConfigResponse in project couchbase-jvm-clients by couchbase.

the class KeyValueBucketLoaderTest method loadsConfigSuccessfully.

@Test
void loadsConfigSuccessfully() {
    byte[] expectedConfig = "config".getBytes(UTF_8);
    CarrierBucketConfigResponse response = mock(CarrierBucketConfigResponse.class);
    when(response.status()).thenReturn(ResponseStatus.SUCCESS);
    when(response.content()).thenReturn(expectedConfig);
    doAnswer(i -> {
        ((CarrierBucketConfigRequest) i.getArgument(0)).succeed(response);
        return null;
    }).when(core).send(any(CarrierBucketConfigRequest.class));
    byte[] config = loader.discoverConfig(SEED, BUCKET).block();
    assertArrayEquals(expectedConfig, config);
}
Also used : CarrierBucketConfigResponse(com.couchbase.client.core.msg.kv.CarrierBucketConfigResponse) CarrierBucketConfigRequest(com.couchbase.client.core.msg.kv.CarrierBucketConfigRequest) Test(org.junit.jupiter.api.Test)

Example 3 with CarrierBucketConfigResponse

use of com.couchbase.client.core.msg.kv.CarrierBucketConfigResponse in project couchbase-jvm-clients by couchbase.

the class KeyValueBucketLoaderTest method errorsIfUnsupported.

@Test
void errorsIfUnsupported() {
    CarrierBucketConfigResponse response = mock(CarrierBucketConfigResponse.class);
    when(response.status()).thenReturn(ResponseStatus.UNSUPPORTED);
    doAnswer(i -> {
        ((CarrierBucketConfigRequest) i.getArgument(0)).succeed(response);
        return null;
    }).when(core).send(any(CarrierBucketConfigRequest.class));
    assertThrows(UnsupportedConfigMechanismException.class, () -> loader.discoverConfig(SEED, BUCKET).block());
}
Also used : CarrierBucketConfigResponse(com.couchbase.client.core.msg.kv.CarrierBucketConfigResponse) CarrierBucketConfigRequest(com.couchbase.client.core.msg.kv.CarrierBucketConfigRequest) Test(org.junit.jupiter.api.Test)

Aggregations

CarrierBucketConfigRequest (com.couchbase.client.core.msg.kv.CarrierBucketConfigRequest)3 CarrierBucketConfigResponse (com.couchbase.client.core.msg.kv.CarrierBucketConfigResponse)3 Test (org.junit.jupiter.api.Test)3