Java Code Examples for org.opendaylight.yangtools.util.concurrent.FluentFutures#immediateFluentFuture()

The following examples show how to use org.opendaylight.yangtools.util.concurrent.FluentFutures#immediateFluentFuture() . 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: 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));
}