use of io.dapr.exceptions.DaprException in project java-sdk by dapr.
the class MethodInvokeIT method testInvokeException.
@Test
public void testInvokeException() throws Exception {
try (DaprClient client = new DaprClientBuilder().build()) {
MethodInvokeServiceProtos.SleepRequest req = MethodInvokeServiceProtos.SleepRequest.newBuilder().setSeconds(-9).build();
DaprException exception = assertThrows(DaprException.class, () -> client.invokeMethod(daprRun.getAppName(), "sleep", -9, HttpExtension.POST).block());
assertEquals("UNKNOWN", exception.getErrorCode());
assertNotNull(exception.getMessage());
assertTrue(exception.getMessage().contains("Internal Server Error"));
}
}
use of io.dapr.exceptions.DaprException in project java-sdk by dapr.
the class AbstractStateClientIT method testInvalidEtag.
@Test
public void testInvalidEtag() {
DaprClient daprClient = buildDaprClient();
DaprException exception = assertThrows(DaprException.class, () -> daprClient.saveState(STATE_STORE_NAME, "myKey", "badEtag", "value", null).block());
assertNotNull(exception.getMessage());
// This will assert that eTag is parsed correctly and is not corrupted. The quotation from runtime helps here.
assertTrue(exception.getMessage().contains("\"badEtag\""));
}
use of io.dapr.exceptions.DaprException in project java-sdk by dapr.
the class TestUtils method assertThrowsDaprException.
public static <T extends Throwable> void assertThrowsDaprException(String expectedErrorCode, String expectedErrorMessage, Executable executable) {
DaprException daprException = Assertions.assertThrows(DaprException.class, executable);
Assertions.assertEquals(expectedErrorCode, daprException.getErrorCode());
Assertions.assertEquals(expectedErrorMessage, daprException.getMessage());
}
use of io.dapr.exceptions.DaprException in project java-sdk by dapr.
the class TestUtils method assertThrowsDaprExceptionSubstring.
public static <T extends Throwable> void assertThrowsDaprExceptionSubstring(String expectedErrorCode, String expectedErrorMessageSubstring, Executable executable) {
DaprException daprException = Assertions.assertThrows(DaprException.class, executable);
Assertions.assertEquals(expectedErrorCode, daprException.getErrorCode());
Assertions.assertTrue(daprException.getMessage().contains(expectedErrorMessageSubstring));
}
use of io.dapr.exceptions.DaprException in project java-sdk by dapr.
the class TestUtils method assertThrowsDaprException.
public static void assertThrowsDaprException(String expectedErrorCode, String expectedErrorMessage, Executable executable) {
DaprException daprException = Assertions.assertThrows(DaprException.class, executable);
Assertions.assertNull(daprException.getCause());
Assertions.assertEquals(expectedErrorCode, daprException.getErrorCode());
Assertions.assertEquals(expectedErrorMessage, daprException.getMessage());
}
Aggregations