diff options
Diffstat (limited to 'vespa-feed-client/src/test/java')
3 files changed, 22 insertions, 22 deletions
diff --git a/vespa-feed-client/src/test/java/ai/vespa/feed/client/HttpFeedClientTest.java b/vespa-feed-client/src/test/java/ai/vespa/feed/client/HttpFeedClientTest.java index d8090549420..6aa0de2160c 100644 --- a/vespa-feed-client/src/test/java/ai/vespa/feed/client/HttpFeedClientTest.java +++ b/vespa-feed-client/src/test/java/ai/vespa/feed/client/HttpFeedClientTest.java @@ -13,6 +13,7 @@ import java.util.function.BiFunction; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author jonmv @@ -55,16 +56,19 @@ class HttpFeedClientTest { return failed; } }); - Result result = client.put(id, - "json", - OperationParameters.empty() - .createIfNonExistent(true) - .testAndSetCondition("false") - .route("route") - .timeout(Duration.ofSeconds(5))) - .get(); - assertEquals("Ooops! ... I did it again.", result.resultMessage().get()); - assertEquals("I played with your heart. Got lost in the game.", result.traceMessage().get()); + ExecutionException expected = assertThrows(ExecutionException.class, + () -> client.put(id, + "json", + OperationParameters.empty() + .createIfNonExistent(true) + .testAndSetCondition("false") + .route("route") + .timeout(Duration.ofSeconds(5))) + .get()); + assertTrue(expected.getCause() instanceof ResultException); + ResultException result = (ResultException) expected.getCause(); + assertEquals("Ooops! ... I did it again.", result.getMessage()); + assertEquals("I played with your heart. Got lost in the game.", result.getTrace().get()); // Handler error is a FeedException. @@ -90,11 +94,11 @@ class HttpFeedClientTest { return failed; } }); - ExecutionException expected = assertThrows(ExecutionException.class, - () -> client.put(id, - "json", - OperationParameters.empty()) - .get()); + expected = assertThrows(ExecutionException.class, + () -> client.put(id, + "json", + OperationParameters.empty()) + .get()); assertEquals("Status 500 executing 'POST /document/v1/ns/type/docid/0': Alla ska i jorden.", expected.getCause().getMessage()); } diff --git a/vespa-feed-client/src/test/java/ai/vespa/feed/client/examples/JsonFileFeederExample.java b/vespa-feed-client/src/test/java/ai/vespa/feed/client/examples/JsonFileFeederExample.java index 1e616f2625a..3b633c38132 100644 --- a/vespa-feed-client/src/test/java/ai/vespa/feed/client/examples/JsonFileFeederExample.java +++ b/vespa-feed-client/src/test/java/ai/vespa/feed/client/examples/JsonFileFeederExample.java @@ -38,17 +38,15 @@ class JsonFileFeederExample implements Closeable { resultsReceived.incrementAndGet(); if (error != null) { log.warning("Problems with feeding document " - + error.documentId().map(DocumentId::toString).orElse("<unknown>")); - errorsReceived.incrementAndGet(); - } else if (result.type() == Result.Type.failure) { - log.warning("Problems with docID " + result.documentId() + ":" + error); + + error.documentId().map(DocumentId::toString).orElse("<unknown>") + + ": " + error); errorsReceived.incrementAndGet(); } } @Override public void onError(FeedException error) { - log.severe("Feeding failed for d: " + error.getMessage()); + log.severe("Feeding failed fatally: " + error.getMessage()); } @Override diff --git a/vespa-feed-client/src/test/java/ai/vespa/feed/client/examples/JsonStreamFeederExample.java b/vespa-feed-client/src/test/java/ai/vespa/feed/client/examples/JsonStreamFeederExample.java index 5cee776b244..cbe0e213907 100644 --- a/vespa-feed-client/src/test/java/ai/vespa/feed/client/examples/JsonStreamFeederExample.java +++ b/vespa-feed-client/src/test/java/ai/vespa/feed/client/examples/JsonStreamFeederExample.java @@ -100,8 +100,6 @@ class JsonStreamFeederExample extends Thread implements AutoCloseable { if (throwable != null) { System.err.printf("Failure for '%s': %s", docId, throwable); throwable.printStackTrace(); - } else if (result.type() == Result.Type.failure) { - System.err.printf("Failure for '%s': %s", docId, result.resultMessage().orElse("<no messsage>")); } }); } catch (InterruptedException e) { |