import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_QNAME;
-import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath;
import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFailedFluentFuture;
import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFluentFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Before
public void setUp() throws Exception {
schemaContext = BASE_SCHEMAS.getBaseSchemaWithNotifications().getEffectiveModelContext();
- final DataSchemaNode schemasNode =
- ((ContainerSchemaNode) schemaContext.findDataChildByName(NetconfState.QNAME).orElseThrow())
- .findDataChildByName(Schemas.QNAME).orElseThrow();
final NormalizedNodeResult resultHolder = new NormalizedNodeResult();
final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder);
- final XmlParserStream xmlParser = XmlParserStream.create(writer, schemaContext, schemasNode, false);
+ final XmlParserStream xmlParser = XmlParserStream.create(writer,
+ SchemaInferenceStack.ofDataTreePath(schemaContext, NetconfState.QNAME, Schemas.QNAME).toInference(), false);
xmlParser.parse(UntrustedXML.createXMLStreamReader(getClass().getResourceAsStream(
"/netconf-state.schemas.payload.xml")));
compositeNodeSchemas = (ContainerNode) resultHolder.getResult();
-
}
@Test
.withChild(data)
.build();
doReturn(immediateFluentFuture(new DefaultDOMRpcResult(rpcReply))).when(rpc)
- .invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any());
+ .invokeRpc(eq(NETCONF_GET_QNAME), any());
final NetconfStateSchemas stateSchemas = NetconfStateSchemas.create(rpc, CAPS, deviceId, schemaContext);
final Set<QName> availableYangSchemasQNames = stateSchemas.getAvailableYangSchemasQNames();
assertEquals(numberOfLegalSchemas, availableYangSchemasQNames.size());
final NetconfSessionPreferences caps = NetconfSessionPreferences.fromStrings(Collections.emptySet());
final NetconfStateSchemas stateSchemas = NetconfStateSchemas.create(rpc, caps, deviceId, schemaContext);
final Set<QName> availableYangSchemasQNames = stateSchemas.getAvailableYangSchemasQNames();
- Assert.assertTrue(availableYangSchemasQNames.isEmpty());
+ assertTrue(availableYangSchemasQNames.isEmpty());
}
@Test
public void testCreateFail() throws Exception {
- when(rpc.invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any())).thenReturn(
+ when(rpc.invokeRpc(eq(NETCONF_GET_QNAME), any())).thenReturn(
immediateFailedFluentFuture(new DOMRpcImplementationNotAvailableException("not available")));
final NetconfStateSchemas stateSchemas = NetconfStateSchemas.create(rpc, CAPS, deviceId, schemaContext);
final Set<QName> availableYangSchemasQNames = stateSchemas.getAvailableYangSchemasQNames();
- Assert.assertTrue(availableYangSchemasQNames.isEmpty());
+ assertTrue(availableYangSchemasQNames.isEmpty());
}
@Test
public void testCreateRpcError() throws Exception {
final RpcError rpcError = RpcResultBuilder.newError(RpcError.ErrorType.RPC, "fail", "fail");
doReturn(immediateFluentFuture(new DefaultDOMRpcResult(rpcError))).when(rpc)
- .invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any());
+ .invokeRpc(eq(NETCONF_GET_QNAME), any());
final NetconfStateSchemas stateSchemas = NetconfStateSchemas.create(rpc, CAPS, deviceId, schemaContext);
final Set<QName> availableYangSchemasQNames = stateSchemas.getAvailableYangSchemasQNames();
- Assert.assertTrue(availableYangSchemasQNames.isEmpty());
+ assertTrue(availableYangSchemasQNames.isEmpty());
}
@SuppressWarnings({ "checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
try {
when(interruptedFuture.get()).thenThrow(new InterruptedException("interrupted"));
doReturn(FluentFuture.from(interruptedFuture)).when(rpc)
- .invokeRpc(eq(toPath(NETCONF_GET_QNAME)), any());
+ .invokeRpc(eq(NETCONF_GET_QNAME), any());
NetconfStateSchemas.create(rpc, CAPS, deviceId, schemaContext);
} catch (final InterruptedException | ExecutionException e) {
LOG.info("Operation failed.", e);
new NetconfStateSchemas.RemoteYangSchema(NetconfState.QNAME);
final NetconfStateSchemas.RemoteYangSchema schema3 =
new NetconfStateSchemas.RemoteYangSchema(Schemas.QNAME);
- Assert.assertEquals(schema1, schema2);
- Assert.assertEquals(schema2, schema1);
- Assert.assertNotEquals(schema1, schema3);
- Assert.assertNotEquals(schema2, schema3);
-
+ assertEquals(schema1, schema2);
+ assertEquals(schema2, schema1);
+ assertNotEquals(schema1, schema3);
+ assertNotEquals(schema2, schema3);
}
}