use of com.torodb.core.exceptions.user.DatabaseNotFoundException in project torodb by torodb.
the class SimpleAnalyzedOplogBatchExecutorTest method testVisit_CudAnalyzedOplog_UserEx.
@Test
public void testVisit_CudAnalyzedOplog_UserEx() throws Exception {
//GIVEN
OplogOperation lastOp = mock(OplogOperation.class);
CudAnalyzedOplogBatch batch = mock(CudAnalyzedOplogBatch.class);
ApplierContext applierContext = new ApplierContext.Builder().setReapplying(true).setUpdatesAsUpserts(true).build();
given(batch.getOriginalBatch()).willReturn(Lists.newArrayList(mock(OplogOperation.class), mock(OplogOperation.class), mock(OplogOperation.class), lastOp));
Timer timer = mock(Timer.class);
Context context = mock(Context.class);
given(metrics.getCudBatchTimer()).willReturn(timer);
given(timer.time()).willReturn(context);
doThrow(new DatabaseNotFoundException("test")).when(executor).execute(eq(batch), any());
//WHEN
try {
executor.visit(batch, applierContext);
fail("An exception was expected");
} catch (RetrierGiveUpException | RetrierAbortException ignore) {
}
//THEN
then(metrics).should().getCudBatchTimer();
then(timer).should().time();
then(executor).should(times(1)).execute(batch, applierContext);
}
use of com.torodb.core.exceptions.user.DatabaseNotFoundException in project torodb by torodb.
the class SqlWriteTorodTransaction method getMetaDatabaseOrThrowException.
@Nonnull
protected MutableMetaDatabase getMetaDatabaseOrThrowException(@Nonnull String dbName) throws DatabaseNotFoundException {
MutableMetaSnapshot metaSnapshot = getInternalTransaction().getMetaSnapshot();
MutableMetaDatabase metaDb = metaSnapshot.getMetaDatabaseByName(dbName);
if (metaDb == null) {
throw new DatabaseNotFoundException(dbName);
}
return metaDb;
}
use of com.torodb.core.exceptions.user.DatabaseNotFoundException in project torodb by torodb.
the class SimpleAnalyzedOplogBatchExecutorTest method testVisit_SingleOp_UserEx.
@Test
public void testVisit_SingleOp_UserEx() throws Exception {
//GIVEN
OplogOperation operation = mock(OplogOperation.class);
SingleOpAnalyzedOplogBatch batch = new SingleOpAnalyzedOplogBatch(operation);
ApplierContext applierContext = new ApplierContext.Builder().setReapplying(true).setUpdatesAsUpserts(true).build();
Timer timer = mock(Timer.class);
Context context = mock(Context.class);
given(metrics.getSingleOpTimer(operation)).willReturn(timer);
given(timer.time()).willReturn(context);
doThrow(new DatabaseNotFoundException("test")).when(executor).execute(operation, applierContext);
//WHEN
try {
executor.visit(batch, applierContext);
fail("An exception was expected");
} catch (RetrierGiveUpException | RetrierAbortException ignore) {
}
//THEN
then(metrics).should().getSingleOpTimer(operation);
then(timer).should().time();
then(executor).should(times(1)).execute(operation, applierContext);
}
Aggregations