org.opendaylight.yangtools.util.concurrent.FluentFutures Java Examples

The following examples show how to use org.opendaylight.yangtools.util.concurrent.FluentFutures. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BridgeConfigReconciliationTaskTest.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    NodeKey nodeKey = new NodeKey(new NodeId(new Uri(NODE_ID)));

    iid = SouthboundMapper.createInstanceIdentifier(nodeKey.getNodeId());
    SouthboundProvider.setBridgesReconciliationInclusionList(Arrays.asList(BR_INT));
    Node brIntNode = createBridgeNode(NODE_ID + "/bridge/" + BR_INT);
    Optional<Node> nodeOptional = Optional.of(brIntNode);
    FluentFuture<Optional<Node>> readNodeFuture =
            FluentFutures.immediateFluentFuture(nodeOptional);
    when(reconciliationManager.getDb()).thenReturn(db);
    ReadTransaction tx = mock(ReadTransaction.class);
    Mockito.when(db.newReadOnlyTransaction()).thenReturn(tx);
    Mockito.when(tx.read(any(LogicalDatastoreType.class),any(InstanceIdentifier.class)))
            .thenReturn(readNodeFuture);

    when(topology.getNode()).thenReturn(Map.of(brIntNode.key(), brIntNode));

    configurationReconciliationTask =
            new BridgeConfigReconciliationTask(reconciliationManager, ovsdbConnectionManager, iid,
                    ovsdbConnectionInstance, mock(InstanceIdentifierCodec.class));
}
 
Example #2
Source File: AbstractRIBTestSetup.java    From bgpcep with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void mockedMethods() throws Exception {
    MockitoAnnotations.initMocks(this);
    final ReadTransaction readTx = mock(ReadTransaction.class);
    doReturn(new TestListenerRegistration()).when(this.service)
            .registerDataTreeChangeListener(any(DOMDataTreeIdentifier.class),
                    any(ClusteredDOMDataTreeChangeListener.class));
    doNothing().when(readTx).close();
    doNothing().when(this.domTransWrite).put(eq(LogicalDatastoreType.OPERATIONAL),
            any(YangInstanceIdentifier.class), any(NormalizedNode.class));
    doNothing().when(this.domTransWrite).delete(eq(LogicalDatastoreType.OPERATIONAL),
            any(YangInstanceIdentifier.class));
    doNothing().when(this.domTransWrite).merge(eq(LogicalDatastoreType.OPERATIONAL),
            any(YangInstanceIdentifier.class), any(NormalizedNode.class));
    doReturn(FluentFutures.immediateFluentFuture(Optional.empty())).when(readTx)
        .read(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class));
    doNothing().when(this.domChain).close();
    doReturn(this.domTransWrite).when(this.domChain).newWriteOnlyTransaction();
    doNothing().when(getTransaction()).put(eq(LogicalDatastoreType.OPERATIONAL),
            eq(YangInstanceIdentifier.of(BgpRib.QNAME)), any(NormalizedNode.class));
    doReturn(ImmutableClassToInstanceMap.of(DOMDataTreeChangeService.class, this.service)).when(this.dom)
        .getExtensions();
    doReturn(this.domChain).when(this.dom).createMergingTransactionChain(any(AbstractPeer.class));
    doReturn(this.transWrite).when(this.chain).newWriteOnlyTransaction();
    doReturn(Optional.empty()).when(this.future).get();
    doReturn(this.future).when(this.domTransWrite).commit();
    doNothing().when(this.future).addListener(any(Runnable.class), any(Executor.class));
    doNothing().when(this.transWrite).mergeParentStructurePut(eq(LogicalDatastoreType.OPERATIONAL),
            any(InstanceIdentifier.class), any(DataObject.class));
    doNothing().when(this.transWrite).put(eq(LogicalDatastoreType.OPERATIONAL),
            any(InstanceIdentifier.class), any(DataObject.class));
    doReturn(this.future).when(this.transWrite).commit();
}
 
Example #3
Source File: InMemorySchemaSourceCache.java    From yangtools with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public FluentFuture<? extends T> getSource(final SourceIdentifier sourceIdentifier) {
    final T present = cache.getIfPresent(sourceIdentifier);
    return present != null ? FluentFutures.immediateFluentFuture(present)
            : FluentFutures.immediateFailedFluentFuture(new MissingSchemaSourceException("Source not found",
                sourceIdentifier));
}
 
Example #4
Source File: MdsalUtilsTest.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testRead() {
    ReadTransaction readTransaction = mock(ReadTransaction.class);
    doReturn(readTransaction).when(databroker).newReadOnlyTransaction();
    DataObject obj = mock(DataObject.class);
    doReturn(FluentFutures.immediateFluentFuture(Optional.of(obj))).when(readTransaction).read(
        any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
    DataObject result = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, mock(InstanceIdentifier.class));

    verify(readTransaction, times(1)).read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
    verify(readTransaction, times(1)).close();

    assertEquals("Error, the read transaction failed", obj, result);
}
 
Example #5
Source File: SchemaSourceFilter.java    From yangtools with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public FluentFuture<Boolean> apply(final SchemaSourceRepresentation schemaSource) {
    return FluentFutures.immediateTrueFluentFuture();
}