use of org.asynchttpclient.Response in project bullet-core by yahoo.
the class RESTQueryPublisherTest method testHandleBadResponse.
@Test
public void testHandleBadResponse() throws Exception {
CompletableFuture<Response> response = getOkFuture(getNotOkResponse(500));
BoundRequestBuilder mockBuilder = mockBuilderWith(response);
AsyncHttpClient mockClient = mockClientWith(mockBuilder);
RESTQueryPublisher publisher = new RESTQueryPublisher(mockClient, "my/custom/query/url", "my/custom/result/url");
publisher.send(new PubSubMessage("foo", "bar", Metadata.Signal.COMPLETE));
verify(mockClient).preparePost("my/custom/query/url");
verify(mockBuilder).setBody("{\"id\":\"foo\",\"sequence\":-1,\"content\":\"bar\",\"metadata\":{\"signal\":\"COMPLETE\",\"content\":\"my/custom/result/url\"}}");
verify(mockBuilder).setHeader(RESTPublisher.CONTENT_TYPE, RESTPublisher.APPLICATION_JSON);
}
use of org.asynchttpclient.Response in project bullet-core by yahoo.
the class RESTQueryPublisherTest method testSendResultUrlPutInMetadataAckPreserved.
@Test
public void testSendResultUrlPutInMetadataAckPreserved() throws Exception {
CompletableFuture<Response> response = getOkFuture(getOkResponse(null));
BoundRequestBuilder mockBuilder = mockBuilderWith(response);
AsyncHttpClient mockClient = mockClientWith(mockBuilder);
RESTQueryPublisher publisher = new RESTQueryPublisher(mockClient, "my/custom/query/url", "my/custom/url");
publisher.send(new PubSubMessage("foo", "bar", Metadata.Signal.ACKNOWLEDGE));
verify(mockClient).preparePost("my/custom/query/url");
verify(mockBuilder).setBody("{\"id\":\"foo\",\"sequence\":-1,\"content\":\"bar\",\"metadata\":{\"signal\":\"ACKNOWLEDGE\",\"content\":\"my/custom/url\"}}");
verify(mockBuilder).setHeader(RESTPublisher.CONTENT_TYPE, RESTPublisher.APPLICATION_JSON);
}
use of org.asynchttpclient.Response in project bullet-core by yahoo.
the class RESTQueryPublisherTest method testSendResultUrlPutInMetadataCompletePreserved.
@Test
public void testSendResultUrlPutInMetadataCompletePreserved() throws Exception {
CompletableFuture<Response> response = getOkFuture(getOkResponse(null));
BoundRequestBuilder mockBuilder = mockBuilderWith(response);
AsyncHttpClient mockClient = mockClientWith(mockBuilder);
RESTPubSubConfig config = new RESTPubSubConfig("src/test/resources/test_config.yaml");
config.set(RESTPubSubConfig.RESULT_URL, "my/custom/url");
RESTQueryPublisher publisher = new RESTQueryPublisher(mockClient, "my/custom/query/url", "my/custom/result/url");
publisher.send(new PubSubMessage("foo", "bar", Metadata.Signal.COMPLETE));
verify(mockClient).preparePost("my/custom/query/url");
verify(mockBuilder).setBody("{\"id\":\"foo\",\"sequence\":-1,\"content\":\"bar\",\"metadata\":{\"signal\":\"COMPLETE\",\"content\":\"my/custom/result/url\"}}");
verify(mockBuilder).setHeader(RESTPublisher.CONTENT_TYPE, RESTPublisher.APPLICATION_JSON);
}
use of org.asynchttpclient.Response in project bullet-core by yahoo.
the class RESTResultPublisherTest method testSendBadURL.
@Test(expectedExceptions = ClassCastException.class)
public void testSendBadURL() throws Exception {
CompletableFuture<Response> response = getOkFuture(getOkResponse(null));
BoundRequestBuilder mockBuilder = mockBuilderWith(response);
AsyncHttpClient mockClient = mockClientWith(mockBuilder);
RESTResultPublisher publisher = new RESTResultPublisher(mockClient);
PubSubMessage message = new PubSubMessage("someId", "someContent", new Metadata(null, 88));
publisher.send(message);
}
use of org.asynchttpclient.Response in project bullet-core by yahoo.
the class RESTSubscriberTest method testGetMessages500.
@Test
public void testGetMessages500() throws Exception {
CompletableFuture<Response> response = getOkFuture(getNotOkResponse(500));
BoundRequestBuilder mockBuilder = mockBuilderWith(response);
AsyncHttpClient mockClient = mockClientWith(mockBuilder);
RESTPubSubConfig config = new RESTPubSubConfig("src/test/resources/test_config.yaml");
RESTSubscriber subscriber = new RESTSubscriber(88, Arrays.asList("url", "anotherURL"), mockClient, 10);
List<PubSubMessage> messages = subscriber.getMessages();
Assert.assertEquals(messages.size(), 0);
}
Aggregations