@Test public void testMergeSynchronous() throws Exception { WriteTransaction transaction = mock(WriteTransaction.class); doReturn(CommitInfo.emptyFluentFuture()).when(transaction).commit(); InstanceIdentifier identifier = mock(InstanceIdentifier.class); DataObject dataObject = mock(DataObject.class); when(transactionChain.newWriteOnlyTransaction()).thenReturn(transaction); assertTrue(access.mergeSynchronous(identifier, dataObject, LogicalDatastoreType.OPERATIONAL)); verify(transaction).merge(LogicalDatastoreType.OPERATIONAL, identifier, dataObject); doReturn(FluentFutures.immediateFailedFluentFuture(new ExecutionException(new NullPointerException()))) .when(transaction).commit(); assertFalse(access.mergeSynchronous(identifier, dataObject, LogicalDatastoreType.OPERATIONAL)); }
public synchronized <T extends DataObject> boolean mergeSynchronous( final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType) { LOG.debug("Merge {}", path); try { merge(path, data, logicalDatastoreType).get(); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to merge {} to {}", path, logicalDatastoreType, e); return false; } catch (final ExecutionException e) { LOG.error("Failed to merge {} to {}", path, logicalDatastoreType, e); return false; } return true; }
DatastoreAccess implements AutoCloseable { public synchronized <T extends DataObject> boolean mergeSynchronous( final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType) { LOG.debug("Merge {}", path); try { merge(path, data, logicalDatastoreType).get(); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to merge {} to {}", path, logicalDatastoreType, e); return false; } catch (final ExecutionException e) { LOG.error("Failed to merge {} to {}", path, logicalDatastoreType, e); return false; } return true; } }
DatastoreAccess implements AutoCloseable { public synchronized <T extends DataObject> boolean mergeSynchronous( final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType) { LOG.debug("Merge {}", path); try { merge(path, data, logicalDatastoreType).get(); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to merge {} to {}", path, logicalDatastoreType, e); return false; } catch (final ExecutionException e) { LOG.error("Failed to merge {} to {}", path, logicalDatastoreType, e); return false; } return true; } private  DatastoreAccess(final DataBroker dataBroker); }
DatastoreAccess implements AutoCloseable { public synchronized <T extends DataObject> boolean mergeSynchronous( final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType) { LOG.debug("Merge {}", path); try { merge(path, data, logicalDatastoreType).get(); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to merge {} to {}", path, logicalDatastoreType, e); return false; } catch (final ExecutionException e) { LOG.error("Failed to merge {} to {}", path, logicalDatastoreType, e); return false; } return true; } private  DatastoreAccess(final DataBroker dataBroker); static DatastoreAccess getInstance(final DataBroker dataBroker); static DatastoreAccess getInstance(final DatastoreAccess datastoreAccess); synchronized FluentFuture<? extends CommitInfo> delete(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized FluentFuture<? extends CommitInfo> merge(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized FluentFuture<? extends CommitInfo> put(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized FluentFuture<java.util.Optional<T>> read(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized boolean mergeSynchronous(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized boolean putSynchronous(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized boolean deleteSynchronous(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized T readSynchronous(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized boolean checkAndPut(
            final InstanceIdentifier<T> identifier, final T data, final LogicalDatastoreType datastoreType,
            final boolean isUpdating); synchronized boolean checkAndMerge(
            final InstanceIdentifier<T> identifier, final T data, final LogicalDatastoreType datastoreType,
            final boolean isUpdating); synchronized boolean checkAndDelete(
            final InstanceIdentifier<T> identifier, final LogicalDatastoreType datastoreType); synchronized boolean putIfNotExists(
            final InstanceIdentifier<T> identifier, final T data, final LogicalDatastoreType datastoreType); synchronized void reinitializeChain(); @Override synchronized void close(); }
DatastoreAccess implements AutoCloseable { public synchronized <T extends DataObject> boolean mergeSynchronous( final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType) { LOG.debug("Merge {}", path); try { merge(path, data, logicalDatastoreType).get(); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to merge {} to {}", path, logicalDatastoreType, e); return false; } catch (final ExecutionException e) { LOG.error("Failed to merge {} to {}", path, logicalDatastoreType, e); return false; } return true; } private  DatastoreAccess(final DataBroker dataBroker); static DatastoreAccess getInstance(final DataBroker dataBroker); static DatastoreAccess getInstance(final DatastoreAccess datastoreAccess); synchronized FluentFuture<? extends CommitInfo> delete(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized FluentFuture<? extends CommitInfo> merge(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized FluentFuture<? extends CommitInfo> put(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized FluentFuture<java.util.Optional<T>> read(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized boolean mergeSynchronous(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized boolean putSynchronous(
            final InstanceIdentifier<T> path, final T data, final LogicalDatastoreType logicalDatastoreType); synchronized boolean deleteSynchronous(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized T readSynchronous(
            final InstanceIdentifier<T> path, final LogicalDatastoreType logicalDatastoreType); synchronized boolean checkAndPut(
            final InstanceIdentifier<T> identifier, final T data, final LogicalDatastoreType datastoreType,
            final boolean isUpdating); synchronized boolean checkAndMerge(
            final InstanceIdentifier<T> identifier, final T data, final LogicalDatastoreType datastoreType,
            final boolean isUpdating); synchronized boolean checkAndDelete(
            final InstanceIdentifier<T> identifier, final LogicalDatastoreType datastoreType); synchronized boolean putIfNotExists(
            final InstanceIdentifier<T> identifier, final T data, final LogicalDatastoreType datastoreType); synchronized void reinitializeChain(); @Override synchronized void close();  }