@Test public void testAddPhysicalLink() throws Exception { final PhysicalLink physicalLink = mock(PhysicalLink.class); WriteTransaction writeTransaction = mock(WriteTransaction.class); CheckedFuture checkedFuture = mock(CheckedFuture.class); PhysicalLinkKey physicalLinkKey = mock(PhysicalLinkKey.class); Class<DataBrokerAdapter> class1 = DataBrokerAdapter.class; Method method = class1.getDeclaredMethod("addPhysicalLink",new Class[]{PhysicalLink.class}); method.setAccessible(true); when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction); when(physicalLink.getKey()).thenReturn(physicalLinkKey); when(writeTransaction.submit()).thenReturn(checkedFuture); method.invoke(dataBrokerAdapter, physicalLink); verify(dataBroker).newWriteOnlyTransaction(); verify(physicalLink).getKey(); verify(writeTransaction).submit(); }
protected void addPhysicalLink(final PhysicalLink physicalLink){ try { WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); final InstanceIdentifier<PhysicalLink> linkIdentifier = getPhysicalLinkIdentifier(physicalLink.getKey()); transaction.put(LogicalDatastoreType.OPERATIONAL, linkIdentifier, physicalLink, true); CheckedFuture<Void, TransactionCommitFailedException> f = transaction.submit(); Futures.addCallback(f, new FutureCallback<Void>() { @Override public void onFailure(Throwable t) { log.warn("Could not put PhysicalLink {} : {}",physicalLink.getKey(), t); } @Override public void onSuccess(Void result) { log.debug("Put transaction onSuccess:{}.",physicalLink.getKey()); } }); } catch (Exception e) { log.error("Exception:",e); } }
DataBrokerAdapter { protected void addPhysicalLink(final PhysicalLink physicalLink){ try { WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); final InstanceIdentifier<PhysicalLink> linkIdentifier = getPhysicalLinkIdentifier(physicalLink.getKey()); transaction.put(LogicalDatastoreType.OPERATIONAL, linkIdentifier, physicalLink, true); CheckedFuture<Void, TransactionCommitFailedException> f = transaction.submit(); Futures.addCallback(f, new FutureCallback<Void>() { @Override public void onFailure(Throwable t) { log.warn("Could not put PhysicalLink {} : {}",physicalLink.getKey(), t); } @Override public void onSuccess(Void result) { log.debug("Put transaction onSuccess:{}.",physicalLink.getKey()); } }); } catch (Exception e) { log.error("Exception:",e); } } }
DataBrokerAdapter { protected void addPhysicalLink(final PhysicalLink physicalLink){ try { WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); final InstanceIdentifier<PhysicalLink> linkIdentifier = getPhysicalLinkIdentifier(physicalLink.getKey()); transaction.put(LogicalDatastoreType.OPERATIONAL, linkIdentifier, physicalLink, true); CheckedFuture<Void, TransactionCommitFailedException> f = transaction.submit(); Futures.addCallback(f, new FutureCallback<Void>() { @Override public void onFailure(Throwable t) { log.warn("Could not put PhysicalLink {} : {}",physicalLink.getKey(), t); } @Override public void onSuccess(Void result) { log.debug("Put transaction onSuccess:{}.",physicalLink.getKey()); } }); } catch (Exception e) { log.error("Exception:",e); } } DataBrokerAdapter(DataBroker dataBroker); }
DataBrokerAdapter { protected void addPhysicalLink(final PhysicalLink physicalLink){ try { WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); final InstanceIdentifier<PhysicalLink> linkIdentifier = getPhysicalLinkIdentifier(physicalLink.getKey()); transaction.put(LogicalDatastoreType.OPERATIONAL, linkIdentifier, physicalLink, true); CheckedFuture<Void, TransactionCommitFailedException> f = transaction.submit(); Futures.addCallback(f, new FutureCallback<Void>() { @Override public void onFailure(Throwable t) { log.warn("Could not put PhysicalLink {} : {}",physicalLink.getKey(), t); } @Override public void onSuccess(Void result) { log.debug("Put transaction onSuccess:{}.",physicalLink.getKey()); } }); } catch (Exception e) { log.error("Exception:",e); } } DataBrokerAdapter(DataBroker dataBroker);  }
DataBrokerAdapter { protected void addPhysicalLink(final PhysicalLink physicalLink){ try { WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); final InstanceIdentifier<PhysicalLink> linkIdentifier = getPhysicalLinkIdentifier(physicalLink.getKey()); transaction.put(LogicalDatastoreType.OPERATIONAL, linkIdentifier, physicalLink, true); CheckedFuture<Void, TransactionCommitFailedException> f = transaction.submit(); Futures.addCallback(f, new FutureCallback<Void>() { @Override public void onFailure(Throwable t) { log.warn("Could not put PhysicalLink {} : {}",physicalLink.getKey(), t); } @Override public void onSuccess(Void result) { log.debug("Put transaction onSuccess:{}.",physicalLink.getKey()); } }); } catch (Exception e) { log.error("Exception:",e); } } DataBrokerAdapter(DataBroker dataBroker);   }