import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
public class CurrentSchemaContext implements SchemaContextListener, AutoCloseable {
- private final AtomicReference<SchemaContext> currentContext = new AtomicReference();
+ private final AtomicReference<SchemaContext> currentContext = new AtomicReference<>();
private final ListenerRegistration<SchemaContextListener> schemaContextListenerListenerRegistration;
private final Set<CapabilityListener> listeners1 = Collections.synchronizedSet(Sets.newHashSet());
private final SchemaSourceProvider<YangTextSchemaSource> rootSchemaSourceProvider;
import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
private static Optional<YangModuleCapability> moduleToCapability(
final Module module, final SchemaSourceProvider<YangTextSchemaSource> rootSchemaSourceProviderDependency) {
- final SourceIdentifier moduleSourceIdentifier = SourceIdentifier.create(module.getName(),
- (SimpleDateFormatUtil.DEFAULT_DATE_REV == module.getRevision() ? Optional.absent() :
- Optional.of(module.getQNameModule().getFormattedRevision())));
+ final SourceIdentifier moduleSourceIdentifier = RevisionSourceIdentifier.create(module.getName(),
+ SimpleDateFormatUtil.DEFAULT_DATE_REV == module.getRevision() ? Optional.absent() :
+ Optional.of(module.getQNameModule().getFormattedRevision()));
InputStream sourceStream = null;
String source;
if (source != null) {
return Optional.of(new YangModuleCapability(module, source));
- } else {
- LOG.warn("Missing source for module {}. This module will not be available from netconf server",
- moduleSourceIdentifier);
}
+
+ LOG.warn("Missing source for module {}. This module will not be available from netconf server",
+ moduleSourceIdentifier);
return Optional.absent();
}
if (dataTreeChangeTracker.getDeleteOperationTracker() > 0
|| dataTreeChangeTracker .getRemoveOperationTracker() > 0) {
return node;
- } else {
- if (!action.equals(dataTreeChangeTracker.peekAction())) {
- dataTreeChangeTracker.pushPath(node.getIdentifier());
- dataTreeChangeTracker.addDataTreeChange(new DataTreeChangeTracker.DataTreeChange(node, action,
- new ArrayList<>(dataTreeChangeTracker.getCurrentPath())));
- dataTreeChangeTracker.popPath();
- return null;
- } else {
- return node;
- }
}
+
+ if (action.equals(dataTreeChangeTracker.peekAction())) {
+ return node;
+ }
+
+ dataTreeChangeTracker.pushPath(node.getIdentifier());
+ dataTreeChangeTracker.addDataTreeChange(new DataTreeChangeTracker.DataTreeChange(node, action,
+ new ArrayList<>(dataTreeChangeTracker.getCurrentPath())));
+ dataTreeChangeTracker.popPath();
+ return null;
}
@Override
if (dataTreeChangeTracker.getDeleteOperationTracker() > 0
|| dataTreeChangeTracker.getRemoveOperationTracker() > 0) {
return node;
- } else {
- if (!action.equals(dataTreeChangeTracker.peekAction())) {
- dataTreeChangeTracker.pushPath(node.getIdentifier());
- dataTreeChangeTracker.addDataTreeChange(new DataTreeChangeTracker.DataTreeChange(node, action,
- new ArrayList<>(dataTreeChangeTracker.getCurrentPath())));
- dataTreeChangeTracker.popPath();
- return null;
- } else {
- return node;
- }
}
+
+ if (action.equals(dataTreeChangeTracker.peekAction())) {
+ return node;
+ }
+
+ dataTreeChangeTracker.pushPath(node.getIdentifier());
+ dataTreeChangeTracker.addDataTreeChange(new DataTreeChangeTracker.DataTreeChange(node, action,
+ new ArrayList<>(dataTreeChangeTracker.getCurrentPath())));
+ dataTreeChangeTracker.popPath();
+ return null;
}
@Override
|| dataTreeChangeTracker.getRemoveOperationTracker() > 0) {
dataTreeChangeTracker.popPath();
return node;
- } else {
- //if parent and current actions dont match create a DataTreeChange and add it to the change list
- //dont add a new child to the parent node
- if (!currentAction.equals(dataTreeChangeTracker.peekAction())) {
- dataTreeChangeTracker.addDataTreeChange(new DataTreeChangeTracker.DataTreeChange(node,
- currentAction, new ArrayList<>(dataTreeChangeTracker.getCurrentPath())));
- dataTreeChangeTracker.popPath();
- return null;
- } else {
- dataTreeChangeTracker.popPath();
- return node;
- }
}
+
+ if (currentAction.equals(dataTreeChangeTracker.peekAction())) {
+ dataTreeChangeTracker.popPath();
+ return node;
+ }
+
+ //if parent and current actions dont match create a DataTreeChange and add it to the change list
+ //dont add a new child to the parent node
+ dataTreeChangeTracker.addDataTreeChange(new DataTreeChangeTracker.DataTreeChange(node,
+ currentAction, new ArrayList<>(dataTreeChangeTracker.getCurrentPath())));
+ dataTreeChangeTracker.popPath();
+ return null;
}
@Override
throw new UnsupportedOperationException("Runtime rpc does not have a stable name");
}
- private URI createNsUri(final String namespace) {
+ private static URI createNsUri(final String namespace) {
final URI namespaceURI;
try {
namespaceURI = new URI(namespace);
schemaContext.getCurrentContext().findModuleByNamespaceAndRevision(namespaceURI, null));
}
- private Optional<RpcDefinition> getRpcDefinitionFromModule(final Module module, final URI namespaceURI,
- final String name) {
+ private static Optional<RpcDefinition> getRpcDefinitionFromModule(final Module module, final URI namespaceURI,
+ final String name) {
for (final RpcDefinition rpcDef : module.getRpcs()) {
if (rpcDef.getQName().getNamespace().equals(namespaceURI)
&& rpcDef.getQName().getLocalName().equals(name)) {
return result.getNode();
}
- private XMLStreamWriter getXmlStreamWriter(final DOMResult result) {
+ private static XMLStreamWriter getXmlStreamWriter(final DOMResult result) {
try {
return XML_OUTPUT_FACTORY.createXMLStreamWriter(result);
} catch (final XMLStreamException e) {
}
}
- private void writeRootElement(final XMLStreamWriter xmlWriter, final SchemaOrderedNormalizedNodeWriter nnWriter,
- final ContainerNode data) {
+ private static void writeRootElement(final XMLStreamWriter xmlWriter,
+ final SchemaOrderedNormalizedNodeWriter nnWriter, final ContainerNode data) {
try {
- final Collection<DataContainerChild<?, ?>> value = (Collection) data.getValue();
+ final Collection<DataContainerChild<?, ?>> value = data.getValue();
nnWriter.write(value);
nnWriter.flush();
xmlWriter.flush();
return Optional.absent();
}
return Optional.of(getInstanceIdentifierFromFilter(filterElement.get()));
- } else {
- return Optional.of(ROOT);
}
+
+ return Optional.of(ROOT);
}
@VisibleForTesting
*/
package org.opendaylight.netconf.mdsal.connector.ops.get;
-import static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder;
import static org.opendaylight.yangtools.yang.data.util.ParserStreamUtils.findSchemaNodeByNameAndNamespace;
import com.google.common.base.Optional;
import java.util.List;
import java.util.Map;
import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamWriter;
import org.opendaylight.controller.config.util.xml.DocumentedException;
import org.opendaylight.controller.config.util.xml.MissingNameSpaceException;
import org.opendaylight.controller.config.util.xml.XmlElement;
import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder;
import org.opendaylight.yangtools.yang.data.codec.xml.XmlCodecFactory;
import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec;
import org.opendaylight.yangtools.yang.data.util.codec.TypeAwareCodec;
final NamespaceContext nsContext = new UniversalNamespaceContextImpl(document, false);
final XmlCodecFactory xmlCodecFactory =
XmlCodecFactory.create(schemaContext.getCurrentContext());
- final TypeAwareCodec identityrefTypeCodec = xmlCodecFactory.codecFor(listKey);
+ final TypeAwareCodec<?, NamespaceContext, XMLStreamWriter> identityrefTypeCodec =
+ xmlCodecFactory.codecFor(listKey);
final QName deserializedKey =
(QName) identityrefTypeCodec.parseValue(nsContext, keyValue.get());
keys.put(qualifiedName, deserializedKey);
}
private static class ValidationException extends Exception {
+ private static final long serialVersionUID = 1L;
+
ValidationException(final XmlElement parent, final XmlElement child) {
super("Element " + child + " can't be child of " + parent);
}
* A single node is read, the namespace attributes are extracted and stored.
*
* @param node to examine
- * @param attributesOnly, if true no recursion happens
+ * @param attributesOnly if true no recursion happens
*/
private void readNode(final Node node, final boolean attributesOnly) {
final NamedNodeMap attributes = node.getAttributes();
* @param prefix to search for
* @return uri
*/
+ @Override
public String getNamespaceURI(final String prefix) {
if (prefix == null || prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
return prefix2Uri.get(DEFAULT_NS);
* This method is not needed in this context, but can be implemented in a
* similar way.
*/
+ @Override
public String getPrefix(final String namespaceURI) {
return uri2Prefix.get(namespaceURI);
}
+ @Override
public Iterator getPrefixes(final String namespaceURI) {
// Not implemented
return null;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
import org.opendaylight.controller.cluster.databroker.ConcurrentDOMDataBroker;
import org.opendaylight.controller.config.util.xml.DocumentedException;
import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
final ConcurrentDOMDataBroker cdb = new ConcurrentDOMDataBroker(datastores, listenableFutureExecutor);
this.transactionProvider = new TransactionProvider(cdb, SESSION_ID_FOR_REPORTING);
- doAnswer(new Answer() {
- @Override
- public Object answer(final InvocationOnMock invocationOnMock) throws Throwable {
- final SourceIdentifier sId = (SourceIdentifier) invocationOnMock.getArguments()[0];
- final YangTextSchemaSource yangTextSchemaSource =
- YangTextSchemaSource.delegateForByteSource(sId, ByteSource.wrap("module test".getBytes()));
- return Futures.immediateCheckedFuture(yangTextSchemaSource);
+ doAnswer(invocationOnMock -> {
+ final SourceIdentifier sId = (SourceIdentifier) invocationOnMock.getArguments()[0];
+ final YangTextSchemaSource yangTextSchemaSource =
+ YangTextSchemaSource.delegateForByteSource(sId, ByteSource.wrap("module test".getBytes()));
+ return Futures.immediateCheckedFuture(yangTextSchemaSource);
- }
}).when(sourceProvider).getSource(any(SourceIdentifier.class));
this.currentSchemaContext = new CurrentSchemaContext(schemaService, sourceProvider);
assertEmptyDatastore(getConfigRunning());
}
- private void verifyResponse(final Document response, final Document template) throws Exception {
+ private static void verifyResponse(final Document response, final Document template) throws Exception {
final DetailedDiff dd = new DetailedDiff(new Diff(response, template));
dd.overrideElementQualifier(new NetconfXmlUnitRecursiveQualifier());
assertTrue(dd.toString(), dd.similar());
}
- private void assertEmptyDatastore(final Document response) {
+ private static void assertEmptyDatastore(final Document response) {
final NodeList nodes = response.getChildNodes();
assertTrue(nodes.getLength() == 1);
return executeOperation(getConfig, resource);
}
- private Document lock() throws Exception {
+ private static Document lock() throws Exception {
final Lock lock = new Lock(SESSION_ID_FOR_REPORTING);
return executeOperation(lock, "messages/mapping/lock.xml");
}
- private Document unlock() throws Exception {
+ private static Document unlock() throws Exception {
final Unlock unlock = new Unlock(SESSION_ID_FOR_REPORTING);
return executeOperation(unlock, "messages/mapping/unlock.xml");
}
- private Document lockWithoutTarget() throws Exception {
+ private static Document lockWithoutTarget() throws Exception {
final Lock lock = new Lock(SESSION_ID_FOR_REPORTING);
return executeOperation(lock, "messages/mapping/lock_notarget.xml");
}
- private Document unlockWithoutTarget() throws Exception {
+ private static Document unlockWithoutTarget() throws Exception {
final Unlock unlock = new Unlock(SESSION_ID_FOR_REPORTING);
return executeOperation(unlock, "messages/mapping/unlock_notarget.xml");
}
- private Document lockCandidate() throws Exception {
+ private static Document lockCandidate() throws Exception {
final Lock lock = new Lock(SESSION_ID_FOR_REPORTING);
return executeOperation(lock, "messages/mapping/lock_candidate.xml");
}
- private Document unlockCandidate() throws Exception {
+ private static Document unlockCandidate() throws Exception {
final Unlock unlock = new Unlock(SESSION_ID_FOR_REPORTING);
return executeOperation(unlock, "messages/mapping/unlock_candidate.xml");
}
- private Document executeOperation(final NetconfOperation op, final String filename) throws Exception {
+ private static Document executeOperation(final NetconfOperation op, final String filename) throws Exception {
final Document request = XmlFileLoader.xmlFileToDocument(filename);
final Document response = op.handle(request, NetconfOperationChainedExecution.EXECUTION_TERMINATION_POINT);
public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(
@Nonnull final SchemaPath type, @Nullable final NormalizedNode<?, ?> input) {
return Futures.immediateFailedCheckedFuture(new DOMRpcException("rpc invocation not implemented yet") {
+ private static final long serialVersionUID = 1L;
});
}
@Override
public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(
@Nonnull final SchemaPath type, @Nullable final NormalizedNode<?, ?> input) {
- final Collection<DataContainerChild<? extends PathArgument, ?>> children = (Collection) input.getValue();
+ final Collection<DataContainerChild<? extends PathArgument, ?>> children =
+ (Collection<DataContainerChild<? extends PathArgument, ?>>) input.getValue();
final Module module = schemaContext.findModuleByNamespaceAndRevision(
type.getLastComponent().getNamespace(), null);
final RpcDefinition rpcDefinition = getRpcDefinitionFromModule(
@Mock
private SchemaContextListener listener;
@Mock
- private ListenerRegistration registration;
+ private ListenerRegistration<?> registration;
@Mock
private SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
}
}
- private void verifyResponse(final Document response, final Document template) throws Exception {
+ private static void verifyResponse(final Document response, final Document template) {
final DetailedDiff dd = new DetailedDiff(new Diff(response, template));
dd.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
//we care about order so response has to be identical
assertTrue(dd.identical());
}
- private RpcDefinition getRpcDefinitionFromModule(final Module module, final URI namespaceURI, final String name) {
+ private static RpcDefinition getRpcDefinitionFromModule(final Module module, final URI namespaceURI,
+ final String name) {
for (final RpcDefinition rpcDef : module.getRpcs()) {
if (rpcDef.getQName().getNamespace().equals(namespaceURI)
&& rpcDef.getQName().getLocalName().equals(name)) {
final QName qName = QName.create(input);
if (qName.getModule().getNamespace() != null) {
return qName;
- } else {
- return QName.create(Preconditions.checkNotNull(prev), input);
}
+
+ return QName.create(Preconditions.checkNotNull(prev), input);
}
}
PROPS.put(Constants.SERVICE_PID, CONFIG_PID);
}
- private ServiceRegistration configService;
+ private ServiceRegistration<?> configService;
@Override
- public void start(BundleContext bundleContext) {
+ public void start(final BundleContext bundleContext) {
LOG.debug("Starting netconf configuration service");
configService = bundleContext.registerService(ManagedService.class,
new NetconfConfiguration(), PROPS);
}
@Override
- public void stop(BundleContext bundleContext) {
+ public void stop(final BundleContext bundleContext) {
if (configService != null) {
LOG.debug("Unregistering netconf configuration service");
configService.unregister();
public class HardcodedNamespaceResolver implements NamespaceContext {
private final Map<String/* prefix */, String/* namespace */> prefixesToNamespaces;
- public HardcodedNamespaceResolver(String prefix, String namespace) {
+ public HardcodedNamespaceResolver(final String prefix, final String namespace) {
this(ImmutableMap.of(prefix, namespace));
}
- public HardcodedNamespaceResolver(Map<String, String> prefixesToNamespaces) {
+ public HardcodedNamespaceResolver(final Map<String, String> prefixesToNamespaces) {
this.prefixesToNamespaces = Collections.unmodifiableMap(prefixesToNamespaces);
}
* @return uri uniform resource identifier
*/
@Override
- public String getNamespaceURI(String prefix) {
+ public String getNamespaceURI(final String prefix) {
if (prefixesToNamespaces.containsKey(prefix)) {
return prefixesToNamespaces.get(prefix);
- } else {
- throw new IllegalStateException("Prefix mapping not found for " + prefix);
}
+
+ throw new IllegalStateException("Prefix mapping not found for " + prefix);
}
@Override
- public String getPrefix(String namespaceURI) {
+ public String getPrefix(final String namespaceURI) {
// Not needed in this context.
return null;
}
@Override
- public Iterator<?> getPrefixes(String namespaceURI) {
+ public Iterator<?> getPrefixes(final String namespaceURI) {
// Not needed in this context.
return null;
}
final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
moduleInfoBackedContext.addModuleInfos(Collections.singletonList($YangModuleInfoImpl.getInstance()));
final SchemaContext context = moduleInfoBackedContext.getSchemaContext();
- final LeafNode username = Builders.leafBuilder()
+ final LeafNode<?> username = Builders.leafBuilder()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(Session.QNAME, "username")))
.withValue("admin")
.build();
@Mock
private BundleContext context;
@Mock
- private ServiceRegistration registration;
+ private ServiceRegistration<?> registration;
@Before
public void setUp() throws Exception {
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import java.io.IOException;
import java.util.Collection;
*/
public static DepthAwareNormalizedNodeWriter forStreamWriter(final NormalizedNodeStreamWriter writer,
final boolean orderKeyLeaves, final int maxDepth) {
- if (orderKeyLeaves) {
- return new OrderedDepthAwareNormalizedNodeWriter(writer, maxDepth);
- } else {
- return new DepthAwareNormalizedNodeWriter(writer, maxDepth);
- }
+ return orderKeyLeaves ? new OrderedDepthAwareNormalizedNodeWriter(writer, maxDepth)
+ : new DepthAwareNormalizedNodeWriter(writer, maxDepth);
}
/**
* @return DepthAwareNormalizedNodeWriter
* @throws IOException when thrown from the backing writer.
*/
+ @Override
public final DepthAwareNormalizedNodeWriter write(final NormalizedNode<?, ?> node) throws IOException {
if (wasProcessedAsCompositeNode(node)) {
return this;
* @return Best estimate of the collection size required to hold all the children.
*/
static final int childSizeHint(final Iterable<?> children) {
- return (children instanceof Collection) ? ((Collection<?>) children).size() : UNKNOWN_SIZE;
+ return children instanceof Collection ? ((Collection<?>) children).size() : UNKNOWN_SIZE;
}
private boolean wasProcessAsSimpleNode(final NormalizedNode<?, ?> node) throws IOException {
return true;
}
- private void writeOnlyKeys(Map<QName, Object> keyValues) throws IllegalArgumentException, IOException {
+ private void writeOnlyKeys(final Map<QName, Object> keyValues) throws IllegalArgumentException, IOException {
for (Map.Entry<QName, Object> entry : keyValues.entrySet()) {
writer.leafNode(new NodeIdentifier(entry.getKey()), entry.getValue());
}
// Write all the rest
currentDepth++;
- boolean result = writeChildren(Iterables.filter(node.getValue(), new Predicate<NormalizedNode<?, ?>>() {
- @Override
- public boolean apply(final NormalizedNode<?, ?> input) {
- if (input instanceof AugmentationNode) {
- return true;
- }
- if (!qnames.contains(input.getNodeType())) {
- return true;
- }
-
- LOG.debug("Skipping key child {}", input);
- return false;
+ boolean result = writeChildren(Iterables.filter(node.getValue(), input -> {
+ if (input instanceof AugmentationNode) {
+ return true;
+ }
+ if (!qnames.contains(input.getNodeType())) {
+ return true;
}
+
+ LOG.debug("Skipping key child {}", input);
+ return false;
}));
currentDepth--;
return result;
new org.opendaylight.restconf.jersey.providers.JsonNormalizedNodeBodyReader();
jsonReaderNewRest.injectParams(getUriInfo(), getRequest());
return jsonReaderNewRest.readFrom(type, genericType, annotations, mediaType, httpHeaders, entityStream);
- } else {
- return readFrom(getInstanceIdentifierContext(), entityStream, isPost());
}
+
+ return readFrom(getInstanceIdentifierContext(), entityStream, isPost());
} catch (final Exception e) {
propagateExceptionAs(e);
return null; // no-op
final List<YangInstanceIdentifier.PathArgument> iiToDataList = new ArrayList<>();
InstanceIdentifierContext<? extends SchemaNode> newIIContext;
- while ((result instanceof AugmentationNode) || (result instanceof ChoiceNode)) {
- final Object childNode = ((DataContainerNode) result).getValue().iterator().next();
+ while (result instanceof AugmentationNode || result instanceof ChoiceNode) {
+ final Object childNode = ((DataContainerNode<?>) result).getValue().iterator().next();
if (isPost) {
iiToDataList.add(result.getIdentifier());
}
ErrorTag.MALFORMED_MESSAGE, exception);
}
- private List<PatchEntity> read(final JsonReader in, final InstanceIdentifierContext path) throws IOException {
+ private List<PatchEntity> read(final JsonReader in, final InstanceIdentifierContext<?> path) throws IOException {
final List<PatchEntity> resultCollection = new ArrayList<>();
final StringModuleInstanceIdentifierCodec codec = new StringModuleInstanceIdentifierCodec(
path.getSchemaContext());
* @throws IOException if operation fails
*/
private void parseByName(@Nonnull final String name, @Nonnull final PatchEdit edit,
- @Nonnull final JsonReader in, @Nonnull final InstanceIdentifierContext path,
+ @Nonnull final JsonReader in, @Nonnull final InstanceIdentifierContext<?> path,
@Nonnull final StringModuleInstanceIdentifierCodec codec,
@Nonnull final List<PatchEntity> resultCollection) throws IOException {
switch (name) {
* @throws IOException if operation fails
*/
private void readEditDefinition(@Nonnull final PatchEdit edit, @Nonnull final JsonReader in,
- @Nonnull final InstanceIdentifierContext path,
+ @Nonnull final InstanceIdentifierContext<?> path,
@Nonnull final StringModuleInstanceIdentifierCodec codec) throws IOException {
final StringBuffer value = new StringBuffer();
in.beginObject();
* @param in reader JsonReader reader
* @return NormalizedNode representing data
*/
- private static NormalizedNode readEditData(@Nonnull final JsonReader in, @Nonnull final SchemaNode targetSchemaNode,
- @Nonnull final InstanceIdentifierContext path) {
+ private static NormalizedNode<?, ?> readEditData(@Nonnull final JsonReader in,
+ @Nonnull final SchemaNode targetSchemaNode, @Nonnull final InstanceIdentifierContext<?> path) {
final NormalizedNodeResult resultHolder = new NormalizedNodeResult();
final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder);
JsonParserStream.create(writer, path.getSchemaContext(), targetSchemaNode).parse(in);
* @return PatchEntity Patch entity
*/
private static PatchEntity prepareEditOperation(@Nonnull final PatchEdit edit) {
- if ((edit.getOperation() != null) && (edit.getTargetSchemaNode() != null)
- && checkDataPresence(edit.getOperation(), (edit.getData() != null))) {
+ if (edit.getOperation() != null && edit.getTargetSchemaNode() != null
+ && checkDataPresence(edit.getOperation(), edit.getData() != null)) {
if (isPatchOperationWithValue(edit.getOperation())) {
// for lists allow to manipulate with list items through their parent
final YangInstanceIdentifier targetNode;
}
return new PatchEntity(edit.getId(), edit.getOperation(), targetNode, edit.getData());
- } else {
- return new PatchEntity(edit.getId(), edit.getOperation(), edit.getTarget());
}
+
+ return new PatchEntity(edit.getId(), edit.getOperation(), edit.getTarget());
}
throw new RestconfDocumentedException("Error parsing input", ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE);
* allow it, false otherwise
*/
private static boolean checkDataPresence(@Nonnull final String operation, final boolean hasData) {
- if (isPatchOperationWithValue(operation)) {
- return hasData;
- } else {
- return !hasData;
- }
+ return isPatchOperationWithValue(operation) == hasData;
}
/**
private String operation;
private YangInstanceIdentifier target;
private SchemaNode targetSchemaNode;
- private NormalizedNode data;
+ private NormalizedNode<?, ?> data;
public String getId() {
return this.id;
this.targetSchemaNode = targetSchemaNode;
}
- public NormalizedNode getData() {
+ public NormalizedNode<?, ?> getData() {
return this.data;
}
- public void setData(final NormalizedNode data) {
+ public void setData(final NormalizedNode<?, ?> data) {
this.data = data;
}
path = path.getParent();
if (data instanceof MapEntryNode) {
- data = ImmutableNodes.mapNodeBuilder(data.getNodeType()).withChild(((MapEntryNode) data)).build();
+ data = ImmutableNodes.mapNodeBuilder(data.getNodeType()).withChild((MapEntryNode) data).build();
}
nnWriter = createNormalizedNodeWriter(context,path,jsonWriter, depth);
nnWriter.write(data);
final JSONCodecFactory codecs = getCodecFactory(context);
final URI initialNs;
- if ((schema instanceof DataSchemaNode)
- && !((DataSchemaNode)schema).isAugmenting()
+ if (schema instanceof DataSchemaNode && !((DataSchemaNode)schema).isAugmenting()
&& !(schema instanceof SchemaContext)) {
initialNs = schema.getQName().getNamespace();
} else if (schema instanceof RpcDefinition) {
JSONNormalizedNodeStreamWriter.createNestedWriter(codecs, path, initialNs, jsonWriter);
if (depth.isPresent()) {
return DepthAwareNormalizedNodeWriter.forStreamWriter(streamWriter, depth.get());
- } else {
- return RestconfDelegatingNormalizedNodeWriter.forStreamWriter(streamWriter);
}
+
+ return RestconfDelegatingNormalizedNodeWriter.forStreamWriter(streamWriter);
}
private static JsonWriter createJsonWriter(final OutputStream entityStream, final boolean prettyPrint) {
if (prettyPrint) {
return JsonWriterFactory.createJsonWriter(new OutputStreamWriter(entityStream, StandardCharsets.UTF_8),
DEFAULT_INDENT_SPACES_NUM);
- } else {
- return JsonWriterFactory.createJsonWriter(new OutputStreamWriter(entityStream, StandardCharsets.UTF_8));
}
+
+ return JsonWriterFactory.createJsonWriter(new OutputStreamWriter(entityStream, StandardCharsets.UTF_8));
}
private static JSONCodecFactory getCodecFactory(final InstanceIdentifierContext<?> context) {
// TODO: Performance: Cache JSON Codec factory and schema context
- return JSONCodecFactory.create(context.getSchemaContext());
+ return JSONCodecFactory.getShared(context.getSchemaContext());
}
-
}
XMLStreamNormalizedNodeStreamWriter.create(xmlWriter, schemaContext, schemaPath);
if (depth.isPresent()) {
return DepthAwareNormalizedNodeWriter.forStreamWriter(xmlStreamWriter, depth.get());
- } else {
- return RestconfDelegatingNormalizedNodeWriter.forStreamWriter(xmlStreamWriter);
}
+
+ return RestconfDelegatingNormalizedNodeWriter.forStreamWriter(xmlStreamWriter);
}
private static void writeElements(final XMLStreamWriter xmlWriter, final RestconfNormalizedNodeWriter nnWriter,
final JsonWriter jsonWriter = JsonWriterFactory.createJsonWriter(outputWriter);
final NormalizedNodeStreamWriter jsonStreamWriter = JSONNormalizedNodeStreamWriter.createExclusiveWriter(
- JSONCodecFactory.create(context.getSchemaContext()), path, initialNs, jsonWriter);
+ JSONCodecFactory.getShared(context.getSchemaContext()), path, initialNs, jsonWriter);
// We create a delegating writer to special-case error-info as error-info is defined as an empty
// container in the restconf yang schema but we create a leaf node so we can output it. The delegate
final NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder =
Builders.leafBuilder((LeafSchemaNode) childSchema);
if (keys.contains(child.getNodeType())) {
- leafBuilder.withValue(((LeafNode) child).getValue());
+ leafBuilder.withValue(((LeafNode<?>) child).getValue());
builder.withChild(leafBuilder.build());
} else {
if (trim) {
if (defaultVal == null || !defaultVal.equals(nodeVal)) {
- leafBuilder.withValue(((LeafNode) child).getValue());
+ leafBuilder.withValue(((LeafNode<?>) child).getValue());
builder.withChild(leafBuilder.build());
}
} else {
if (defaultVal != null && defaultVal.equals(nodeVal)) {
- leafBuilder.withValue(((LeafNode) child).getValue());
+ leafBuilder.withValue(((LeafNode<?>) child).getValue());
builder.withChild(leafBuilder.build());
}
}
Builders.leafBuilder((LeafSchemaNode) childSchema);
if (trim) {
if (defaultVal == null || !defaultVal.equals(nodeVal)) {
- leafBuilder.withValue(((LeafNode) child).getValue());
+ leafBuilder.withValue(((LeafNode<?>) child).getValue());
builder.withChild(leafBuilder.build());
}
} else {
if (defaultVal != null && defaultVal.equals(nodeVal)) {
- leafBuilder.withValue(((LeafNode) child).getValue());
+ leafBuilder.withValue(((LeafNode<?>) child).getValue());
builder.withChild(leafBuilder.build());
}
}
final IdentityValuesDTO identityValuesDTO = new IdentityValuesDTO();
for (final PathArgument pathArgument : data.getPathArguments()) {
final IdentityValue identityValue = qNameToIdentityValue(pathArgument.getNodeType());
- if ((pathArgument instanceof NodeIdentifierWithPredicates) && (identityValue != null)) {
+ if (pathArgument instanceof NodeIdentifierWithPredicates && identityValue != null) {
final List<Predicate> predicates =
keyValuesToPredicateList(((NodeIdentifierWithPredicates) pathArgument).getKeyValues());
identityValue.setPredicates(predicates);
- } else if ((pathArgument instanceof NodeWithValue) && (identityValue != null)) {
+ } else if (pathArgument instanceof NodeWithValue && identityValue != null) {
final List<Predicate> predicates = new ArrayList<>();
final String value = String.valueOf(((NodeWithValue) pathArgument).getValue());
predicates.add(new Predicate(null, value));
String.valueOf(identityValue.getValue()));
return null;
}
- pathArgument = new NodeWithValue(qName, leafListPredicate.getValue());
+ pathArgument = new NodeWithValue<>(qName, leafListPredicate.getValue());
} else if (node instanceof ListSchemaNode) { // predicates are keys of list
final DataNodeContainer listNode = (DataNodeContainer) node;
final Map<QName, Object> predicatesMap = new HashMap<>();
}
}
result.add(pathArgument);
- if (i < (identities.size() - 1)) { // last element in instance-identifier can be other than
+ if (i < identities.size() - 1) { // last element in instance-identifier can be other than
// DataNodeContainer
if (node instanceof DataNodeContainer) {
parentContainer = (DataNodeContainer) node;
this.outputType = Preconditions.checkNotNull(outputType);
this.path = Preconditions.checkNotNull(path);
- Preconditions.checkArgument((streamName != null) && !streamName.isEmpty());
+ Preconditions.checkArgument(streamName != null && !streamName.isEmpty());
this.streamName = streamName;
}
private String writeBodyToString() {
final Writer writer = new StringWriter();
final NormalizedNodeStreamWriter jsonStream =
- JSONNormalizedNodeStreamWriter.createExclusiveWriter(JSONCodecFactory.create(this.schemaContext),
+ JSONNormalizedNodeStreamWriter.createExclusiveWriter(JSONCodecFactory.getShared(this.schemaContext),
this.notification.getType(), null, JsonWriterFactory.createJsonWriter(writer));
final NormalizedNodeWriter nodeWriter = NormalizedNodeWriter.forStreamWriter(jsonStream);
try {
final List<YangInstanceIdentifier.PathArgument> iiToDataList = new ArrayList<>();
InstanceIdentifierContext<? extends SchemaNode> newIIContext;
- while ((result instanceof AugmentationNode) || (result instanceof ChoiceNode)) {
- final Object childNode = ((DataContainerNode) result).getValue().iterator().next();
+ while (result instanceof AugmentationNode || result instanceof ChoiceNode) {
+ final Object childNode = ((DataContainerNode<?>) result).getValue().iterator().next();
if (isPost) {
iiToDataList.add(result.getIdentifier());
}
ErrorTag.MALFORMED_MESSAGE, exception);
}
- private List<PatchEntity> read(final JsonReader in, final InstanceIdentifierContext path) throws IOException {
+ private List<PatchEntity> read(final JsonReader in, final InstanceIdentifierContext<?> path) throws IOException {
final List<PatchEntity> resultCollection = new ArrayList<>();
final StringModuleInstanceIdentifierCodec codec = new StringModuleInstanceIdentifierCodec(
path.getSchemaContext());
* @throws IOException if operation fails
*/
private void parseByName(@Nonnull final String name, @Nonnull final PatchEdit edit,
- @Nonnull final JsonReader in, @Nonnull final InstanceIdentifierContext path,
+ @Nonnull final JsonReader in, @Nonnull final InstanceIdentifierContext<?> path,
@Nonnull final StringModuleInstanceIdentifierCodec codec,
@Nonnull final List<PatchEntity> resultCollection) throws IOException {
switch (name) {
* @throws IOException if operation fails
*/
private void readEditDefinition(@Nonnull final PatchEdit edit, @Nonnull final JsonReader in,
- @Nonnull final InstanceIdentifierContext path,
+ @Nonnull final InstanceIdentifierContext<?> path,
@Nonnull final StringModuleInstanceIdentifierCodec codec) throws IOException {
final StringBuffer value = new StringBuffer();
in.beginObject();
* @param in reader JsonReader reader
* @return NormalizedNode representing data
*/
- private static NormalizedNode readEditData(@Nonnull final JsonReader in, @Nonnull final SchemaNode targetSchemaNode,
- @Nonnull final InstanceIdentifierContext path) {
+ private static NormalizedNode<?, ?> readEditData(@Nonnull final JsonReader in,
+ @Nonnull final SchemaNode targetSchemaNode, @Nonnull final InstanceIdentifierContext<?> path) {
final NormalizedNodeResult resultHolder = new NormalizedNodeResult();
final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder);
JsonParserStream.create(writer, path.getSchemaContext(), targetSchemaNode).parse(in);
private static PatchEntity prepareEditOperation(@Nonnull final PatchEdit edit) {
if (edit.getOperation() != null && edit.getTargetSchemaNode() != null
&& checkDataPresence(edit.getOperation(), edit.getData() != null)) {
- if (isPatchOperationWithValue(edit.getOperation())) {
- // for lists allow to manipulate with list items through their parent
- final YangInstanceIdentifier targetNode;
- if (edit.getTarget().getLastPathArgument() instanceof NodeIdentifierWithPredicates) {
- targetNode = edit.getTarget().getParent();
- } else {
- targetNode = edit.getTarget();
- }
+ if (!isPatchOperationWithValue(edit.getOperation())) {
+ return new PatchEntity(edit.getId(), edit.getOperation(), edit.getTarget());
+ }
- return new PatchEntity(edit.getId(), edit.getOperation(), targetNode, edit.getData());
+ // for lists allow to manipulate with list items through their parent
+ final YangInstanceIdentifier targetNode;
+ if (edit.getTarget().getLastPathArgument() instanceof NodeIdentifierWithPredicates) {
+ targetNode = edit.getTarget().getParent();
} else {
- return new PatchEntity(edit.getId(), edit.getOperation(), edit.getTarget());
+ targetNode = edit.getTarget();
}
+
+ return new PatchEntity(edit.getId(), edit.getOperation(), targetNode, edit.getData());
}
throw new RestconfDocumentedException("Error parsing input", ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE);
* allow it, false otherwise
*/
private static boolean checkDataPresence(@Nonnull final String operation, final boolean hasData) {
- if (isPatchOperationWithValue(operation)) {
- return hasData;
- } else {
- return !hasData;
- }
+ return isPatchOperationWithValue(operation) == hasData;
}
/**
private String operation;
private YangInstanceIdentifier target;
private SchemaNode targetSchemaNode;
- private NormalizedNode data;
+ private NormalizedNode<?, ?> data;
public String getId() {
return id;
this.targetSchemaNode = targetSchemaNode;
}
- public NormalizedNode getData() {
+ public NormalizedNode<?, ?> getData() {
return data;
}
- public void setData(final NormalizedNode data) {
+ public void setData(final NormalizedNode<?, ?> data) {
this.data = data;
}
// Restconf allows returning one list item. We need to wrap it
// in map node in order to serialize it properly
nnWriter.write(
- ImmutableNodes.mapNodeBuilder(data.getNodeType()).withChild(((MapEntryNode) data)).build());
+ ImmutableNodes.mapNodeBuilder(data.getNodeType()).withChild((MapEntryNode) data).build());
} else {
nnWriter.write(data);
}
final JSONCodecFactory codecs = getCodecFactory(context);
final URI initialNs;
- if ((schema instanceof DataSchemaNode)
+ if (schema instanceof DataSchemaNode
&& !((DataSchemaNode)schema).isAugmenting()
&& !(schema instanceof SchemaContext)) {
initialNs = schema.getQName().getNamespace();
if (prettyPrint) {
return JsonWriterFactory.createJsonWriter(
new OutputStreamWriter(entityStream, StandardCharsets.UTF_8), DEFAULT_INDENT_SPACES_NUM);
- } else {
- return JsonWriterFactory.createJsonWriter(new OutputStreamWriter(entityStream, StandardCharsets.UTF_8));
}
+ return JsonWriterFactory.createJsonWriter(new OutputStreamWriter(entityStream, StandardCharsets.UTF_8));
}
private static JSONCodecFactory getCodecFactory(final InstanceIdentifierContext<?> context) {
// TODO: Performance: Cache JSON Codec factory and schema context
- return JSONCodecFactory.create(context.getSchemaContext());
+ return JSONCodecFactory.getShared(context.getSchemaContext());
}
}
import com.google.common.annotations.Beta;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import java.io.IOException;
import java.util.Collection;
final boolean orderKeyLeaves,
final Integer maxDepth,
final List<Set<QName>> fields) {
- if (orderKeyLeaves) {
- return new OrderedParameterAwareNormalizedNodeWriter(writer, maxDepth, fields);
- } else {
- return new ParameterAwareNormalizedNodeWriter(writer, maxDepth, fields);
- }
+ return orderKeyLeaves ? new OrderedParameterAwareNormalizedNodeWriter(writer, maxDepth, fields)
+ : new ParameterAwareNormalizedNodeWriter(writer, maxDepth, fields);
}
/**
* @return {@code ParameterAwareNormalizedNodeWriter}
* @throws IOException when thrown from the backing writer.
*/
+ @Override
public final ParameterAwareNormalizedNodeWriter write(final NormalizedNode<?, ?> node) throws IOException {
if (wasProcessedAsCompositeNode(node)) {
return this;
* @return Best estimate of the collection size required to hold all the children.
*/
static final int childSizeHint(final Iterable<?> children) {
- return (children instanceof Collection) ? ((Collection<?>) children).size() : UNKNOWN_SIZE;
+ return children instanceof Collection ? ((Collection<?>) children).size() : UNKNOWN_SIZE;
}
private boolean wasProcessAsSimpleNode(final NormalizedNode<?, ?> node) throws IOException {
protected boolean selectedByParameters(final NormalizedNode<?, ?> node, final boolean mixinParent) {
// nodes to be written are not limited by fields, only by depth
if (fields == null) {
- return (maxDepth == null || currentDepth < maxDepth);
+ return maxDepth == null || currentDepth < maxDepth;
}
// children of mixin nodes are never selected in fields but must be written if they are first in selected target
// write only selected nodes
if (currentDepth > 0 && currentDepth <= fields.size()) {
- if (fields.get(currentDepth - 1).contains(node.getNodeType())) {
- return true;
- } else {
- return false;
- }
+ return fields.get(currentDepth - 1).contains(node.getNodeType());
}
// after this depth only depth parameter is used to determine when to write node
- return (maxDepth == null || currentDepth < maxDepth);
+ return maxDepth == null || currentDepth < maxDepth;
}
/**
currentDepth++;
// Write all the rest
final boolean result =
- writeChildren(Iterables.filter(node.getValue(), new Predicate<NormalizedNode<?, ?>>() {
- @Override
- public boolean apply(final NormalizedNode<?, ?> input) {
- if (input instanceof AugmentationNode) {
- return true;
- }
- if (!qnames.contains(input.getNodeType())) {
- return true;
- }
-
- LOG.debug("Skipping key child {}", input);
- return false;
- }
- }), false);
+ writeChildren(Iterables.filter(node.getValue(), input -> {
+ if (input instanceof AugmentationNode) {
+ return true;
+ }
+ if (!qnames.contains(input.getNodeType())) {
+ return true;
+ }
+
+ LOG.debug("Skipping key child {}", input);
+ return false;
+ }), false);
currentDepth--;
return result;
}
MessageBodyReader<PatchContext> {
private static final Logger LOG = LoggerFactory.getLogger(XmlToPatchBodyReader.class);
+ private static final Splitter SLASH_SPLITTER = Splitter.on('/');
@Override
public boolean isReadable(final Class<?> type, final Type genericType,
final Element firstValueElement = values != null ? values.get(0) : null;
// get namespace according to schema node from path context or value
- final String namespace = (firstValueElement == null)
+ final String namespace = firstValueElement == null
? schemaNode.getQName().getNamespace().toString() : firstValueElement.getNamespaceURI();
// find module according to namespace
LOG.debug("Target node {} not found in path {} ", target, pathContext.getSchemaNode());
throw new RestconfDocumentedException("Error parsing input", ErrorType.PROTOCOL,
ErrorTag.MALFORMED_MESSAGE);
- } else {
- if (PatchEditOperation.isPatchOperationWithValue(operation)) {
- NormalizedNode<?, ?> parsed = null;
- if (schemaNode instanceof ContainerSchemaNode) {
- parsed = parserFactory.getContainerNodeParser().parse(values, (ContainerSchemaNode) schemaNode);
- } else if (schemaNode instanceof ListSchemaNode) {
- parsed = parserFactory.getMapNodeParser().parse(values, (ListSchemaNode) schemaNode);
- }
-
- // for lists allow to manipulate with list items through their parent
- if (targetII.getLastPathArgument() instanceof NodeIdentifierWithPredicates) {
- targetII = targetII.getParent();
- }
-
- resultCollection.add(new PatchEntity(editId, operation, targetII, parsed));
- } else {
- resultCollection.add(new PatchEntity(editId, operation, targetII));
+ }
+
+ if (PatchEditOperation.isPatchOperationWithValue(operation)) {
+ NormalizedNode<?, ?> parsed = null;
+ if (schemaNode instanceof ContainerSchemaNode) {
+ parsed = parserFactory.getContainerNodeParser().parse(values, (ContainerSchemaNode) schemaNode);
+ } else if (schemaNode instanceof ListSchemaNode) {
+ parsed = parserFactory.getMapNodeParser().parse(values, (ListSchemaNode) schemaNode);
}
+
+ // for lists allow to manipulate with list items through their parent
+ if (targetII.getLastPathArgument() instanceof NodeIdentifierWithPredicates) {
+ targetII = targetII.getParent();
+ }
+
+ resultCollection.add(new PatchEntity(editId, operation, targetII, parsed));
+ } else {
+ resultCollection.add(new PatchEntity(editId, operation, targetII));
}
}
*/
private static String prepareNonCondXpath(@Nonnull final DataSchemaNode schemaNode, @Nonnull final String target,
@Nonnull final Element value, @Nonnull final String namespace, @Nonnull final String revision) {
- final Iterator<String> args = Splitter.on("/").split(target.substring(target.indexOf(':') + 1)).iterator();
+ final Iterator<String> args = SLASH_SPLITTER.split(target.substring(target.indexOf(':') + 1)).iterator();
final StringBuilder nonCondXpath = new StringBuilder();
SchemaNode childNode = schemaNode;
private static void appendKeys(@Nonnull final StringBuilder nonCondXpath, @Nonnull final Iterator<QName> keyNames,
@Nonnull final Iterator<String> keyValues) {
while (keyNames.hasNext()) {
- nonCondXpath.append("[");
+ nonCondXpath.append('[');
nonCondXpath.append(keyNames.next().getLocalName());
- nonCondXpath.append("=");
- nonCondXpath.append("'");
+ nonCondXpath.append("='");
nonCondXpath.append(keyValues.next());
- nonCondXpath.append("'");
- nonCondXpath.append("]");
+ nonCondXpath.append("']");
}
}
}
streamName = streamName + "/JSON";
}
- if (!Notificator.existNotificationListenerFor(streamName)) {
- return Notificator.createNotificationListener(paths, streamName, outputType);
- } else {
+ if (Notificator.existNotificationListenerFor(streamName)) {
final List<NotificationListenerAdapter> notificationListenerFor =
Notificator.getNotificationListenerFor(streamName);
return SubscribeToStreamUtil.pickSpecificListenerByOutput(notificationListenerFor, outputType);
}
+
+ return Notificator.createNotificationListener(paths, streamName, outputType);
}
}
import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+@Deprecated
public class NnToJsonWithAugmentTest extends AbstractBodyReaderTest {
private static SchemaContext schemaContext;
final DOMTransactionChain transactionChain = mock(DOMTransactionChain.class);
final DOMDataWriteTransaction wTx = mock(DOMDataWriteTransaction.class);
- final CheckedFuture checked = Futures.immediateCheckedFuture("");
+ final CheckedFuture<Void, TransactionCommitFailedException> checked = Futures.immediateCheckedFuture(null);
when(wTx.submit()).thenReturn(checked);
when(transactionChain.newWriteOnlyTransaction()).thenReturn(wTx);
final TransactionChainHandler transactionChainHandler = new TransactionChainHandler(transactionChain);
final Iterator<?> prefixes =
startElement.getNamespaceContext().getPrefixes("augment:augment:module");
- while (prefixes.hasNext() && (augmentAugmentModulePrefix == null)) {
+ while (prefixes.hasNext() && augmentAugmentModulePrefix == null) {
final String prefix = (String) prefixes.next();
if (!prefix.isEmpty()) {
augmentAugmentModulePrefix = prefix;
final Iterator<?> prefixes =
startElement.getNamespaceContext().getPrefixes("augment:module:leaf:list");
- while (prefixes.hasNext() && (augmentModuleLfLstPrefix == null)) {
+ while (prefixes.hasNext() && augmentModuleLfLstPrefix == null) {
final String prefix = (String) prefixes.next();
if (!prefix.isEmpty()) {
augmentModuleLfLstPrefix = prefix;
final List<PathArgument> pathArguments = new ArrayList<>();
pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont")));
pathArguments.add(new NodeIdentifier(new QName(new URI("instance:identifier:module"), "cont1")));
- pathArguments.add(new NodeWithValue(new QName(new URI("augment:module:leaf:list"), "lflst11"), "lflst11_1"));
+ pathArguments.add(new NodeWithValue<>(new QName(new URI("augment:module:leaf:list"), "lflst11"), "lflst11_1"));
return YangInstanceIdentifier.create(pathArguments);
}
public NormalizedNodeContext getData(@Encoded @PathParam("identifier") final String identifier,
@Context final UriInfo uriInfo) {
- final InstanceIdentifierContext iiWithData = ControllerContext.getInstance().toInstanceIdentifier(
+ final InstanceIdentifierContext<?> iiWithData = ControllerContext.getInstance().toInstanceIdentifier(
identifier);
NormalizedNode<?, ?> data = null;
keys);
}
- private static NodeWithValue toIdentifier(final String localName, final Object value) {
- return new NodeWithValue(QName.create("urn:nested:module", "2014-06-3", localName), value);
+ private static NodeWithValue<?> toIdentifier(final String localName, final Object value) {
+ return new NodeWithValue<>(QName.create("urn:nested:module", "2014-06-3", localName), value);
}
private static UnkeyedListEntryNode nodeDataDepth3Operational() {
final DataSchemaNode lfSchemaNode = ((ContainerSchemaNode) contSchemaNode).getDataChildByName(lfQName);
assertTrue(lfSchemaNode instanceof LeafSchemaNode);
final LeafNode<Object> lfNode =
- (Builders.leafBuilder((LeafSchemaNode) lfSchemaNode).withValue("any value")).build();
+ Builders.leafBuilder((LeafSchemaNode) lfSchemaNode).withValue("any value").build();
contNode.withChild(lfNode);
container.withChild(contNode.build());
assertNotNull(rpcDef);
assertNotNull(rpcInputSchemaNode);
- assertTrue(rpcInputSchemaNode instanceof ContainerSchemaNode);
final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> containerBuilder =
Builders.containerBuilder(rpcInputSchemaNode);
}
assertNotNull(rpcDef);
assertNotNull(rpcOutputSchemaNode);
- assertTrue(rpcOutputSchemaNode instanceof ContainerSchemaNode);
final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> containerBuilder =
Builders.containerBuilder(rpcOutputSchemaNode);
final DataSchemaNode leafSchema = rpcOutputSchemaNode
@Test
public void deleteFailTest() throws Exception {
final String uri = "/config/test-interface:interfaces";
- final Exception exception = new TransactionCommitFailedException("failed test");
- final CheckedFuture future = Futures.immediateFailedCheckedFuture(exception);
+ final CheckedFuture<Void, TransactionCommitFailedException> future =
+ Futures.immediateFailedCheckedFuture(new TransactionCommitFailedException("failed test"));
when(brokerFacade.commitConfigurationDataDelete(any(YangInstanceIdentifier.class))).thenReturn(future);
final Response response = target(uri).request(MediaType.APPLICATION_XML).delete();
assertEquals(500, response.getStatus());
package org.opendaylight.controller.sal.restconf.impl.test;
import java.time.Instant;
+import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@Test
public void startTimeTest() {
final List<Entry<String, List<String>>> list = new ArrayList<>();
- final Entry<String, List<String>> entry = Mockito.mock(Entry.class);
- Mockito.when(entry.getKey()).thenReturn("start-time");
final List<String> time = new ArrayList<>();
time.add("2014-10-25T10:02:00Z");
- Mockito.when(entry.getValue()).thenReturn(time);
+ final Entry<String, List<String>> entry = new SimpleImmutableEntry<>("start-time", time);
list.add(entry);
subscribe(list);
@Test
public void milisecsTest() {
final List<Entry<String, List<String>>> list = new ArrayList<>();
- final Entry<String, List<String>> entry = Mockito.mock(Entry.class);
- Mockito.when(entry.getKey()).thenReturn("start-time");
final List<String> time = new ArrayList<>();
time.add("2014-10-25T10:02:00.12345Z");
- Mockito.when(entry.getValue()).thenReturn(time);
+ final Entry<String, List<String>> entry = new SimpleImmutableEntry<>("start-time", time);
list.add(entry);
subscribe(list);
@Test
public void zonesPlusTest() {
final List<Entry<String, List<String>>> list = new ArrayList<>();
- final Entry<String, List<String>> entry = Mockito.mock(Entry.class);
- Mockito.when(entry.getKey()).thenReturn("start-time");
final List<String> time = new ArrayList<>();
time.add("2014-10-25T10:02:00+01:00");
- Mockito.when(entry.getValue()).thenReturn(time);
+ final Entry<String, List<String>> entry = new SimpleImmutableEntry<>("start-time", time);
list.add(entry);
subscribe(list);
@Test
public void zonesMinusTest() {
final List<Entry<String, List<String>>> list = new ArrayList<>();
- final Entry<String, List<String>> entry = Mockito.mock(Entry.class);
- Mockito.when(entry.getKey()).thenReturn("start-time");
final List<String> time = new ArrayList<>();
time.add("2014-10-25T10:02:00-01:00");
- Mockito.when(entry.getValue()).thenReturn(time);
+ final Entry<String, List<String>> entry = new SimpleImmutableEntry<>("start-time", time);
list.add(entry);
subscribe(list);
@Test
public void startAndStopTimeTest() {
final List<Entry<String, List<String>>> list = new ArrayList<>();
- final Entry<String, List<String>> entry = Mockito.mock(Entry.class);
- Mockito.when(entry.getKey()).thenReturn("start-time");
final List<String> time = new ArrayList<>();
time.add("2014-10-25T10:02:00Z");
- Mockito.when(entry.getValue()).thenReturn(time);
+ final Entry<String, List<String>> entry = new SimpleImmutableEntry<>("start-time", time);
- final Entry<String, List<String>> entry2 = Mockito.mock(Entry.class);
- Mockito.when(entry2.getKey()).thenReturn("stop-time");
final List<String> time2 = new ArrayList<>();
time2.add("2014-10-25T12:31:00Z");
- Mockito.when(entry2.getValue()).thenReturn(time2);
+ final Entry<String, List<String>> entry2 = new SimpleImmutableEntry<>("stop-time", time2);
list.add(entry);
list.add(entry2);
@Test(expected = RestconfDocumentedException.class)
public void stopTimeTest() {
final List<Entry<String, List<String>>> list = new ArrayList<>();
- final Entry<String, List<String>> entry = Mockito.mock(Entry.class);
- Mockito.when(entry.getKey()).thenReturn("stop-time");
final List<String> time = new ArrayList<>();
time.add("2014-10-25T12:31:00Z");
- Mockito.when(entry.getValue()).thenReturn(time);
+ final Entry<String, List<String>> entry = new SimpleImmutableEntry<>("stop-time", time);
list.add(entry);
subscribe(list);
@Test(expected = RestconfDocumentedException.class)
public void badParamTest() {
final List<Entry<String, List<String>>> list = new ArrayList<>();
- final Entry<String, List<String>> entry = Mockito.mock(Entry.class);
- Mockito.when(entry.getKey()).thenReturn("time");
final List<String> time = new ArrayList<>();
time.add("2014-10-25T12:31:00Z");
- Mockito.when(entry.getValue()).thenReturn(time);
+ final Entry<String, List<String>> entry = new SimpleImmutableEntry<>("time", time);
list.add(entry);
subscribe(list);
@Test(expected = IllegalArgumentException.class)
public void badValueTest() {
final List<Entry<String, List<String>>> list = new ArrayList<>();
- final Entry<String, List<String>> entry = Mockito.mock(Entry.class);
- Mockito.when(entry.getKey()).thenReturn("start-time");
final List<String> time = new ArrayList<>();
time.add("badvalue");
- Mockito.when(entry.getValue()).thenReturn(time);
+ final Entry<String, List<String>> entry = new SimpleImmutableEntry<>("start-time", time);
list.add(entry);
subscribe(list);
@Test(expected = IllegalArgumentException.class)
public void badZonesTest() {
final List<Entry<String, List<String>>> list = new ArrayList<>();
- final Entry<String, List<String>> entry = Mockito.mock(Entry.class);
- Mockito.when(entry.getKey()).thenReturn("start-time");
final List<String> time = new ArrayList<>();
time.add("2014-10-25T10:02:00Z+1:00");
- Mockito.when(entry.getValue()).thenReturn(time);
+ final Entry<String, List<String>> entry = new SimpleImmutableEntry<>("start-time", time);
list.add(entry);
subscribe(list);
@Test(expected = IllegalArgumentException.class)
public void badMilisecsTest() {
final List<Entry<String, List<String>>> list = new ArrayList<>();
- final Entry<String, List<String>> entry = Mockito.mock(Entry.class);
- Mockito.when(entry.getKey()).thenReturn("start-time");
final List<String> time = new ArrayList<>();
time.add("2014-10-25T10:02:00:0026Z");
- Mockito.when(entry.getValue()).thenReturn(time);
+ final Entry<String, List<String>> entry = new SimpleImmutableEntry<>("start-time", time);
list.add(entry);
subscribe(list);
final ListenerAdapter listener = Notificator.createListener(path, this.identifier, NotificationOutputType.XML);
final List<Entry<String, List<String>>> list = new ArrayList<>();
- final Entry<String, List<String>> entry = Mockito.mock(Entry.class);
- Mockito.when(entry.getKey()).thenReturn("start-time");
final List<String> time = new ArrayList<>();
time.add("2014-10-25T10:02:00Z");
- Mockito.when(entry.getValue()).thenReturn(time);
+ final Entry<String, List<String>> entry = new SimpleImmutableEntry<>("start-time", time);
list.add(entry);
subscribe(list);
final DOMNotification notificationData = mock(DOMNotification.class);
- final LeafNode leaf = mockLeaf(QName.create(MODULE, "lf"));
+ final LeafNode<String> leaf = mockLeaf(QName.create(MODULE, "lf"));
final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), leaf);
when(notificationData.getType()).thenReturn(schemaPathNotifi);
final DOMNotification notificationData = mock(DOMNotification.class);
- final LeafNode leaf = mockLeaf(QName.create(MODULE, "lf"));
+ final LeafNode<String> leaf = mockLeaf(QName.create(MODULE, "lf"));
final ContainerNode cont = mockCont(QName.create(MODULE, "cont"), leaf);
final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), cont);
final DOMNotification notificationData = mock(DOMNotification.class);
- final LeafNode leaf = mockLeaf(QName.create(MODULE, "lf"));
+ final LeafNode<String> leaf = mockLeaf(QName.create(MODULE, "lf"));
final MapEntryNode entry = mockMapEntry(QName.create(MODULE, "lst"), leaf);
final MapNode list = mockList(QName.create(MODULE, "lst"), entry);
final ContainerNode cont = mockCont(QName.create(MODULE, "cont"), list);
final DOMNotification notificationData = mock(DOMNotification.class);
- final LeafNode leaf = mockLeaf(QName.create(MODULE, "lf"));
+ final LeafNode<String> leaf = mockLeaf(QName.create(MODULE, "lf"));
final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), leaf);
when(notificationData.getType()).thenReturn(schemaPathNotifi);
final DOMNotification notificationData = mock(DOMNotification.class);
- final LeafNode leaf = mockLeaf(QName.create(MODULE, "lf-augm"));
+ final LeafNode<String> leaf = mockLeaf(QName.create(MODULE, "lf-augm"));
final AugmentationNode augm = mockAugm(leaf);
final ContainerNode notifiBody = mockCont(schemaPathNotifi.getLastComponent(), augm);
assertTrue(result.contains("lf-augm" + '"' + ":" + '"' + "value"));
}
- private static AugmentationNode mockAugm(final LeafNode leaf) {
+ private static AugmentationNode mockAugm(final LeafNode<String> leaf) {
final AugmentationNode augm = mock(AugmentationNode.class);
final AugmentationIdentifier augmId = new AugmentationIdentifier(SingletonSet.of(leaf.getNodeType()));
when(augm.getIdentifier()).thenReturn(augmId);
return augm;
}
- private static MapEntryNode mockMapEntry(final QName entryQName, final LeafNode leaf) {
+ private static MapEntryNode mockMapEntry(final QName entryQName, final LeafNode<String> leaf) {
final MapEntryNode entry = mock(MapEntryNode.class);
final Map<QName, Object> keyValues = new HashMap<>();
keyValues.put(leaf.getNodeType(), "value");
return cont;
}
- private static LeafNode mockLeaf(final QName leafQName) {
- final LeafNode child = mock(LeafNode.class);
+ private static LeafNode<String> mockLeaf(final QName leafQName) {
+ final LeafNode<String> child = mock(LeafNode.class);
when(child.getNodeType()).thenReturn(leafQName);
when(child.getIdentifier()).thenReturn(NodeIdentifier.create(leafQName));
when(child.getValue()).thenReturn("value");
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
Mockito.when(txHandler.get()).thenReturn(domTx);
final DOMDataWriteTransaction wTx = Mockito.mock(DOMDataWriteTransaction.class);
Mockito.when(domTx.newWriteOnlyTransaction()).thenReturn(wTx);
- final CheckedFuture checked = Mockito.mock(CheckedFuture.class);
+ final CheckedFuture<Void, TransactionCommitFailedException> checked = Mockito.mock(CheckedFuture.class);
Mockito.when(wTx.submit()).thenReturn(checked);
- final Object valueObj = null;
- Mockito.when(checked.checkedGet()).thenReturn(valueObj);
+ Mockito.when(checked.checkedGet()).thenReturn(null);
final SchemaContextHandler schemaContextHandler = new SchemaContextHandler(txHandler);
schemaContextHandler.onGlobalContextUpdated(schemaContext);
final RestconfImpl restconfImpl = new RestconfImpl(schemaContextHandler);
final NormalizedNodeContext libraryVersion = restconfImpl.getLibraryVersion();
- final LeafNode value = (LeafNode) libraryVersion.getData();
+ final LeafNode<?> value = (LeafNode<?>) libraryVersion.getData();
Assert.assertEquals(IetfYangLibrary.REVISION, value.getValue());
}
}
import static org.junit.Assert.assertTrue;
import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
import java.net.URI;
import java.util.Set;
import javax.ws.rs.core.UriInfo;
Mockito.when(txHandler.get()).thenReturn(domTx);
final DOMDataWriteTransaction wTx = Mockito.mock(DOMDataWriteTransaction.class);
Mockito.when(domTx.newWriteOnlyTransaction()).thenReturn(wTx);
- final CheckedFuture checked = Mockito.mock(CheckedFuture.class);
- Mockito.when(wTx.submit()).thenReturn(checked);
- final Object valueObj = null;
- Mockito.when(checked.checkedGet()).thenReturn(valueObj);
+ Mockito.when(wTx.submit()).thenReturn(Futures.immediateCheckedFuture(null));
this.schemaContextHandler = new SchemaContextHandler(txHandler);
this.schemaContextHandler.onGlobalContextUpdated(this.schemaContext);
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
Mockito.when(txHandler.get()).thenReturn(domTx);
final DOMDataWriteTransaction wTx = Mockito.mock(DOMDataWriteTransaction.class);
Mockito.when(domTx.newWriteOnlyTransaction()).thenReturn(wTx);
- final CheckedFuture checked = Mockito.mock(CheckedFuture.class);
+ final CheckedFuture<Void,TransactionCommitFailedException> checked = Mockito.mock(CheckedFuture.class);
Mockito.when(wTx.submit()).thenReturn(checked);
- final Object value = null;
- Mockito.when(checked.checkedGet()).thenReturn(value);
+ Mockito.when(checked.checkedGet()).thenReturn(null);
this.schemaContextHandler = new SchemaContextHandler(txHandler);
this.schemaContext =
YangInstanceIdentifier.NodeIdentifier.create(leafList),
iterator.next());
assertEquals("Not expected path argument",
- new YangInstanceIdentifier.NodeWithValue(leafList, "instance"),
+ new YangInstanceIdentifier.NodeWithValue<>(leafList, "instance"),
iterator.next());
}
new YangInstanceIdentifier.NodeIdentifier(leafList),
iterator.next());
assertEquals("Not expected path argument",
- new YangInstanceIdentifier.NodeWithValue(leafList, true).toString(),
+ new YangInstanceIdentifier.NodeWithValue<>(leafList, true).toString(),
iterator.next().toString());
}
.node(new YangInstanceIdentifier.NodeIdentifierWithPredicates(
list, QName.create(list, "list-key"), 100))
.node(leafList)
- .node(new NodeWithValue(leafList, "instance"))
+ .node(new NodeWithValue<>(leafList, "instance"))
.build();
final String result = YangInstanceIdentifierSerializer.create(this.schemaContext, data);
public void serializeLeafListTest() {
final YangInstanceIdentifier data = YangInstanceIdentifier.builder()
.node(QName.create("serializer:test", "2016-06-06", "leaf-list-0"))
- .node(new NodeWithValue(QName.create("serializer:test", "2016-06-06", "leaf-list-0"), "instance"))
+ .node(new NodeWithValue<>(QName.create("serializer:test", "2016-06-06", "leaf-list-0"), "instance"))
.build();
final String result = YangInstanceIdentifierSerializer.create(this.schemaContext, data);
import org.mockito.MockitoAnnotations;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
Mockito.when(txHandler.get()).thenReturn(domTx);
final DOMDataWriteTransaction wTx = Mockito.mock(DOMDataWriteTransaction.class);
Mockito.when(domTx.newWriteOnlyTransaction()).thenReturn(wTx);
- final CheckedFuture checked = Mockito.mock(CheckedFuture.class);
+ final CheckedFuture<Void, TransactionCommitFailedException> checked = Mockito.mock(CheckedFuture.class);
Mockito.when(wTx.submit()).thenReturn(checked);
- final Object valueObj = null;
- Mockito.when(checked.checkedGet()).thenReturn(valueObj);
+ Mockito.when(checked.checkedGet()).thenReturn(null);
final SchemaContextHandler schemaContextHandler = new SchemaContextHandler(txHandler);
schemaContextHandler.onGlobalContextUpdated(this.contextRef.get());
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
Mockito.when(txHandler.get()).thenReturn(domTx);
final DOMDataWriteTransaction wTx = Mockito.mock(DOMDataWriteTransaction.class);
Mockito.when(domTx.newWriteOnlyTransaction()).thenReturn(wTx);
- final CheckedFuture checked = Mockito.mock(CheckedFuture.class);
+ final CheckedFuture<Void, TransactionCommitFailedException> checked = Mockito.mock(CheckedFuture.class);
Mockito.when(wTx.submit()).thenReturn(checked);
- final Object valueObj = null;
- Mockito.when(checked.checkedGet()).thenReturn(valueObj);
+ Mockito.when(checked.checkedGet()).thenReturn(null);
final SchemaContextHandler schemaContextHandler = new SchemaContextHandler(txHandler);
schemaContextHandler.onGlobalContextUpdated(contextRef.get());
this.invokeOperationsService =
@Test
public void testInvokeRpc() throws Exception {
final String identifier = "invoke-rpc-module:rpcTest";
- final NormalizedNode result = Mockito.mock(NormalizedNode.class);
+ final NormalizedNode<?, ?> result = Mockito.mock(NormalizedNode.class);
final NormalizedNodeContext payload = prepNNC(result);
final UriInfo uriInfo = Mockito.mock(UriInfo.class);
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
final DOMDataWriteTransaction wTx = Mockito.mock(DOMDataWriteTransaction.class);
Mockito.when(domTx.newWriteOnlyTransaction()).thenReturn(wTx);
final DOMDataReadWriteTransaction rwTx = Mockito.mock(DOMDataReadWriteTransaction.class);
- final CheckedFuture checkedFuture = Futures.immediateCheckedFuture(true);
+ final CheckedFuture<Boolean, ReadFailedException> checkedFuture = Futures.immediateCheckedFuture(Boolean.TRUE);
Mockito.when(rwTx.exists(Mockito.any(), Mockito.any())).thenReturn(checkedFuture);
- final CheckedFuture checkedFutureEmpty = Futures.immediateCheckedFuture("");
+ final CheckedFuture<Void, TransactionCommitFailedException> checkedFutureEmpty =
+ Futures.immediateCheckedFuture(null);
Mockito.when(rwTx.submit()).thenReturn(checkedFutureEmpty);
Mockito.when(domTx.newReadWriteTransaction()).thenReturn(rwTx);
- final CheckedFuture checked = Mockito.mock(CheckedFuture.class);
+ final CheckedFuture<Void, TransactionCommitFailedException> checked = Mockito.mock(CheckedFuture.class);
Mockito.when(wTx.submit()).thenReturn(checked);
- final Object valueObj = null;
- Mockito.when(checked.checkedGet()).thenReturn(valueObj);
+ Mockito.when(checked.checkedGet()).thenReturn(null);
this.schemaHandler = new SchemaContextHandler(txHandler);
final DOMDataBroker dataBroker = mock(DOMDataBroker.class);
.build();
/* values that are used for creating leaf for testPatchDataCreateAndDelete test */
- final LeafNode buildGapLeaf = Builders.leafBuilder()
+ final LeafNode<?> buildGapLeaf = Builders.leafBuilder()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(leafGapQName))
.withValue(0.2)
.build();
.node(baseQName)
.build();
- final LeafNode buildLeaf = Builders.leafBuilder()
+ final LeafNode<?> buildLeaf = Builders.leafBuilder()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(leafQname))
.withValue(0.2)
.build();
doReturn(Futures.immediateCheckedFuture(false))
.when(this.readWrite).exists(LogicalDatastoreType.CONFIGURATION, this.iid2);
final YangInstanceIdentifier.NodeIdentifier identifier =
- ((ContainerNode) ((SingletonSet) payload.getData().getValue()).iterator().next()).getIdentifier();
+ ((ContainerNode) ((SingletonSet<?>) payload.getData().getValue()).iterator().next()).getIdentifier();
final YangInstanceIdentifier node =
payload.getInstanceIdentifierContext().getInstanceIdentifier().node(identifier);
doReturn(Futures.immediateCheckedFuture(false))
doReturn(Futures.immediateCheckedFuture(false))
.when(this.readWrite).exists(LogicalDatastoreType.CONFIGURATION, this.iid2);
final YangInstanceIdentifier.NodeIdentifier identifier =
- ((ContainerNode) ((SingletonSet) payload.getData().getValue()).iterator().next()).getIdentifier();
+ ((ContainerNode) ((SingletonSet<?>) payload.getData().getValue()).iterator().next()).getIdentifier();
final YangInstanceIdentifier node =
payload.getInstanceIdentifierContext().getInstanceIdentifier().node(identifier);
doReturn(Futures.immediateCheckedFuture(false))
if (child.getNodeType().equals(MonitoringModule.CONT_CAPABILITES_QNAME)) {
for (final DataContainerChild<? extends PathArgument, ?> dataContainerChild : ((ContainerNode) child)
.getValue()) {
- for (final Object entry : ((LeafSetNode) dataContainerChild).getValue()) {
- listOfValues.add(((LeafSetEntryNode) entry).getValue());
+ for (final Object entry : ((LeafSetNode<?>) dataContainerChild).getValue()) {
+ listOfValues.add(((LeafSetEntryNode<?>) entry).getValue());
}
}
}
final Map<QName, Object> map =
prepareMap(path.getLastPathArgument().getNodeType().getLocalName(), uri, start, outputType);
- final NormalizedNode mappedData =
+ final NormalizedNode<?, ?> mappedData =
RestconfMappingNodeUtil.mapDataChangeNotificationStreamByIetfRestconfMonitoring(
path, start, outputType, uri, monitoringModule, exist, schemaContextMonitoring);
assertNotNull(mappedData);
map.put(MonitoringModule.LEAF_DESCR_STREAM_QNAME, "Notifi");
final QName notifiQName = QName.create("urn:nested:module", "2014-06-3", "notifi");
- final NormalizedNode mappedData =
+ final NormalizedNode<?, ?> mappedData =
RestconfMappingNodeUtil.mapYangNotificationStreamByIetfRestconfMonitoring(notifiQName,
schemaContextMonitoring.getNotifications(), start, outputType, uri, monitoringModule, exist);
assertNotNull(mappedData);
final Map<QName, Object> map = new HashMap<>();
map.put(MonitoringModule.LEAF_NAME_STREAM_QNAME, name);
map.put(MonitoringModule.LEAF_LOCATION_ACCESS_QNAME, uri.toString());
- map.put(MonitoringModule.LEAF_REPLAY_SUPP_STREAM_QNAME, true);
+ map.put(MonitoringModule.LEAF_REPLAY_SUPP_STREAM_QNAME, Boolean.TRUE);
map.put(MonitoringModule.LEAF_START_TIME_STREAM_QNAME, DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(
OffsetDateTime.ofInstant(start, ZoneId.systemDefault())));
map.put(MonitoringModule.LEAF_ENCODING_ACCESS_QNAME, outputType);
return map;
}
- private static void testData(final Map<QName, Object> map, final NormalizedNode mappedData) {
+ private static void testData(final Map<QName, Object> map, final NormalizedNode<?, ?> mappedData) {
for (final DataContainerChild<? extends PathArgument, ?> child : ((MapEntryNode) mappedData).getValue()) {
if (child instanceof LeafNode) {
- final LeafNode leaf = ((LeafNode) child);
+ final LeafNode<?> leaf = (LeafNode<?>) child;
Assert.assertTrue(map.containsKey(leaf.getNodeType()));
Assert.assertEquals(map.get(leaf.getNodeType()), leaf.getValue());
}
for (final DataContainerChild<? extends PathArgument, ?> child : containerNode.getValue()) {
if (child instanceof LeafNode) {
- assertEquals(IetfYangLibrary.MODULE_SET_ID_LEAF_QNAME, ((LeafNode) child).getNodeType());
+ assertEquals(IetfYangLibrary.MODULE_SET_ID_LEAF_QNAME, ((LeafNode<?>) child).getNodeType());
}
if (child instanceof MapNode) {
assertEquals(IetfYangLibrary.MODULE_QNAME_LIST, ((MapNode) child).getNodeType());
.getValue()) {
switch (dataContainerChild.getNodeType().getLocalName()) {
case IetfYangLibrary.SPECIFIC_MODULE_NAME_LEAF:
- name = String.valueOf(((LeafNode) dataContainerChild).getValue());
+ name = String.valueOf(((LeafNode<?>) dataContainerChild).getValue());
break;
case IetfYangLibrary.SPECIFIC_MODULE_REVISION_LEAF:
- revision = String.valueOf(((LeafNode) dataContainerChild).getValue());
+ revision = String.valueOf(((LeafNode<?>) dataContainerChild).getValue());
break;
default :
LOG.info("Unknown local name '{}' of node.",