use of com.apple.foundationdb.record.RecordCoreException in project fdb-record-layer by FoundationDB.
the class ProbableIntersectionCursorTest method errorAndLimitInChild.
@Test
public void errorAndLimitInChild() {
CompletableFuture<Integer> future = new CompletableFuture<>();
RecordCursor<Integer> cursor = ProbableIntersectionCursor.create(Collections::singletonList, Arrays.asList(continuation -> RecordCursor.fromList(Arrays.asList(1, 2), continuation).limitRowsTo(1), continuation -> RecordCursor.fromFuture(future)), null, null);
CompletableFuture<RecordCursorResult<Integer>> cursorResultFuture = cursor.onNext();
final RecordCoreException ex = new RecordCoreException("something bad happened!");
future.completeExceptionally(ex);
ExecutionException executionException = assertThrows(ExecutionException.class, cursorResultFuture::get);
assertNotNull(executionException.getCause());
assertSame(ex, executionException.getCause());
}
use of com.apple.foundationdb.record.RecordCoreException in project fdb-record-layer by FoundationDB.
the class ProbableIntersectionCursorTest method errorInChild.
@Test
public void errorInChild() {
CompletableFuture<Integer> future = new CompletableFuture<>();
RecordCursor<Integer> cursor = ProbableIntersectionCursor.create(Collections::singletonList, Arrays.asList(continuation -> RecordCursor.fromList(Arrays.asList(1, 2), continuation), continuation -> RecordCursor.fromFuture(future)), null, null);
CompletableFuture<RecordCursorResult<Integer>> cursorResultFuture = cursor.onNext();
final RecordCoreException ex = new RecordCoreException("something bad happened!");
future.completeExceptionally(ex);
ExecutionException executionException = assertThrows(ExecutionException.class, cursorResultFuture::get);
assertNotNull(executionException.getCause());
assertSame(ex, executionException.getCause());
}
use of com.apple.foundationdb.record.RecordCoreException in project fdb-record-layer by FoundationDB.
the class UnorderedUnionCursorTest method errorAndLimitInChild.
@Test
public void errorAndLimitInChild() {
CompletableFuture<Integer> future = new CompletableFuture<>();
RecordCursor<Integer> cursor = UnorderedUnionCursor.create(Arrays.asList(continuation -> RecordCursor.fromList(Arrays.asList(1, 2), continuation).limitRowsTo(1), continuation -> RecordCursor.fromFuture(future)), null, null);
RecordCursorResult<Integer> cursorResult = cursor.getNext();
assertEquals(1, (int) cursorResult.get());
CompletableFuture<RecordCursorResult<Integer>> cursorResultFuture = cursor.onNext();
final RecordCoreException ex = new RecordCoreException("something bad happened!");
future.completeExceptionally(ex);
ExecutionException executionException = assertThrows(ExecutionException.class, cursorResultFuture::get);
assertNotNull(executionException.getCause());
assertSame(ex, executionException.getCause());
}
use of com.apple.foundationdb.record.RecordCoreException in project fdb-record-layer by FoundationDB.
the class UnorderedUnionCursorTest method errorInChild.
@Test
public void errorInChild() {
CompletableFuture<Integer> future = new CompletableFuture<>();
RecordCursor<Integer> cursor = UnorderedUnionCursor.create(Arrays.asList(continuation -> RecordCursor.fromList(Arrays.asList(1, 2), continuation), continuation -> RecordCursor.fromFuture(future)), null, null);
RecordCursorResult<Integer> cursorResult = cursor.getNext();
assertEquals(1, (int) cursorResult.get());
cursorResult = cursor.getNext();
assertEquals(2, (int) cursorResult.get());
CompletableFuture<RecordCursorResult<Integer>> cursorResultFuture = cursor.onNext();
final RecordCoreException ex = new RecordCoreException("something bad happened!");
future.completeExceptionally(ex);
ExecutionException executionException = assertThrows(ExecutionException.class, cursorResultFuture::get);
assertNotNull(executionException.getCause());
assertSame(ex, executionException.getCause());
}
use of com.apple.foundationdb.record.RecordCoreException in project fdb-record-layer by FoundationDB.
the class StringInterningLayerTest method testCreate.
@Test
void testCreate() {
try (FDBRecordContext context = database.openContext()) {
StringInterningLayer interningLayer = new StringInterningLayer(testSubspace);
String toIntern = "some-string";
byte[] metadata = Tuple.from("some-metadata").pack();
ResolverResult interned = interningLayer.create(context, toIntern, metadata).join();
assertArrayEquals(interned.getMetadata(), metadata, "we see the metadata with the interned value");
Optional<ResolverResult> maybeRead = interningLayer.read(context, toIntern).join();
assertIsPresentWithValue("we read the value", maybeRead, interned);
Optional<String> maybeReverseRead = interningLayer.readReverse(context, interned.getValue()).join();
assertIsPresentWithValue("the reverse lookup works", maybeReverseRead, toIntern);
try {
interningLayer.create(context, toIntern, null).join();
fail("should throw exception");
} catch (CompletionException ex) {
assertThat(ex.getCause(), is(instanceOf(RecordCoreException.class)));
assertThat(ex.getCause().getMessage(), containsString("value already exists in interning layer"));
RecordCoreException cause = (RecordCoreException) ex.getCause();
assertThat("exception log info has the key", cause.getLogInfo(), hasEntry("value", toIntern));
}
}
}
Aggregations