Search in sources :

Example 1 with OpendaylightOfMigrationTestModelService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.OpendaylightOfMigrationTestModelService in project controller by opendaylight.

the class CrossBrokerRpcTest method bindingRpcInvoker_DomRoutedProviderTest.

@Test
public void bindingRpcInvoker_DomRoutedProviderTest() throws Exception {
    KnockKnockOutputBuilder builder = new KnockKnockOutputBuilder();
    builder.setAnswer("open");
    final KnockKnockOutput output = builder.build();
    provisionRegistry.registerRpcImplementation((rpc, input) -> {
        ContainerNode result = testContext.getCodec().getCodecFactory().toNormalizedNodeRpcData(output);
        return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result));
    }, DOMRpcIdentifier.create(KNOCK_KNOCK_PATH, BI_NODE_C_ID));
    OpendaylightOfMigrationTestModelService baKnockInvoker = providerRegistry.getRpcService(OpendaylightOfMigrationTestModelService.class);
    Future<RpcResult<KnockKnockOutput>> baResult = baKnockInvoker.knockKnock((knockKnock(BA_NODE_C_ID).setQuestion("Who's there?").build()));
    assertNotNull(baResult);
    assertEquals(output, baResult.get().getResult());
}
Also used : DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) KnockKnockOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutputBuilder) KnockKnockOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutput) DOMRpcResult(org.opendaylight.controller.md.sal.dom.api.DOMRpcResult) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) OpendaylightOfMigrationTestModelService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.OpendaylightOfMigrationTestModelService) Test(org.junit.Test)

Example 2 with OpendaylightOfMigrationTestModelService

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.OpendaylightOfMigrationTestModelService in project controller by opendaylight.

the class CrossBrokerRpcTest method bindingRoutedRpcProvider_DomInvokerTest.

@Test
public void bindingRoutedRpcProvider_DomInvokerTest() throws Exception {
    // 
    knockService.registerPath(TestContext.class, // 
    BA_NODE_A_ID).registerPath(TestContext.class, // 
    BA_NODE_B_ID).setKnockKnockResult(knockResult(true, "open"));
    OpendaylightOfMigrationTestModelService baKnockInvoker = providerRegistry.getRpcService(OpendaylightOfMigrationTestModelService.class);
    assertNotSame(knockService, baKnockInvoker);
    KnockKnockInput knockKnockA = // 
    knockKnock(BA_NODE_A_ID).setQuestion("who's there?").build();
    ContainerNode knockKnockDom = toDomRpc(KNOCK_KNOCK_QNAME, knockKnockA);
    assertNotNull(knockKnockDom);
    DOMRpcResult domResult = biRpcInvoker.invokeRpc(KNOCK_KNOCK_PATH, knockKnockDom).get();
    assertNotNull(domResult);
    assertNotNull("DOM result is successful.", domResult.getResult());
    assertTrue("Bidning Add Flow RPC was captured.", knockService.getReceivedKnocks().containsKey(BA_NODE_A_ID));
    assertEquals(knockKnockA, knockService.getReceivedKnocks().get(BA_NODE_A_ID).iterator().next());
}
Also used : DOMRpcResult(org.opendaylight.controller.md.sal.dom.api.DOMRpcResult) DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) BindingTestContext(org.opendaylight.controller.sal.binding.test.util.BindingTestContext) TestContext(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.TestContext) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) OpendaylightOfMigrationTestModelService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.OpendaylightOfMigrationTestModelService) KnockKnockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockInput) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 DOMRpcResult (org.opendaylight.controller.md.sal.dom.api.DOMRpcResult)2 DefaultDOMRpcResult (org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult)2 OpendaylightOfMigrationTestModelService (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.OpendaylightOfMigrationTestModelService)2 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)2 BindingTestContext (org.opendaylight.controller.sal.binding.test.util.BindingTestContext)1 KnockKnockInput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockInput)1 KnockKnockOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutput)1 KnockKnockOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutputBuilder)1 TestContext (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.TestContext)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1