diff --git a/CHANGELOG.md b/CHANGELOG.md index 228936b66ef..f8bc85b6c5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## 6.3.0 [unreleased] +### Features +1. [#367](https://github.com/influxdata/influxdb-client-java/pull/367): Add HTTP status code to detail message of `InfluxException` +1. [#367](https://github.com/influxdata/influxdb-client-java/pull/367): Add `GatewayTimeoutException` for HTTP status code 504 + ## 6.2.0 [2022-06-24] ### Features diff --git a/client-core/src/main/java/com/influxdb/exceptions/GatewayTimeoutException.java b/client-core/src/main/java/com/influxdb/exceptions/GatewayTimeoutException.java new file mode 100644 index 00000000000..67f78f64616 --- /dev/null +++ b/client-core/src/main/java/com/influxdb/exceptions/GatewayTimeoutException.java @@ -0,0 +1,37 @@ +/* + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.influxdb.exceptions; + +import org.jetbrains.annotations.Nullable; +import retrofit2.Response; + +/** + * The exception is thrown if an HTTP 504 response code arrived - Gateway Timeout. + * + * @author Jakub Bednar (bednar@github) (06/23/2022 13:16) + */ +public class GatewayTimeoutException extends InfluxException { + + public GatewayTimeoutException(@Nullable final Response cause) { + super(cause); + } +} diff --git a/client-core/src/main/java/com/influxdb/exceptions/InfluxException.java b/client-core/src/main/java/com/influxdb/exceptions/InfluxException.java index 6b472e05d7f..3b79769c64a 100644 --- a/client-core/src/main/java/com/influxdb/exceptions/InfluxException.java +++ b/client-core/src/main/java/com/influxdb/exceptions/InfluxException.java @@ -50,6 +50,7 @@ public class InfluxException extends RuntimeException { private static final Logger LOG = Logger.getLogger(InfluxException.class.getName()); + private static final String HTTP_STATUS_CODE_MESSAGE = "HTTP status code: %d; Message: %s"; private final Response response; private final String message; @@ -88,7 +89,7 @@ public String getMessage() { } /** - * Gets the reference code unique to the error type. If the reference code is not present than return "0". + * Gets the reference code unique to the error type. If the reference code is not present then return "0". * * @return reference code unique to the error type */ @@ -108,7 +109,7 @@ public int reference() { /** * Gets the HTTP status code of the unsuccessful response. - * If the response is not present than return "0". + * If the response is not present then return "0". * * @return HTTP status code */ @@ -123,7 +124,7 @@ public int status() { /** * Gets the HTTP headers from the unsuccessful response. - * If the response is not present than return empty {@code Map}. + * If the response is not present then return empty {@code Map}. * * @return HTTP headers */ @@ -155,6 +156,7 @@ public Map errorBody() { @Nullable private String messageFromResponse() { if (response != null) { + int code = response.code(); try { ResponseBody body = response.errorBody(); if (body != null) { @@ -163,7 +165,7 @@ private String messageFromResponse() { errorBody = new Gson().fromJson(json, new TypeToken>() { }.getType()); if (errorBody.containsKey("message")) { - return errorBody.get("message").toString(); + return String.format(HTTP_STATUS_CODE_MESSAGE, code, errorBody.get("message").toString()); } } } @@ -177,7 +179,7 @@ private String messageFromResponse() { .orElse(null); if (value != null) { - return value; + return String.format(HTTP_STATUS_CODE_MESSAGE, code, value); } } diff --git a/client-core/src/main/java/com/influxdb/internal/AbstractRestClient.java b/client-core/src/main/java/com/influxdb/internal/AbstractRestClient.java index 39bd58498c1..63d15897d4a 100644 --- a/client-core/src/main/java/com/influxdb/internal/AbstractRestClient.java +++ b/client-core/src/main/java/com/influxdb/internal/AbstractRestClient.java @@ -32,6 +32,7 @@ import com.influxdb.exceptions.BadGatewayException; import com.influxdb.exceptions.BadRequestException; import com.influxdb.exceptions.ForbiddenException; +import com.influxdb.exceptions.GatewayTimeoutException; import com.influxdb.exceptions.InfluxException; import com.influxdb.exceptions.InternalServerErrorException; import com.influxdb.exceptions.MethodNotAllowedException; @@ -138,6 +139,8 @@ protected InfluxException responseToError(@Nonnull final Response response) { return new BadGatewayException(response); case 503: return new ServiceUnavailableException(response); + case 504: + return new GatewayTimeoutException(response); default: return new InfluxException(response); } diff --git a/client-core/src/test/java/com/influxdb/exceptions/InfluxExceptionTest.java b/client-core/src/test/java/com/influxdb/exceptions/InfluxExceptionTest.java index 6462399e858..941f07986a3 100644 --- a/client-core/src/test/java/com/influxdb/exceptions/InfluxExceptionTest.java +++ b/client-core/src/test/java/com/influxdb/exceptions/InfluxExceptionTest.java @@ -78,7 +78,7 @@ void retrofitHttpException() { }) .isInstanceOf(InfluxException.class) .hasCauseInstanceOf(HttpException.class) - .hasMessage("Wrong query"); + .hasMessage("HTTP status code: 500; Message: Wrong query"); } @Test @@ -172,7 +172,7 @@ void errorBodyInfluxDB() { Response response = errorResponse("not found", 404, 15, "{\"code\":\"not found\",\"message\":\"user not found\"}", "X-Platform-Error-Code"); throw new InfluxException(new HttpException(response)); }) - .matches((Predicate) throwable -> throwable.getMessage().equals("user not found")); + .matches((Predicate) throwable -> throwable.getMessage().equals("HTTP status code: 404; Message: user not found")); } @Test @@ -182,7 +182,7 @@ void errorBodyInfluxDBWithoutMsg() { Response response = errorResponse("not found", 404, 15, "{\"code\":\"not found\"}", "X-Platform-Error-Code"); throw new InfluxException(new HttpException(response)); }) - .matches((Predicate) throwable -> throwable.getMessage().equals("not found")); + .matches((Predicate) throwable -> throwable.getMessage().equals("HTTP status code: 404; Message: not found")); } @Test @@ -192,7 +192,7 @@ void errorBodyInfluxDBNotJson() { Response response = errorResponse("not found", 404, 15, "not-json", "X-Platform-Error-Code"); throw new InfluxException(new HttpException(response)); }) - .matches((Predicate) throwable -> throwable.getMessage().equals("not found")); + .matches((Predicate) throwable -> throwable.getMessage().equals("HTTP status code: 404; Message: not found")); } @Test @@ -314,6 +314,17 @@ void nullResponse() { .matches((Predicate) throwable -> ((InfluxException) throwable).errorBody().isEmpty()); } + @Test + void messageContainsHttpErrorCode() { + Assertions + .assertThatThrownBy(() -> { + Response response = errorResponse("Wrong query", 501, 15, "{\"error\": \"error-body\"}"); + throw new InfluxException(new HttpException(response)); + }) + .matches((Predicate) throwable -> throwable.getMessage().equals("HTTP status code: 501; Message: Wrong query")) + .matches((Predicate) throwable -> throwable.toString().equals("com.influxdb.exceptions.InfluxException: HTTP status code: 501; Message: Wrong query")); + } + @Nonnull private Response errorResponse(@Nullable final String influxError) { return errorResponse(influxError, 500); diff --git a/client-core/src/test/java/com/influxdb/internal/QueryAbstractApiTest.java b/client-core/src/test/java/com/influxdb/internal/QueryAbstractApiTest.java index 0a59dddc3d9..a7401f71c19 100644 --- a/client-core/src/test/java/com/influxdb/internal/QueryAbstractApiTest.java +++ b/client-core/src/test/java/com/influxdb/internal/QueryAbstractApiTest.java @@ -172,7 +172,7 @@ void queryError() { Assertions.assertThatThrownBy(() -> queryClient.query(createCall(), consumer, AbstractQueryApi.ERROR_CONSUMER, () -> { }, false)) .isInstanceOf(InfluxException.class) - .hasMessage("Flux query is not valid"); + .hasMessage("HTTP status code: 500; Message: Flux query is not valid"); } @Test @@ -238,7 +238,7 @@ void queryRawError() { Assertions.assertThatThrownBy(() -> queryClient.queryRaw(createCall(), consumer, AbstractQueryApi.ERROR_CONSUMER, () -> { }, false)) .isInstanceOf(InfluxException.class) - .hasMessage("Flux query is not valid"); + .hasMessage("HTTP status code: 500; Message: Flux query is not valid"); } @Test diff --git a/client-core/src/test/java/com/influxdb/internal/RestClientTest.java b/client-core/src/test/java/com/influxdb/internal/RestClientTest.java index 652bb974f79..3db33d8759f 100644 --- a/client-core/src/test/java/com/influxdb/internal/RestClientTest.java +++ b/client-core/src/test/java/com/influxdb/internal/RestClientTest.java @@ -30,6 +30,7 @@ import com.influxdb.exceptions.BadGatewayException; import com.influxdb.exceptions.BadRequestException; import com.influxdb.exceptions.ForbiddenException; +import com.influxdb.exceptions.GatewayTimeoutException; import com.influxdb.exceptions.InfluxException; import com.influxdb.exceptions.InternalServerErrorException; import com.influxdb.exceptions.MethodNotAllowedException; @@ -114,6 +115,7 @@ void exceptionType() { Assertions.assertThatThrownBy(() -> errorResponse(501)).isInstanceOf(NotImplementedException.class); Assertions.assertThatThrownBy(() -> errorResponse(502)).isInstanceOf(BadGatewayException.class); Assertions.assertThatThrownBy(() -> errorResponse(503)).isInstanceOf(ServiceUnavailableException.class); + Assertions.assertThatThrownBy(() -> errorResponse(504)).isInstanceOf(GatewayTimeoutException.class); Assertions.assertThatThrownBy(() -> errorResponse(550)).isInstanceOf(InfluxException.class); } @@ -202,7 +204,7 @@ void restCallError() { Assertions.assertThatThrownBy(() -> restClient.execute(call)) .isInstanceOf(InfluxException.class) - .hasMessage("flower not found"); + .hasMessage("HTTP status code: 500; Message: flower not found"); } @Test diff --git a/client-kotlin/src/test/kotlin/com/influxdb/client/kotlin/WriteKotlinApiTest.kt b/client-kotlin/src/test/kotlin/com/influxdb/client/kotlin/WriteKotlinApiTest.kt index 552b013ec7a..dc71e14453b 100644 --- a/client-kotlin/src/test/kotlin/com/influxdb/client/kotlin/WriteKotlinApiTest.kt +++ b/client-kotlin/src/test/kotlin/com/influxdb/client/kotlin/WriteKotlinApiTest.kt @@ -183,7 +183,7 @@ class WriteKotlinApiTest : AbstractMockServerTest() { runBlocking { writeApi.writeRecord("h2o_feet,location=coyote_creek water_level=1.0 1", WritePrecision.S) } - }.hasMessageStartingWith("token does not have sufficient permissions") + }.hasMessageStartingWith("HTTP status code: 401; Message: token does not have sufficient permissions") .isInstanceOf(UnauthorizedException::class.java) } diff --git a/client-legacy/src/test/java/com/influxdb/client/flux/FluxClientQueryRawTest.java b/client-legacy/src/test/java/com/influxdb/client/flux/FluxClientQueryRawTest.java index a10f4590f40..2966a0327d6 100644 --- a/client-legacy/src/test/java/com/influxdb/client/flux/FluxClientQueryRawTest.java +++ b/client-legacy/src/test/java/com/influxdb/client/flux/FluxClientQueryRawTest.java @@ -58,7 +58,7 @@ void queryRawError() { mockServer.enqueue(createErrorResponse()); Assertions.assertThatThrownBy(() -> fluxClient.queryRaw("from(bucket:\"telegraf\")")) - .hasMessage("Flux query is not valid") + .hasMessage("HTTP status code: 500; Message: Flux query is not valid") .isInstanceOf(InfluxException.class); } diff --git a/client-legacy/src/test/java/com/influxdb/client/flux/FluxClientQueryTest.java b/client-legacy/src/test/java/com/influxdb/client/flux/FluxClientQueryTest.java index 8fab2a8df01..50efbbcf0a7 100644 --- a/client-legacy/src/test/java/com/influxdb/client/flux/FluxClientQueryTest.java +++ b/client-legacy/src/test/java/com/influxdb/client/flux/FluxClientQueryTest.java @@ -90,7 +90,7 @@ void queryError() { Assertions.assertThatThrownBy(() -> fluxClient.query("from(bucket:\"telegraf\")")) .isInstanceOf(InfluxException.class) - .hasMessage("Flux query is not valid"); + .hasMessage("HTTP status code: 500; Message: Flux query is not valid"); } @Test diff --git a/client-legacy/src/test/java/com/influxdb/client/flux/ITFluxClient.java b/client-legacy/src/test/java/com/influxdb/client/flux/ITFluxClient.java index d065d9a922e..e7494b12c13 100644 --- a/client-legacy/src/test/java/com/influxdb/client/flux/ITFluxClient.java +++ b/client-legacy/src/test/java/com/influxdb/client/flux/ITFluxClient.java @@ -182,7 +182,7 @@ void error() { Assertions.assertThatThrownBy(() -> fluxClient.query("from(bucket:\"telegraf\")")) .isInstanceOf(InfluxException.class) - .hasMessageStartingWith("error in building plan while starting program:") + .hasMessageStartingWith("HTTP status code: 500; Message: error in building plan while starting program:") .hasMessageEndingWith("try bounding 'from' with a call to 'range'"); } diff --git a/client-reactive/src/test/java/com/influxdb/client/reactive/WriteReactiveApiTest.java b/client-reactive/src/test/java/com/influxdb/client/reactive/WriteReactiveApiTest.java index a5265d5d960..bc5bab1d7df 100644 --- a/client-reactive/src/test/java/com/influxdb/client/reactive/WriteReactiveApiTest.java +++ b/client-reactive/src/test/java/com/influxdb/client/reactive/WriteReactiveApiTest.java @@ -313,7 +313,7 @@ void disableRetry() { .assertValueCount(0) .assertError(throwable -> { Assertions.assertThat(throwable).isInstanceOf(InfluxException.class); - Assertions.assertThat(throwable).hasMessage("token is temporarily over quota"); + Assertions.assertThat(throwable).hasMessage("HTTP status code: 429; Message: token is temporarily over quota"); return true; }) .assertNotComplete(); diff --git a/client-scala/src/test/scala/com/influxdb/client/scala/WriteScalaApiTest.scala b/client-scala/src/test/scala/com/influxdb/client/scala/WriteScalaApiTest.scala index 2b91b914095..786d3f8994e 100644 --- a/client-scala/src/test/scala/com/influxdb/client/scala/WriteScalaApiTest.scala +++ b/client-scala/src/test/scala/com/influxdb/client/scala/WriteScalaApiTest.scala @@ -111,7 +111,7 @@ class WriteScalaApiTest extends AnyFunSuite with Matchers with BeforeAndAfter wi val materialized = source.toMat(sink)(Keep.right) whenReady(materialized.run().failed) { exc => { - exc.getMessage should be("line protocol poorly formed and no points were written") + exc.getMessage should be("HTTP status code: 500; Message: line protocol poorly formed and no points were written") exc.getClass should be(classOf[InternalServerErrorException]) } } diff --git a/client/src/main/java/com/influxdb/client/internal/InfluxDBClientImpl.java b/client/src/main/java/com/influxdb/client/internal/InfluxDBClientImpl.java index 8e331b3741d..386bde83805 100644 --- a/client/src/main/java/com/influxdb/client/internal/InfluxDBClientImpl.java +++ b/client/src/main/java/com/influxdb/client/internal/InfluxDBClientImpl.java @@ -79,7 +79,6 @@ import com.influxdb.exceptions.UnprocessableEntityException; import com.influxdb.utils.Arguments; -import org.jetbrains.annotations.NotNull; import retrofit2.Call; /** @@ -242,7 +241,7 @@ public DeleteApi getDeleteApi() { return new DeleteApiImpl(retrofit.create(DeleteService.class)); } - @NotNull + @Nonnull @Override public InvokableScriptsApi getInvokableScriptsApi() { return new InvokableScriptsApiImpl(retrofit.create(InvokableScriptsService.class)); diff --git a/client/src/test/java/com/influxdb/client/ITAuthorizationsApi.java b/client/src/test/java/com/influxdb/client/ITAuthorizationsApi.java index 779869e0d4b..681332e0070 100644 --- a/client/src/test/java/com/influxdb/client/ITAuthorizationsApi.java +++ b/client/src/test/java/com/influxdb/client/ITAuthorizationsApi.java @@ -223,7 +223,7 @@ void findAuthorizationsByIDNull() { Assertions.assertThatThrownBy(() -> authorizationsApi.findAuthorizationByID("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("authorization not found"); + .hasMessage("HTTP status code: 404; Message: authorization not found"); } @Test @@ -321,7 +321,7 @@ void deleteAuthorization() { Assertions.assertThatThrownBy(() -> authorizationsApi.findAuthorizationByID(createdAuthorization.getId())) .isInstanceOf(NotFoundException.class) - .hasMessage("authorization not found"); + .hasMessage("HTTP status code: 404; Message: authorization not found"); } @Test @@ -350,7 +350,7 @@ void cloneAuthorizationNotFound() { Assertions.assertThatThrownBy(() -> authorizationsApi.cloneAuthorization("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("authorization not found"); + .hasMessage("HTTP status code: 404; Message: authorization not found"); } @Nonnull diff --git a/client/src/test/java/com/influxdb/client/ITBucketsApi.java b/client/src/test/java/com/influxdb/client/ITBucketsApi.java index a59d946d713..7d90fa1421d 100644 --- a/client/src/test/java/com/influxdb/client/ITBucketsApi.java +++ b/client/src/test/java/com/influxdb/client/ITBucketsApi.java @@ -142,7 +142,7 @@ void findBucketByIDNull() { Assertions.assertThatThrownBy(() -> bucketsApi.findBucketByID("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("bucket not found"); + .hasMessage("HTTP status code: 404; Message: bucket not found"); } @Test @@ -237,7 +237,7 @@ void deleteBucket() { Assertions.assertThatThrownBy(() -> bucketsApi.findBucketByID(createBucket.getId())) .isInstanceOf(NotFoundException.class) - .hasMessage("bucket not found"); + .hasMessage("HTTP status code: 404; Message: bucket not found"); } @Test @@ -408,6 +408,6 @@ void cloneBucket() { void cloneBucketNotFound() { Assertions.assertThatThrownBy(() -> bucketsApi.cloneBucket(generateName("cloned"), "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("bucket not found"); + .hasMessage("HTTP status code: 404; Message: bucket not found"); } } \ No newline at end of file diff --git a/client/src/test/java/com/influxdb/client/ITChecksApi.java b/client/src/test/java/com/influxdb/client/ITChecksApi.java index 3e9feb3075e..c1354de77aa 100644 --- a/client/src/test/java/com/influxdb/client/ITChecksApi.java +++ b/client/src/test/java/com/influxdb/client/ITChecksApi.java @@ -225,7 +225,7 @@ public void updateCheckNotExists() { Assertions.assertThatThrownBy(() -> checksApi.updateCheck("020f755c3c082000", update)) .isInstanceOf(NotFoundException.class) - .hasMessage("check not found for key \"020f755c3c082000\""); + .hasMessage("HTTP status code: 404; Message: check not found for key \"020f755c3c082000\""); } @Test @@ -247,7 +247,7 @@ public void deleteCheck() { Assertions.assertThatThrownBy(() -> checksApi.findCheckByID(found.getId())) .isInstanceOf(NotFoundException.class) - .hasMessage("check not found for key \"" + found.getId() + "\""); + .hasMessage("HTTP status code: 404; Message: check not found for key \"" + found.getId() + "\""); } @Test @@ -255,7 +255,7 @@ public void deleteCheckNotFound() { Assertions.assertThatThrownBy(() -> checksApi.deleteCheck("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("check not found for key \"020f755c3c082000\""); + .hasMessage("HTTP status code: 404; Message: check not found for key \"020f755c3c082000\""); } @Test @@ -280,7 +280,7 @@ public void findCheckByID() { public void findCheckByIDNotFound() { Assertions.assertThatThrownBy(() -> checksApi.findCheckByID("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("check not found for key \"020f755c3c082000\""); + .hasMessage("HTTP status code: 404; Message: check not found for key \"020f755c3c082000\""); } @Test diff --git a/client/src/test/java/com/influxdb/client/ITDashboardsApi.java b/client/src/test/java/com/influxdb/client/ITDashboardsApi.java index 5c430e35737..de7abd8f558 100644 --- a/client/src/test/java/com/influxdb/client/ITDashboardsApi.java +++ b/client/src/test/java/com/influxdb/client/ITDashboardsApi.java @@ -142,7 +142,7 @@ void findDashboardByIDNotFound() { Assertions.assertThatThrownBy(() -> dashboardsApi.findDashboardByID("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("dashboard not found"); + .hasMessage("HTTP status code: 404; Message: dashboard not found"); } @Test @@ -351,7 +351,7 @@ void addCellDashboardNotFound() { Assertions.assertThatThrownBy(() -> dashboardsApi.addCell(createCell, "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("dashboard not found"); + .hasMessage("HTTP status code: 404; Message: dashboard not found"); } @Test @@ -462,7 +462,7 @@ void deleteCellNotFound() { Assertions.assertThatThrownBy(() -> dashboardsApi.deleteCell("020f755c3c082000", dashboard.getId())) .isInstanceOf(NotFoundException.class) - .hasMessage("cell not found"); + .hasMessage("HTTP status code: 404; Message: cell not found"); } @Test @@ -482,7 +482,7 @@ void deleteCellDashboardNotFound() { Assertions.assertThatThrownBy(() -> dashboardsApi.deleteCell(cell.getId(), "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("dashboard not found"); + .hasMessage("HTTP status code: 404; Message: dashboard not found"); } @Test @@ -582,7 +582,7 @@ void addCellViewNotFound() { Assertions.assertThatThrownBy(() -> dashboardsApi.addCellView(view, cell.getId(), "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("dashboard not found"); + .hasMessage("HTTP status code: 404; Message: dashboard not found"); //TODO https://github.com/influxdata/influxdb/issues/13083 // Assertions.assertThatThrownBy(() -> dashboardsApi.addCellView(view, "020f755c3c082000", dashboard.getId())) @@ -607,7 +607,7 @@ void getCellViewNotFound() { Assertions.assertThatThrownBy(() -> dashboardsApi.getCellView(cell.getId(), "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("dashboard not found"); + .hasMessage("HTTP status code: 404; Message: dashboard not found"); //TODO https://github.com/influxdata/influxdb/issues/13083 // Assertions.assertThatThrownBy(() -> dashboardsApi.getCellView("ffffffffffffffff", dashboard.getId())) diff --git a/client/src/test/java/com/influxdb/client/ITInfluxDBClient.java b/client/src/test/java/com/influxdb/client/ITInfluxDBClient.java index 6b55d56d351..18133689022 100644 --- a/client/src/test/java/com/influxdb/client/ITInfluxDBClient.java +++ b/client/src/test/java/com/influxdb/client/ITInfluxDBClient.java @@ -194,7 +194,7 @@ void onboardingAlreadyDone() { Assertions.assertThatThrownBy(() -> influxDBClient.onBoarding(onboarding)) .isInstanceOf(UnprocessableEntityException.class) - .hasMessage("onboarding has already been completed"); + .hasMessage("HTTP status code: 422; Message: onboarding has already been completed"); } @Test diff --git a/client/src/test/java/com/influxdb/client/ITLabelsApi.java b/client/src/test/java/com/influxdb/client/ITLabelsApi.java index f1931c9b829..16cb6ca7ea0 100644 --- a/client/src/test/java/com/influxdb/client/ITLabelsApi.java +++ b/client/src/test/java/com/influxdb/client/ITLabelsApi.java @@ -107,7 +107,7 @@ void findLabelByIDNull() { Assertions.assertThatThrownBy(() -> labelsApi.findLabelByID("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("label not found"); + .hasMessage("HTTP status code: 404; Message: label not found"); } @Test @@ -153,7 +153,7 @@ void deleteLabel() { Assertions.assertThatThrownBy(() -> labelsApi.findLabelByID(createdLabel.getId())) .isInstanceOf(NotFoundException.class) - .hasMessage("label not found"); + .hasMessage("HTTP status code: 404; Message: label not found"); } @Test @@ -212,6 +212,6 @@ void cloneLabel() { void cloneLabelNotFound() { Assertions.assertThatThrownBy(() -> labelsApi.cloneLabel(generateName("cloned"), "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("label not found"); + .hasMessage("HTTP status code: 404; Message: label not found"); } } \ No newline at end of file diff --git a/client/src/test/java/com/influxdb/client/ITNotificationEndpointsApi.java b/client/src/test/java/com/influxdb/client/ITNotificationEndpointsApi.java index 67a01ee7627..79fe2475082 100644 --- a/client/src/test/java/com/influxdb/client/ITNotificationEndpointsApi.java +++ b/client/src/test/java/com/influxdb/client/ITNotificationEndpointsApi.java @@ -168,7 +168,7 @@ public void slackUrlShouldBeDefined() { Assertions.assertThatThrownBy(() -> notificationEndpointsApi .createEndpoint(endpoint)) .isInstanceOf(BadRequestException.class) - .hasMessage("slack endpoint URL must be provided"); + .hasMessage("HTTP status code: 400; Message: slack endpoint URL must be provided"); } @Test @@ -339,7 +339,7 @@ public void updateEndpointNotExists() { Assertions.assertThatThrownBy(() -> notificationEndpointsApi.updateEndpoint("020f755c3c082000", update)) .isInstanceOf(NotFoundException.class) - .hasMessage("notification endpoint not found for key \"020f755c3c082000\""); + .hasMessage("HTTP status code: 404; Message: notification endpoint not found for key \"020f755c3c082000\""); } @Test @@ -354,7 +354,7 @@ public void deleteEndpoint() { Assertions.assertThatThrownBy(() -> notificationEndpointsApi.findNotificationEndpointByID(found.getId())) .isInstanceOf(NotFoundException.class) - .hasMessage("notification endpoint not found for key \"" + found.getId() + "\""); + .hasMessage("HTTP status code: 404; Message: notification endpoint not found for key \"" + found.getId() + "\""); } @Test @@ -362,7 +362,7 @@ public void deleteEndpointNotFound() { Assertions.assertThatThrownBy(() -> notificationEndpointsApi.deleteNotificationEndpoint("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("notification endpoint not found for key \"020f755c3c082000\""); + .hasMessage("HTTP status code: 404; Message: notification endpoint not found for key \"020f755c3c082000\""); } @Test @@ -381,7 +381,7 @@ public void findNotificationEndpointByID() { public void findNotificationEndpointByIDNotFound() { Assertions.assertThatThrownBy(() -> notificationEndpointsApi.findNotificationEndpointByID("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("notification endpoint not found for key \"020f755c3c082000\""); + .hasMessage("HTTP status code: 404; Message: notification endpoint not found for key \"020f755c3c082000\""); } @Test @@ -516,27 +516,27 @@ public void cloneNotFound() { Assertions.assertThatThrownBy(() -> notificationEndpointsApi .cloneSlackEndpoint("not-found-cloned", "token", "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("notification endpoint not found for key \"020f755c3c082000\""); + .hasMessage("HTTP status code: 404; Message: notification endpoint not found for key \"020f755c3c082000\""); Assertions.assertThatThrownBy(() -> notificationEndpointsApi .clonePagerDutyEndpoint("not-found-cloned", "token", "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("notification endpoint not found for key \"020f755c3c082000\""); + .hasMessage("HTTP status code: 404; Message: notification endpoint not found for key \"020f755c3c082000\""); Assertions.assertThatThrownBy(() -> notificationEndpointsApi .cloneHTTPEndpoint("not-found-cloned", "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("notification endpoint not found for key \"020f755c3c082000\""); + .hasMessage("HTTP status code: 404; Message: notification endpoint not found for key \"020f755c3c082000\""); Assertions.assertThatThrownBy(() -> notificationEndpointsApi .cloneHTTPEndpointBearer("not-found-cloned", "token", "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("notification endpoint not found for key \"020f755c3c082000\""); + .hasMessage("HTTP status code: 404; Message: notification endpoint not found for key \"020f755c3c082000\""); Assertions.assertThatThrownBy(() -> notificationEndpointsApi .cloneHTTPEndpointBasicAuth("not-found-cloned", "username", "password", "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("notification endpoint not found for key \"020f755c3c082000\""); + .hasMessage("HTTP status code: 404; Message: notification endpoint not found for key \"020f755c3c082000\""); } @Test diff --git a/client/src/test/java/com/influxdb/client/ITNotificationRulesApi.java b/client/src/test/java/com/influxdb/client/ITNotificationRulesApi.java index 7708e114b30..ed50b969b9e 100644 --- a/client/src/test/java/com/influxdb/client/ITNotificationRulesApi.java +++ b/client/src/test/java/com/influxdb/client/ITNotificationRulesApi.java @@ -278,7 +278,7 @@ public void updateRuleNotExists() { Assertions.assertThatThrownBy(() -> notificationRulesApi.updateNotificationRule("020f755c3c082000", update)) .isInstanceOf(NotFoundException.class) - .hasMessage("notification rule not found"); + .hasMessage("HTTP status code: 404; Message: notification rule not found"); } @Test @@ -298,7 +298,7 @@ public void deleteRule() { Assertions.assertThatThrownBy(() -> notificationRulesApi.findNotificationRuleByID(created.getId())) .isInstanceOf(NotFoundException.class) - .hasMessage("notification rule not found"); + .hasMessage("HTTP status code: 404; Message: notification rule not found"); } @Test @@ -306,7 +306,7 @@ public void deleteRuleNotFound() { Assertions.assertThatThrownBy(() -> notificationRulesApi.deleteNotificationRule("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("notification rule not found"); + .hasMessage("HTTP status code: 404; Message: notification rule not found"); } @Test @@ -330,7 +330,7 @@ public void findRuleByID() { public void findRuleByIDNotFound() { Assertions.assertThatThrownBy(() -> notificationRulesApi.findNotificationRuleByID("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("notification rule not found"); + .hasMessage("HTTP status code: 404; Message: notification rule not found"); } @Test diff --git a/client/src/test/java/com/influxdb/client/ITOrganizationsApi.java b/client/src/test/java/com/influxdb/client/ITOrganizationsApi.java index 0264eee6e26..6d4b97b17bb 100644 --- a/client/src/test/java/com/influxdb/client/ITOrganizationsApi.java +++ b/client/src/test/java/com/influxdb/client/ITOrganizationsApi.java @@ -124,7 +124,7 @@ void findOrganizationByIDNull() { Assertions.assertThatThrownBy(() -> organizationsApi.findOrganizationByID("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("organization not found"); + .hasMessage("HTTP status code: 404; Message: organization not found"); } @Test @@ -152,7 +152,7 @@ void deleteOrganization() { Assertions.assertThatThrownBy(() -> organizationsApi.findOrganizationByID(createdOrganization.getId())) .isInstanceOf(NotFoundException.class) - .hasMessage("organization not found"); + .hasMessage("HTTP status code: 404; Message: organization not found"); } @Test @@ -280,6 +280,6 @@ void cloneOrganization() { void cloneOrganizationNotFound() { Assertions.assertThatThrownBy(() -> organizationsApi.cloneOrganization(generateName("cloned"), "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("organization not found"); + .hasMessage("HTTP status code: 404; Message: organization not found"); } } \ No newline at end of file diff --git a/client/src/test/java/com/influxdb/client/ITScraperTargetsApi.java b/client/src/test/java/com/influxdb/client/ITScraperTargetsApi.java index 9d8a9193f09..35f6a4de10a 100644 --- a/client/src/test/java/com/influxdb/client/ITScraperTargetsApi.java +++ b/client/src/test/java/com/influxdb/client/ITScraperTargetsApi.java @@ -142,7 +142,7 @@ void findScraperByIDNull() { Assertions.assertThatThrownBy(() -> scraperTargetsApi.findScraperTargetByID("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("scraper target is not found"); + .hasMessage("HTTP status code: 404; Message: scraper target is not found"); } @Test @@ -160,7 +160,7 @@ void deleteScraper() { Assertions.assertThatThrownBy(() -> scraperTargetsApi.findScraperTargetByID(createdScraper.getId())) .isInstanceOf(NotFoundException.class) - .hasMessage("scraper target is not found"); + .hasMessage("HTTP status code: 404; Message: scraper target is not found"); } @Test @@ -290,6 +290,6 @@ void cloneScraperTarget() { void cloneScraperTargetNotFound() { Assertions.assertThatThrownBy(() -> scraperTargetsApi.cloneScraperTarget(generateName("cloned"), "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("scraper target is not found"); + .hasMessage("HTTP status code: 404; Message: scraper target is not found"); } } \ No newline at end of file diff --git a/client/src/test/java/com/influxdb/client/ITSourcesApi.java b/client/src/test/java/com/influxdb/client/ITSourcesApi.java index af5399bd1f2..14acd8f404f 100644 --- a/client/src/test/java/com/influxdb/client/ITSourcesApi.java +++ b/client/src/test/java/com/influxdb/client/ITSourcesApi.java @@ -126,7 +126,7 @@ void deleteSource() { Assertions.assertThatThrownBy(() -> sourcesApi.findSourceByID(createdSource.getId())) .isInstanceOf(NotFoundException.class) - .hasMessage("source not found"); + .hasMessage("HTTP status code: 404; Message: source not found"); } @@ -151,7 +151,7 @@ void findSourceByIDNull() { Assertions.assertThatThrownBy(() -> sourcesApi.findSourceByID("020f755c3d082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("source not found"); + .hasMessage("HTTP status code: 404; Message: source not found"); } @Test @@ -182,7 +182,7 @@ void findBucketsBySourceByUnknownSource() { Assertions.assertThatThrownBy(() -> sourcesApi.findBucketsBySourceID("020f755c3d082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("source not found"); + .hasMessage("HTTP status code: 404; Message: source not found"); } @Test @@ -224,7 +224,7 @@ void cloneSource() { void cloneSourceNotFound() { Assertions.assertThatThrownBy(() -> sourcesApi.cloneSource(generateName("cloned"), "da7aba5e5d81e550")) .isInstanceOf(NotFoundException.class) - .hasMessage("source not found"); + .hasMessage("HTTP status code: 404; Message: source not found"); } @Nonnull diff --git a/client/src/test/java/com/influxdb/client/ITTasksApi.java b/client/src/test/java/com/influxdb/client/ITTasksApi.java index 020df15086f..dfeaefd80c2 100644 --- a/client/src/test/java/com/influxdb/client/ITTasksApi.java +++ b/client/src/test/java/com/influxdb/client/ITTasksApi.java @@ -257,7 +257,7 @@ void findTaskByIDNull() { Assertions.assertThatThrownBy(() -> tasksApi.findTaskByID("020f755c3d082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("failed to find task: task not found"); + .hasMessage("HTTP status code: 404; Message: failed to find task: task not found"); } @Test @@ -332,7 +332,7 @@ void deleteTask() { Assertions.assertThatThrownBy(() -> tasksApi.findTaskByID(createdTask.getId())) .isInstanceOf(NotFoundException.class) - .hasMessage("failed to find task: task not found"); + .hasMessage("HTTP status code: 404; Message: failed to find task: task not found"); } @Test @@ -466,7 +466,7 @@ void runsNotExist() { Assertions.assertThatThrownBy(() -> tasksApi.getRuns("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("failed to find runs: task not found"); + .hasMessage("HTTP status code: 404; Message: failed to find runs: task not found"); } @Test @@ -559,7 +559,7 @@ void runNotExist() { Assertions.assertThatThrownBy(() -> tasksApi.getRun(task.getId(), "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("failed to find run: run not found"); + .hasMessage("HTTP status code: 404; Message: failed to find run: run not found"); } @Test @@ -578,7 +578,7 @@ void runTaskManuallyNotExist() { Assertions.assertThatThrownBy(() -> tasksApi.runManually("020f755c3c082000", new RunManually())) .isInstanceOf(NotFoundException.class) - .hasMessage("failed to force run: task not found"); + .hasMessage("HTTP status code: 404; Message: failed to force run: task not found"); } @Test @@ -611,7 +611,7 @@ void retryRunNotExist() { Assertions.assertThatThrownBy(() -> tasksApi.retryRun(task.getId(), "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("failed to retry run: run not found"); + .hasMessage("HTTP status code: 404; Message: failed to retry run: run not found"); } @Test @@ -644,7 +644,7 @@ void logsNotExist() { Assertions.assertThatThrownBy(() -> tasksApi.getLogs("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("failed to find task logs: task not found"); + .hasMessage("HTTP status code: 404; Message: failed to find task logs: task not found"); } @Test @@ -674,7 +674,7 @@ void runLogsNotExist() { Assertions.assertThatThrownBy(() -> tasksApi.getRunLogs(task.getId(), "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("failed to find task logs: run not found"); + .hasMessage("HTTP status code: 404; Message: failed to find task logs: run not found"); } @Test @@ -690,7 +690,7 @@ void cancelRunNotExist() throws InterruptedException { Assertions.assertThatThrownBy(() -> tasksApi.cancelRun(runs.get(0))) .isInstanceOf(NotFoundException.class) - .hasMessage("failed to cancel run: run not found"); + .hasMessage("HTTP status code: 404; Message: failed to cancel run: run not found"); } @Test @@ -698,7 +698,7 @@ void cancelRunTaskNotExist() { Assertions.assertThatThrownBy(() -> tasksApi.cancelRun("020f755c3c082000", "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("failed to cancel run: task not found"); + .hasMessage("HTTP status code: 404; Message: failed to cancel run: task not found"); } @Test @@ -771,7 +771,7 @@ void cloneTask() { void cloneTaskNotFound() { Assertions.assertThatThrownBy(() -> tasksApi.cloneTask("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("failed to find task: task not found"); + .hasMessage("HTTP status code: 404; Message: failed to find task: task not found"); } @Nonnull diff --git a/client/src/test/java/com/influxdb/client/ITTelegrafsApi.java b/client/src/test/java/com/influxdb/client/ITTelegrafsApi.java index 64b71bf80e4..87d868f48e0 100644 --- a/client/src/test/java/com/influxdb/client/ITTelegrafsApi.java +++ b/client/src/test/java/com/influxdb/client/ITTelegrafsApi.java @@ -160,7 +160,7 @@ void deleteTelegrafConfig() { Assertions.assertThatThrownBy(() -> telegrafsApi.findTelegrafByID(createdConfig.getId())) .isInstanceOf(NotFoundException.class) - .hasMessage("telegraf configuration not found"); + .hasMessage("HTTP status code: 404; Message: telegraf configuration not found"); } @Test @@ -168,7 +168,7 @@ void deleteTelegrafConfigNotFound() { Assertions.assertThatThrownBy(() -> telegrafsApi.deleteTelegraf("020f755c3d082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("telegraf configuration not found"); + .hasMessage("HTTP status code: 404; Message: telegraf configuration not found"); } @Test @@ -193,7 +193,7 @@ void findTelegrafConfigByIDNull() { Assertions.assertThatThrownBy(() -> telegrafsApi.findTelegrafByID("020f755c3d082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("telegraf configuration not found"); + .hasMessage("HTTP status code: 404; Message: telegraf configuration not found"); } @Test @@ -247,7 +247,7 @@ void getTOMLNotFound() { Assertions.assertThatThrownBy(() -> telegrafsApi.getTOML("020f755c3d082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("telegraf configuration not found"); + .hasMessage("HTTP status code: 404; Message: telegraf configuration not found"); } @Test @@ -397,7 +397,7 @@ void cloneTelegrafConfig() { void cloneTelegrafConfigNotFound() { Assertions.assertThatThrownBy(() -> telegrafsApi.cloneTelegraf(generateName("cloned"), "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("telegraf configuration not found"); + .hasMessage("HTTP status code: 404; Message: telegraf configuration not found"); } @Nonnull diff --git a/client/src/test/java/com/influxdb/client/ITUsersApi.java b/client/src/test/java/com/influxdb/client/ITUsersApi.java index da50d62bce3..50ecf32fb83 100644 --- a/client/src/test/java/com/influxdb/client/ITUsersApi.java +++ b/client/src/test/java/com/influxdb/client/ITUsersApi.java @@ -87,7 +87,7 @@ void findUserByIDNull() { Assertions.assertThatThrownBy(() -> usersApi.findUserByID("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("user not found"); + .hasMessage("HTTP status code: 404; Message: user not found"); } @Test @@ -115,7 +115,7 @@ void deleteUser() { Assertions.assertThatThrownBy(() -> usersApi.findUserByID(createdUser.getId())) .isInstanceOf(NotFoundException.class) - .hasMessage("user not found"); + .hasMessage("HTTP status code: 404; Message: user not found"); } @Test @@ -147,7 +147,7 @@ void meNotAuthenticated() { Assertions.assertThatThrownBy(() -> usersApi.me()) .isInstanceOf(UnauthorizedException.class) - .hasMessage("unauthorized access"); + .hasMessage("HTTP status code: 401; Message: unauthorized access"); } @Test @@ -232,6 +232,6 @@ void cloneUser() { void cloneUserNotFound() { Assertions.assertThatThrownBy(() -> usersApi.cloneUser(generateName("cloned"), "020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("user not found"); + .hasMessage("HTTP status code: 404; Message: user not found"); } } \ No newline at end of file diff --git a/client/src/test/java/com/influxdb/client/ITVariablesApi.java b/client/src/test/java/com/influxdb/client/ITVariablesApi.java index f9e814b3ae8..541debb582d 100644 --- a/client/src/test/java/com/influxdb/client/ITVariablesApi.java +++ b/client/src/test/java/com/influxdb/client/ITVariablesApi.java @@ -198,7 +198,7 @@ void findVariableByIDNotFound() { Assertions.assertThatThrownBy(() -> variablesApi.findVariableByID("020f755c3c082000")) .isInstanceOf(NotFoundException.class) - .hasMessage("variable not found for key \"020f755c3c082000\""); + .hasMessage("HTTP status code: 404; Message: variable not found for key \"020f755c3c082000\""); } @Test diff --git a/client/src/test/java/com/influxdb/client/ITWriteApiBlocking.java b/client/src/test/java/com/influxdb/client/ITWriteApiBlocking.java index 6ca14f6adfc..149141b30dc 100644 --- a/client/src/test/java/com/influxdb/client/ITWriteApiBlocking.java +++ b/client/src/test/java/com/influxdb/client/ITWriteApiBlocking.java @@ -131,7 +131,7 @@ void propagateServerException() { WriteApiBlocking api = influxDBClient.getWriteApiBlocking(); Assertions.assertThatThrownBy(() -> api.writeRecord(WritePrecision.NS, "h2o,location=coyote_creek")) - .hasMessageStartingWith("unable to parse 'h2o,location=coyote_creek': missing fields") + .hasMessageStartingWith("HTTP status code: 400; Message: unable to parse 'h2o,location=coyote_creek': missing fields") .isInstanceOf(BadRequestException.class); } diff --git a/client/src/test/java/com/influxdb/client/WriteApiTest.java b/client/src/test/java/com/influxdb/client/WriteApiTest.java index 1cd8640aa8e..9c3456e2c1a 100644 --- a/client/src/test/java/com/influxdb/client/WriteApiTest.java +++ b/client/src/test/java/com/influxdb/client/WriteApiTest.java @@ -29,7 +29,6 @@ import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; -import javax.annotation.Nonnull; import com.influxdb.annotations.Column; import com.influxdb.annotations.Measurement; @@ -46,12 +45,9 @@ import com.influxdb.exceptions.InfluxException; import com.influxdb.exceptions.RequestEntityTooLargeException; import com.influxdb.exceptions.UnauthorizedException; -import com.influxdb.query.FluxRecord; -import com.influxdb.query.FluxTable; import io.reactivex.rxjava3.schedulers.TestScheduler; import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; import org.assertj.core.api.Assertions; import org.assertj.core.util.Lists; @@ -611,7 +607,7 @@ void eventUnhandledErrorEvent() { Assertions.assertThat(listener.getValue().getThrowable()).isNotNull(); Assertions.assertThat(listener.getValue().getThrowable()) .isInstanceOf(ForbiddenException.class) - .hasMessage("no token was sent and they are required"); + .hasMessage("HTTP status code: 403; Message: no token was sent and they are required"); } @Test @@ -655,7 +651,7 @@ void retryWithRetryAfter() throws InterruptedException { retriableListener.awaitCount(1); Assertions.assertThat(retriableListener.getValue().getThrowable()) .isInstanceOf(InfluxException.class) - .hasMessage("token is temporarily over quota"); + .hasMessage("HTTP status code: 429; Message: token is temporarily over quota"); Assertions.assertThat(retriableListener.getValue().getRetryInterval()).isEqualTo(5000); @@ -747,17 +743,17 @@ void retryAttempts() throws InterruptedException { writeApi.writePoint("b1", "org1", Point.measurement("h2o").addTag("location", "europe").addField("level", 2)); WriteRetriableErrorEvent error = retriableListener.awaitCount(1).popValue(); - Assertions.assertThat(error.getThrowable()).isInstanceOf(InfluxException.class).hasMessage("attempt1"); + Assertions.assertThat(error.getThrowable()).isInstanceOf(InfluxException.class).hasMessage("HTTP status code: 429; Message: attempt1"); Assertions.assertThat(error.getRetryInterval()).isGreaterThanOrEqualTo(100); Assertions.assertThat(error.getRetryInterval()).isLessThanOrEqualTo(200); error = retriableListener.awaitCount(1).popValue(); - Assertions.assertThat(error.getThrowable()).isInstanceOf(InfluxException.class).hasMessage("attempt2"); + Assertions.assertThat(error.getThrowable()).isInstanceOf(InfluxException.class).hasMessage("HTTP status code: 429; Message: attempt2"); Assertions.assertThat(error.getRetryInterval()).isGreaterThanOrEqualTo(200); Assertions.assertThat(error.getRetryInterval()).isLessThanOrEqualTo(400); error = retriableListener.awaitCount(1).popValue(); - Assertions.assertThat(error.getThrowable()).isInstanceOf(InfluxException.class).hasMessage("attempt3"); + Assertions.assertThat(error.getThrowable()).isInstanceOf(InfluxException.class).hasMessage("HTTP status code: 429; Message: attempt3"); Assertions.assertThat(error.getRetryInterval()).isGreaterThanOrEqualTo(400); Assertions.assertThat(error.getRetryInterval()).isLessThanOrEqualTo(800); @@ -798,7 +794,7 @@ void retryNotApplied() { WriteErrorEvent error = listener.awaitCount(1).popValue(); Assertions.assertThat(error.getThrowable()) .isInstanceOf(BadRequestException.class) - .hasMessage("line protocol poorly formed and no points were written"); + .hasMessage("HTTP status code: 400; Message: line protocol poorly formed and no points were written"); // // 401 @@ -809,7 +805,7 @@ void retryNotApplied() { error = listener.awaitCount(1).popValue(); Assertions.assertThat(error.getThrowable()) .isInstanceOf(UnauthorizedException.class) - .hasMessage("token does not have sufficient permissions to write to this organization and bucket or the organization and bucket do not exist"); + .hasMessage("HTTP status code: 401; Message: token does not have sufficient permissions to write to this organization and bucket or the organization and bucket do not exist"); // // 403 @@ -820,7 +816,7 @@ void retryNotApplied() { error = listener.awaitCount(1).popValue(); Assertions.assertThat(error.getThrowable()) .isInstanceOf(ForbiddenException.class) - .hasMessage("no token was sent and they are required"); + .hasMessage("HTTP status code: 403; Message: no token was sent and they are required"); // // 413 @@ -831,7 +827,7 @@ void retryNotApplied() { error = listener.awaitCount(1).popValue(); Assertions.assertThat(error.getThrowable()) .isInstanceOf(RequestEntityTooLargeException.class) - .hasMessage("write has been rejected because the payload is too large. Error message returns max size supported. All data in body was rejected and not written"); + .hasMessage("HTTP status code: 413; Message: write has been rejected because the payload is too large. Error message returns max size supported. All data in body was rejected and not written"); Assertions.assertThat(mockServer.getRequestCount()) .isEqualTo(4); @@ -887,7 +883,7 @@ public void retryContainsMessage() { Assertions.assertThat(records.get(0).getMessage()) .isEqualTo("The retriable error occurred during writing of data. Reason: ''{0}''. Retry in: {1}s."); Assertions.assertThat(records.get(0).getParameters()).hasSize(2); - Assertions.assertThat(records.get(0).getParameters()[0]).isEqualTo("org 04014de4ed590000 has exceeded limited_write plan limit"); + Assertions.assertThat(records.get(0).getParameters()[0]).isEqualTo("HTTP status code: 429; Message: org 04014de4ed590000 has exceeded limited_write plan limit"); Assertions.assertThat(records.get(0).getParameters()[1]).isEqualTo(5.0); }