package org.opendaylight.mdsal.dom.spi;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNull;
-import com.google.common.collect.Iterables;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.AfterClass;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.yang.extension.yang.ext.rev130709.$YangModuleInfoImpl;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.stmt.RpcEffectiveStatement;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class RpcRoutingStrategyTest {
+public class ContentRoutedRpcContextTest {
private static List<RpcEffectiveStatement> RPCS;
@BeforeClass
public static void beforeClass() {
- final EffectiveModelContext ctx = YangParserTestUtils.parseYangSources(YangParserConfiguration.DEFAULT, null,
+ final var ctx = YangParserTestUtils.parseYangSources(YangParserConfiguration.DEFAULT, null,
YangTextSchemaSource.delegateForByteSource("yang-ext.yang",
$YangModuleInfoImpl.getInstance().getYangTextByteSource()),
- YangTextSchemaSource.forResource(RpcRoutingStrategy.class, "/rpc-routing-strategy.yang"));
+ YangTextSchemaSource.forResource(ContentRoutedRpcContext.class, "/rpc-routing-strategy.yang"));
- RPCS = Iterables.getOnlyElement(ctx.findModuleStatements("foo"))
+ RPCS = ctx.findModuleStatements("foo").iterator().next()
.streamEffectiveSubstatements(RpcEffectiveStatement.class)
.collect(Collectors.toUnmodifiableList());
}
@Test
public void unroutedRpcStrategyTest() {
- final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(Iterables.get(RPCS, 1));
- assertNotNull(strategy);
-
- assertEquals(QName.create("foo", "unrouted"), strategy.getIdentifier());
- assertFalse(strategy.isContextBasedRouted());
- assertThrows(UnsupportedOperationException.class, () -> strategy.getLeaf());
- assertThrows(UnsupportedOperationException.class, () -> strategy.getContext());
+ assertNull(ContentRoutedRpcContext.forRpc(RPCS.get(1)));
}
@Test
public void routedRpcStrategyTest() {
- final RpcRoutingStrategy strategy = RpcRoutingStrategy.from(Iterables.get(RPCS, 0));
- assertNotNull(strategy);
+ final var context = ContentRoutedRpcContext.forRpc(RPCS.get(0));
+ assertNotNull(context);
- assertEquals(QName.create("foo", "routed"), strategy.getIdentifier());
- assertTrue(strategy.isContextBasedRouted());
- assertEquals(QName.create("foo", "identity"), strategy.getContext());
- assertEquals(QName.create("foo", "ctx"), strategy.getLeaf());
+ assertEquals(QName.create("foo", "identity"), context.identity());
+ assertEquals(QName.create("foo", "ctx"), context.leaf());
}
}
\ No newline at end of file