com.google.common.util.concurrent.CheckedFuture

Here are the examples of the java api class com.google.common.util.concurrent.CheckedFuture taken from open source projects.

1. EventSourceTopicTest#setUp()

View license
@Before
public void setUp() throws Exception {
    NotificationPattern notificationPattern = new NotificationPattern("value1");
    eventSourceServiceMock = mock(EventSourceService.class);
    eventSourceTopologyMock = mock(EventSourceTopology.class);
    dataBrokerMock = mock(DataBroker.class);
    doReturn(eventSourceServiceMock).when(eventSourceTopologyMock).getEventSourceService();
    doReturn(dataBrokerMock).when(eventSourceTopologyMock).getDataBroker();
    WriteTransaction writeTransactionMock = mock(WriteTransaction.class);
    doReturn(writeTransactionMock).when(dataBrokerMock).newWriteOnlyTransaction();
    doNothing().when(writeTransactionMock).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(DataObject.class), eq(true));
    CheckedFuture checkedFutureWriteMock = mock(CheckedFuture.class);
    doReturn(checkedFutureWriteMock).when(writeTransactionMock).submit();
    ReadOnlyTransaction readOnlyTransactionMock = mock(ReadOnlyTransaction.class);
    doReturn(readOnlyTransactionMock).when(dataBrokerMock).newReadOnlyTransaction();
    CheckedFuture checkedFutureReadMock = mock(CheckedFuture.class);
    doReturn(checkedFutureReadMock).when(readOnlyTransactionMock).read(LogicalDatastoreType.OPERATIONAL, EventSourceTopology.EVENT_SOURCE_TOPOLOGY_PATH);
    eventSourceTopic = EventSourceTopic.create(notificationPattern, "nodeIdPattern1", eventSourceTopologyMock);
}

2. MessageBusAppImplModuleTest#createInstanceTest()

View license
@Test
public void createInstanceTest() throws Exception {
    org.opendaylight.controller.sal.binding.api.BindingAwareBroker bindingAwareBrokerMock = mock(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.class);
    Broker brokerMock = mock(Broker.class);
    doReturn(brokerMock).when(dependencyResolverMock).resolveInstance(eq(org.opendaylight.controller.sal.core.api.Broker.class), any(ObjectName.class), any(JmxAttribute.class));
    doReturn(bindingAwareBrokerMock).when(dependencyResolverMock).resolveInstance(eq(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class));
    messageBusAppImplModule.resolveDependencies();
    BindingAwareBroker.ProviderContext providerContext = mock(BindingAwareBroker.ProviderContext.class);
    doReturn(providerContext).when(bindingAwareBrokerMock).registerProvider(any(BindingAwareProvider.class));
    Broker.ProviderSession providerSessionMock = mock(Broker.ProviderSession.class);
    doReturn(providerSessionMock).when(brokerMock).registerProvider(any(Provider.class));
    DataBroker dataBrokerMock = mock(DataBroker.class);
    doReturn(dataBrokerMock).when(providerContext).getSALService(eq(DataBroker.class));
    DOMNotificationPublishService domNotificationPublishServiceMock = mock(DOMNotificationPublishService.class);
    doReturn(domNotificationPublishServiceMock).when(providerSessionMock).getService(DOMNotificationPublishService.class);
    DOMMountPointService domMountPointServiceMock = mock(DOMMountPointService.class);
    doReturn(domMountPointServiceMock).when(providerSessionMock).getService(DOMMountPointService.class);
    MountPointService mountPointServiceMock = mock(MountPointService.class);
    doReturn(mountPointServiceMock).when(providerContext).getSALService(eq(MountPointService.class));
    RpcProviderRegistry rpcProviderRegistryMock = mock(RpcProviderRegistry.class);
    doReturn(rpcProviderRegistryMock).when(providerContext).getSALService(eq(RpcProviderRegistry.class));
    WriteTransaction writeTransactionMock = mock(WriteTransaction.class);
    doReturn(writeTransactionMock).when(dataBrokerMock).newWriteOnlyTransaction();
    doNothing().when(writeTransactionMock).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(DataObject.class), eq(true));
    CheckedFuture checkedFutureMock = mock(CheckedFuture.class);
    doReturn(checkedFutureMock).when(writeTransactionMock).submit();
    assertNotNull("EventSourceRegistryWrapper has not been created correctly.", messageBusAppImplModule.createInstance());
}

3. EventSourceTopologyTest#constructorTestHelper()

View license
private void constructorTestHelper() {
    aggregatorRpcReg = mock(RpcRegistration.class);
    EventSourceService eventSourceService = mock(EventSourceService.class);
    doReturn(aggregatorRpcReg).when(rpcProviderRegistryMock).addRpcImplementation(eq(EventAggregatorService.class), any(EventSourceTopology.class));
    doReturn(eventSourceService).when(rpcProviderRegistryMock).getRpcService(EventSourceService.class);
    WriteTransaction writeTransactionMock = mock(WriteTransaction.class);
    doReturn(writeTransactionMock).when(dataBrokerMock).newWriteOnlyTransaction();
    doNothing().when(writeTransactionMock).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(DataObject.class), eq(true));
    CheckedFuture checkedFutureMock = mock(CheckedFuture.class);
    doReturn(checkedFutureMock).when(writeTransactionMock).submit();
}

4. EventSourceTopologyTest#topicTestHelper()

View license
private void topicTestHelper() throws Exception {
    constructorTestHelper();
    createTopicInputMock = mock(CreateTopicInput.class);
    eventSourceTopology = new EventSourceTopology(dataBrokerMock, rpcProviderRegistryMock);
    NotificationPattern notificationPattern = new NotificationPattern("value1");
    doReturn(notificationPattern).when(createTopicInputMock).getNotificationPattern();
    Pattern pattern = new Pattern("valuePattern1");
    doReturn(pattern).when(createTopicInputMock).getNodeIdPattern();
    listenerRegistrationMock = mock(ListenerRegistration.class);
    doReturn(listenerRegistrationMock).when(dataBrokerMock).registerDataChangeListener(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class), any(EventSourceTopic.class), eq(DataBroker.DataChangeScope.SUBTREE));
    ReadOnlyTransaction readOnlyTransactionMock = mock(ReadOnlyTransaction.class);
    doReturn(readOnlyTransactionMock).when(dataBrokerMock).newReadOnlyTransaction();
    CheckedFuture checkedFutureMock = mock(CheckedFuture.class);
    doReturn(checkedFutureMock).when(readOnlyTransactionMock).read(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class));
    Optional optionalMock = mock(Optional.class);
    doReturn(optionalMock).when(checkedFutureMock).checkedGet();
    doReturn(true).when(optionalMock).isPresent();
    Topology topologyMock = mock(Topology.class);
    doReturn(topologyMock).when(optionalMock).get();
    Node nodeMock = mock(Node.class);
    List<Node> nodeList = new ArrayList<>();
    nodeList.add(nodeMock);
    doReturn(nodeList).when(topologyMock).getNode();
    NodeId nodeId = new NodeId("nodeIdValue1");
    doReturn(nodeId).when(nodeMock).getNodeId();
}