@Test public void testAdaptedWriteTransactionFailsOnInvalidDatastore() throws Exception { Future<?> future = managedNewTransactionRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, writeTx -> TransactionAdapter.toWriteTransaction(writeTx).put(LogicalDatastoreType.CONFIGURATION, TEST_PATH, newTestDataObject())); ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get()); assertThat(ex.getCause(), instanceOf(IllegalArgumentException.class)); assertEquals(Optional.empty(), syncReadOptional(LogicalDatastoreType.OPERATIONAL, TEST_PATH)); }
public static WriteTransaction toWriteTransaction(final TypedWriteTransaction<? extends Datastore> datastoreTx) { if (datastoreTx instanceof TypedWriteTransactionImpl) { final TypedWriteTransactionImpl<?, ?> txImpl = (TypedWriteTransactionImpl<?, ?>) datastoreTx; return new WriteTransactionAdapter<>(txImpl.getDatastoreType(), txImpl); } throw new IllegalArgumentException("Unsupported TypedWriteTransaction implementation " + datastoreTx.getClass()); }
TransactionAdapter { public static WriteTransaction toWriteTransaction(final TypedWriteTransaction<? extends Datastore> datastoreTx) { if (datastoreTx instanceof TypedWriteTransactionImpl) { final TypedWriteTransactionImpl<?, ?> txImpl = (TypedWriteTransactionImpl<?, ?>) datastoreTx; return new WriteTransactionAdapter<>(txImpl.getDatastoreType(), txImpl); } throw new IllegalArgumentException("Unsupported TypedWriteTransaction implementation " + datastoreTx.getClass()); } }
TransactionAdapter { public static WriteTransaction toWriteTransaction(final TypedWriteTransaction<? extends Datastore> datastoreTx) { if (datastoreTx instanceof TypedWriteTransactionImpl) { final TypedWriteTransactionImpl<?, ?> txImpl = (TypedWriteTransactionImpl<?, ?>) datastoreTx; return new WriteTransactionAdapter<>(txImpl.getDatastoreType(), txImpl); } throw new IllegalArgumentException("Unsupported TypedWriteTransaction implementation " + datastoreTx.getClass()); } private  TransactionAdapter(); }
TransactionAdapter { public static WriteTransaction toWriteTransaction(final TypedWriteTransaction<? extends Datastore> datastoreTx) { if (datastoreTx instanceof TypedWriteTransactionImpl) { final TypedWriteTransactionImpl<?, ?> txImpl = (TypedWriteTransactionImpl<?, ?>) datastoreTx; return new WriteTransactionAdapter<>(txImpl.getDatastoreType(), txImpl); } throw new IllegalArgumentException("Unsupported TypedWriteTransaction implementation " + datastoreTx.getClass()); } private  TransactionAdapter(); static ReadWriteTransaction toReadWriteTransaction(
            final TypedReadWriteTransaction<? extends Datastore> datastoreTx); static WriteTransaction toWriteTransaction(final TypedWriteTransaction<? extends Datastore> datastoreTx); }
TransactionAdapter { public static WriteTransaction toWriteTransaction(final TypedWriteTransaction<? extends Datastore> datastoreTx) { if (datastoreTx instanceof TypedWriteTransactionImpl) { final TypedWriteTransactionImpl<?, ?> txImpl = (TypedWriteTransactionImpl<?, ?>) datastoreTx; return new WriteTransactionAdapter<>(txImpl.getDatastoreType(), txImpl); } throw new IllegalArgumentException("Unsupported TypedWriteTransaction implementation " + datastoreTx.getClass()); } private  TransactionAdapter(); static ReadWriteTransaction toReadWriteTransaction(
            final TypedReadWriteTransaction<? extends Datastore> datastoreTx); static WriteTransaction toWriteTransaction(final TypedWriteTransaction<? extends Datastore> datastoreTx);  }