|
7 | 7 | import io.tarantool.driver.core.ProxyTarantoolTupleClient;
|
8 | 8 | import io.tarantool.driver.exceptions.TarantoolAccessDeniedException;
|
9 | 9 | import io.tarantool.driver.exceptions.TarantoolClientException;
|
| 10 | +import io.tarantool.driver.exceptions.TarantoolEmptyMetadataException; |
| 11 | +import io.tarantool.driver.exceptions.TarantoolFunctionCallException; |
10 | 12 | import io.tarantool.driver.exceptions.TarantoolInternalException;
|
11 | 13 | import io.tarantool.driver.exceptions.TarantoolInternalNetworkException;
|
| 14 | +import io.tarantool.driver.exceptions.TarantoolMetadataRequestException; |
12 | 15 | import io.tarantool.driver.exceptions.TarantoolNoSuchProcedureException;
|
| 16 | +import io.tarantool.driver.exceptions.TarantoolSpaceNotFoundException; |
| 17 | + |
13 | 18 | import org.junit.jupiter.api.BeforeAll;
|
14 | 19 | import org.junit.jupiter.api.Test;
|
15 | 20 |
|
@@ -213,4 +218,40 @@ void test_should_throwTarantoolAccessDenied_ifUserHasRestrictions() {
|
213 | 218 | assertTrue(cause.getMessage()
|
214 | 219 | .contains("Execute access to function 'ddl.get_schema' is denied for user 'restricted_user'"));
|
215 | 220 | }
|
| 221 | + |
| 222 | + @Test |
| 223 | + void test_failedToRefreshMetadata_shouldHasReasonOfException_ifDdlReturnNull() { |
| 224 | + ProxyTarantoolTupleClient adminClient = setupAdminClient(); |
| 225 | + |
| 226 | + adminClient.eval("true_ddl = ddl; " + |
| 227 | + "ddl = {get_schema = function() return nil end}").join(); |
| 228 | + |
| 229 | + TarantoolClientException exception = assertThrows(TarantoolClientException.class, |
| 230 | + () -> adminClient.space("test_space").select(Conditions.any())); |
| 231 | + assertEquals("Failed to refresh spaces and indexes metadata", exception.getMessage()); |
| 232 | + Throwable cause = exception.getCause(); |
| 233 | + assertEquals(TarantoolEmptyMetadataException.class, cause.getClass()); |
| 234 | + assertEquals("No space metadata returned", cause.getMessage()); |
| 235 | + adminClient.eval("ddl = true_ddl").join(); |
| 236 | + } |
| 237 | + |
| 238 | + @Test |
| 239 | + void test_failedToRefreshMetadata_shouldHasReasonOfException_ifDdlReturnEmptyTable() { |
| 240 | + ProxyTarantoolTupleClient adminClient = setupAdminClient(); |
| 241 | + |
| 242 | + adminClient.eval("true_ddl = ddl; " + |
| 243 | + "ddl = {get_schema = function() return {} end}").join(); |
| 244 | + |
| 245 | + TarantoolClientException exception = assertThrows(TarantoolClientException.class, |
| 246 | + () -> adminClient.space("test_space").select(Conditions.any())); |
| 247 | + assertEquals("Failed to refresh spaces and indexes metadata", exception.getMessage()); |
| 248 | + Throwable cause = exception.getCause(); |
| 249 | + assertEquals(TarantoolMetadataRequestException.class, cause.getClass()); |
| 250 | + cause = cause.getCause(); |
| 251 | + assertEquals(CompletionException.class, cause.getClass()); |
| 252 | + cause = cause.getCause(); |
| 253 | + assertEquals(TarantoolEmptyMetadataException.class, cause.getClass()); |
| 254 | + assertEquals("No space metadata returned", cause.getMessage()); |
| 255 | + adminClient.eval("ddl = true_ddl").join(); |
| 256 | + } |
216 | 257 | }
|
0 commit comments