Fix various warnings 81/57581/3
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 20 May 2017 10:19:08 +0000 (12:19 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 20 May 2017 11:53:04 +0000 (13:53 +0200)
The code is full of eclipse warnings around static methods, raw types
and similar. Fix that up.

Change-Id: I8aa84b8c0fbde5c32ab855dfc215205501ce2777
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
48 files changed:
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/CurrentSchemaContext.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/MdsalNetconfOperationServiceFactory.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/EditOperationStrategyProvider.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpc.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/get/AbstractGet.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/get/FilterContentValidator.java
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/get/UniversalNamespaceContextImpl.java
netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/NetconfMDSalMappingTest.java
netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpcTest.java
netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/netconf/mdsal/connector/ops/get/FilterContentValidatorTest.java
netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/osgi/NetconfConfigurationActivator.java
netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/xml/HardcodedNamespaceResolver.java
netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/NetconfUtilTest.java
netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/osgi/NetconfConfigurationActivatorTest.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/DepthAwareNormalizedNodeWriter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonNormalizedNodeBodyReader.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/JsonToPatchBodyReader.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/NormalizedNodeJsonBodyWriter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/NormalizedNodeXmlBodyWriter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/RestconfDocumentedExceptionMapper.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/BrokerFacade.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/restconf/impl/RestCodec.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerAdapter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/jersey/providers/JsonNormalizedNodeBodyReader.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/jersey/providers/JsonToPatchBodyReader.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/jersey/providers/NormalizedNodeJsonBodyWriter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/jersey/providers/ParameterAwareNormalizedNodeWriter.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/jersey/providers/XmlToPatchBodyReader.java
restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/restful/utils/CreateStreamUtil.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/nn/to/json/test/NnToJsonWithAugmentTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/BrokerFacadeTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CnSnToXmlAndJsonInstanceIdentifierTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CutDataToCorrectDepthTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/InvokeRpcMethodTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfImplNotificationSubscribingTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/netconf/sal/streams/listeners/NotificationListenerTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/base/services/impl/RestconfImplTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/base/services/impl/RestconfOperationsServiceTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/handlers/SchemaContextHandlerTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierDeserializerTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/parser/builder/YangInstanceIdentifierSerializerTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/restful/services/impl/RestconfDataServiceImplTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/restful/services/impl/RestconfInvokeOperationsServiceImplTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/restful/services/impl/RestconfStreamsSubscriptionServiceImplTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/restful/utils/PatchDataTransactionUtilTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/restful/utils/PostDataTransactionUtilTest.java
restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/utils/mapping/RestconfMappingNodeUtilTest.java

index 8ec0d42d1cd99a82fa7bc683c4fc04bb1730568d..d83cfb56f40d07bf0965a4ebd56c7303686efa2b 100644 (file)
@@ -23,7 +23,7 @@ import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 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;
index 2e84d3d216e6325c2ce918012f34eb022ca0aa35..273709db1c61a33ec9cd1d4ebda65b7c9033aad8 100644 (file)
@@ -28,6 +28,7 @@ import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListen
 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;
@@ -116,9 +117,9 @@ public class MdsalNetconfOperationServiceFactory implements NetconfOperationServ
     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;
@@ -141,10 +142,10 @@ public class MdsalNetconfOperationServiceFactory implements NetconfOperationServ
 
         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();
     }
 
index 505e38739b458991c5516d72b4ca015420476dff..a29e37d47f754acb57d5ca784926f7dd129d829d 100644 (file)
@@ -151,17 +151,17 @@ class EditOperationStrategyProvider extends DomToNormalizedNodeParserFactory.Bui
             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
@@ -200,17 +200,17 @@ class EditOperationStrategyProvider extends DomToNormalizedNodeParserFactory.Bui
             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
@@ -244,19 +244,19 @@ class EditOperationStrategyProvider extends DomToNormalizedNodeParserFactory.Bui
                     || 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
index bd47a3d9bddef73cc64e502163329a6c2b460adb..30cd1dae8ba111c2279f6c1b4511dc94a0025cf2 100644 (file)
@@ -98,7 +98,7 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
         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);
@@ -115,8 +115,8 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
                 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)) {
@@ -234,7 +234,7 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
         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) {
@@ -242,10 +242,10 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
         }
     }
 
-    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();
index 5bbcd340ff3b6b04516a141d9e83ae16a36ac77f..5acceb359b8bc24b1b59f16571db049abebd8c1b 100644 (file)
@@ -132,9 +132,9 @@ public abstract class AbstractGet extends AbstractSingletonNetconfOperation {
                 return Optional.absent();
             }
             return Optional.of(getInstanceIdentifierFromFilter(filterElement.get()));
-        } else {
-            return Optional.of(ROOT);
         }
+
+        return Optional.of(ROOT);
     }
 
     @VisibleForTesting
index f3132740162aaae4b65607234dbeed05e3443212..c6f5714e1f295403336ab0bac32f402b3d8ed1f5 100644 (file)
@@ -7,7 +7,6 @@
  */
 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;
@@ -22,12 +21,14 @@ import java.util.HashMap;
 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;
@@ -210,7 +211,8 @@ public class FilterContentValidator {
                         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);
@@ -282,6 +284,8 @@ public class FilterContentValidator {
     }
 
     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);
         }
index f1deb933828761c2798ad318a2ee731498e752cc..3fa27d94b6330f620fbd4827acbbda93104dcfb3 100644 (file)
@@ -39,7 +39,7 @@ public class UniversalNamespaceContextImpl implements NamespaceContext {
      * 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();
@@ -93,6 +93,7 @@ public class UniversalNamespaceContextImpl implements NamespaceContext {
      * @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);
@@ -105,10 +106,12 @@ public class UniversalNamespaceContextImpl implements NamespaceContext {
      * 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;
index ab87564bef8864e844e8c99baadb59f6dbec059e..320c27b09f3ae7c9c7c38349e7d0c484ec5e48fa 100644 (file)
@@ -36,8 +36,6 @@ import org.junit.Before;
 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;
@@ -148,15 +146,12 @@ public class NetconfMDSalMappingTest {
         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);
@@ -613,7 +608,7 @@ public class NetconfMDSalMappingTest {
         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());
 
@@ -623,7 +618,7 @@ public class NetconfMDSalMappingTest {
         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);
 
@@ -678,37 +673,37 @@ public class NetconfMDSalMappingTest {
         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);
 
index ca6c47eb98bc9f55fb5675e5a2605b4ac814a1f9..7df0ff59e05d232e9b2023544e368e01a714e30d 100644 (file)
@@ -110,6 +110,7 @@ public class RuntimeRpcTest {
         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;
             });
         }
 
@@ -126,7 +127,8 @@ public class RuntimeRpcTest {
         @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(
@@ -155,7 +157,7 @@ public class RuntimeRpcTest {
     @Mock
     private SchemaContextListener listener;
     @Mock
-    private ListenerRegistration registration;
+    private ListenerRegistration<?> registration;
     @Mock
     private SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
 
@@ -274,14 +276,15 @@ public class RuntimeRpcTest {
         }
     }
 
-    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)) {
index 2156270b803b8c31b995b161b9561f246bae9d30..8ee3e38a33964a06099f40cbc53d50f20fb1c16e 100644 (file)
@@ -145,8 +145,8 @@ public class FilterContentValidatorTest {
         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);
     }
 }
index 28d820aa896513de333aff1d1d96f6f37df017f7..3c1a9c5cb06083982ae952ce36ba7a678a8a8fcb 100644 (file)
@@ -28,17 +28,17 @@ public class NetconfConfigurationActivator implements BundleActivator {
         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();
index a705ea647a1074f4a49f976b75bfa04b03d96eb8..942fe86a4cbfc11b451738568e7d946a5a307e99 100644 (file)
@@ -18,11 +18,11 @@ import javax.xml.namespace.NamespaceContext;
 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);
     }
 
@@ -34,22 +34,22 @@ public class HardcodedNamespaceResolver implements NamespaceContext {
      * @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;
     }
index 38f5bd039f516d99bd59e825426ee081e6d90ced..c263a0769231fe73d553bfacd68bf87b7443ff30 100644 (file)
@@ -59,7 +59,7 @@ public class NetconfUtilTest {
         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();
index cd21d8ce2968c52c42b2a9f9403eb32e311e319b..70fadc231415642f36790d2b17b3e59610cdefab 100644 (file)
@@ -30,7 +30,7 @@ public class NetconfConfigurationActivatorTest {
     @Mock
     private BundleContext context;
     @Mock
-    private ServiceRegistration registration;
+    private ServiceRegistration<?> registration;
 
     @Before
     public void setUp() throws Exception {
index e3135b4a67237ad36b35807bd179109d9e1c271d..37f6cea6019108cfd09d48c8e9ba9571cdfc752a 100644 (file)
@@ -11,7 +11,6 @@ import static org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedN
 
 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;
@@ -91,11 +90,8 @@ public class DepthAwareNormalizedNodeWriter implements RestconfNormalizedNodeWri
      */
     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);
     }
 
     /**
@@ -106,6 +102,7 @@ public class DepthAwareNormalizedNodeWriter implements RestconfNormalizedNodeWri
      * @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;
@@ -138,7 +135,7 @@ public class DepthAwareNormalizedNodeWriter implements RestconfNormalizedNodeWri
      * @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 {
@@ -197,7 +194,7 @@ public class DepthAwareNormalizedNodeWriter implements RestconfNormalizedNodeWri
         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());
         }
@@ -304,19 +301,16 @@ public class DepthAwareNormalizedNodeWriter implements RestconfNormalizedNodeWri
 
             // 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;
index 3b7d07e716e7ffd24320f67d48a35f1dc92085e4..0f558fa229743c088398f22591363dcbd4d8a9d9 100644 (file)
@@ -77,9 +77,9 @@ public class JsonNormalizedNodeBodyReader
                         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
@@ -130,8 +130,8 @@ public class JsonNormalizedNodeBodyReader
         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());
             }
index aa7c32a1cf7cedd26e319df613482efc1f65645c..d922a5aa94c1dc87d3a9c5f67d9ecb50e1afdc32 100644 (file)
@@ -122,7 +122,7 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
                 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());
@@ -178,7 +178,7 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
      * @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) {
@@ -217,7 +217,7 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
      * @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();
@@ -358,8 +358,8 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
      * @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);
@@ -373,8 +373,8 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
      * @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;
@@ -385,9 +385,9 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
                 }
 
                 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);
@@ -401,11 +401,7 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
      *     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;
     }
 
     /**
@@ -416,7 +412,7 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
         private String operation;
         private YangInstanceIdentifier target;
         private SchemaNode targetSchemaNode;
-        private NormalizedNode data;
+        private NormalizedNode<?, ?> data;
 
         public String getId() {
             return this.id;
@@ -450,11 +446,11 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
             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;
         }
 
index 202f08897d533308ce997b3665dfde10a8f25cb8..7891d4037295d4e2a7abffec93bd7a34431db1bd 100644 (file)
@@ -121,7 +121,7 @@ public class NormalizedNodeJsonBodyWriter implements MessageBodyWriter<Normalize
             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);
@@ -144,8 +144,7 @@ public class NormalizedNodeJsonBodyWriter implements MessageBodyWriter<Normalize
         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) {
@@ -157,23 +156,22 @@ public class NormalizedNodeJsonBodyWriter implements MessageBodyWriter<Normalize
                 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());
     }
-
 }
index cfe6b2116b05842629a8a4a4cbbeceb3f2f864de..40123d0e9826d5ee1f76feba910eceb4b9cf5013 100644 (file)
@@ -135,9 +135,9 @@ public class NormalizedNodeXmlBodyWriter implements MessageBodyWriter<Normalized
                 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,
index d2f5846764315bd474bf224aa43ff41c160805dc..f24650856c5cf46ce6f7e2895a4170ff878a1873 100644 (file)
@@ -234,7 +234,7 @@ public class RestconfDocumentedExceptionMapper implements ExceptionMapper<Restco
 
         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
index c269e2f60781142a0567458b053562887fc99316..026e538b617185e3011e4605f16d2d7418519023 100644 (file)
@@ -616,17 +616,17 @@ public class BrokerFacade {
                 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());
                         }
                     }
@@ -672,12 +672,12 @@ public class BrokerFacade {
                         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());
                     }
                 }
index 0518de3f8f75107ebbb63f223eab21a077616427..0202b722cc5d29cb1d78a468a0ce66751f09742a 100644 (file)
@@ -212,11 +212,11 @@ public class RestCodec {
             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));
@@ -266,7 +266,7 @@ public class RestCodec {
                                     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<>();
@@ -286,7 +286,7 @@ public class RestCodec {
                     }
                 }
                 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;
index 084457aea35a7ed18a9eb9ccfc864b39df7d6ebd..cdf1ff26451cb70e68b684789f4975d95e1ed663 100644 (file)
@@ -71,7 +71,7 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem
 
         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;
     }
 
@@ -156,7 +156,7 @@ public class NotificationListenerAdapter extends AbstractCommonSubscriber implem
     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 {
index e76ad6b989447bfa3171938c7f4f6517f58de146..9dbf3f0e9ccf577ca1d99f73b9f8c8cacf55f3ca 100644 (file)
@@ -108,8 +108,8 @@ public class JsonNormalizedNodeBodyReader extends AbstractIdentifierAwareJaxRsPr
         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());
             }
index 4a217599a6775467b04a6978b428a11d43dbb6be..2665e58e2a98febf7584cd07e78800bd8a965102 100644 (file)
@@ -115,7 +115,7 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
                 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());
@@ -171,7 +171,7 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
      * @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) {
@@ -211,7 +211,7 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
      * @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();
@@ -352,8 +352,8 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
      * @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);
@@ -369,19 +369,19 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
     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);
@@ -395,11 +395,7 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
      *     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;
     }
 
     /**
@@ -410,7 +406,7 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
         private String operation;
         private YangInstanceIdentifier target;
         private SchemaNode targetSchemaNode;
-        private NormalizedNode data;
+        private NormalizedNode<?, ?> data;
 
         public String getId() {
             return id;
@@ -444,11 +440,11 @@ public class JsonToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider
             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;
         }
 
index 563b5666233476ebcc9833f88a3a80c162783c2d..b89b30c12f9081f7c4da3b8943437c95de83e178 100644 (file)
@@ -127,7 +127,7 @@ public class NormalizedNodeJsonBodyWriter implements MessageBodyWriter<Normalize
                 // 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);
             }
@@ -151,7 +151,7 @@ public class NormalizedNodeJsonBodyWriter implements MessageBodyWriter<Normalize
         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();
@@ -169,13 +169,12 @@ public class NormalizedNodeJsonBodyWriter implements MessageBodyWriter<Normalize
         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());
     }
 }
index ce108409bc72ee658ee74b7ad23673e84d9c1955..c86bd6fcb3d3c1868c869f5d2587c4d1f2f67526 100644 (file)
@@ -13,7 +13,6 @@ import static org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedN
 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;
@@ -102,11 +101,8 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
                                                                      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);
     }
 
     /**
@@ -117,6 +113,7 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
      * @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;
@@ -149,7 +146,7 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
      * @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 {
@@ -192,7 +189,7 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
     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
@@ -207,15 +204,11 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
 
         // 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;
     }
 
     /**
@@ -370,20 +363,17 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
             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;
         }
index 1972ea970a0c3dbcf10b66d21b92e47ecaef60b2..eed386645d4a4eb8b6cd4a97c4033d119ddf39fc 100644 (file)
@@ -61,6 +61,7 @@ public class XmlToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider i
         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,
@@ -113,7 +114,7 @@ public class XmlToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider i
             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
@@ -148,24 +149,24 @@ public class XmlToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider i
                 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));
             }
         }
 
@@ -219,7 +220,7 @@ public class XmlToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider i
      */
     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;
@@ -271,13 +272,11 @@ public class XmlToPatchBodyReader extends AbstractIdentifierAwareJaxRsProvider i
     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("']");
         }
     }
 }
index 10955e792906dbaff4b5caa45308f213fa969225..c358b42bda523e374bf7ddbfb56a327bb0a88087 100644 (file)
@@ -221,12 +221,12 @@ public final class CreateStreamUtil {
             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);
     }
 }
index 632cfc199b85594defdee6eb80012ad30f2a2c5b..a108094751e4d5185839c65a92ef1b1f0c9f7755 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter;
 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;
index 33fa3c4dcbf964d23a91f5a98a995817d2ccbc1d..a2485dfc81aa7adb0a9e95fa63caec6ece7032f8 100644 (file)
@@ -381,7 +381,7 @@ public class BrokerFacadeTest {
 
         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);
index a6154e8460e02bcda17db32799cb4c239ac4fcdb..dd0ea449a1d0d6722623c9016f27382e109303e3 100644 (file)
@@ -57,7 +57,7 @@ public class CnSnToXmlAndJsonInstanceIdentifierTest extends YangAndXmlAndDataSch
                     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;
@@ -100,7 +100,7 @@ public class CnSnToXmlAndJsonInstanceIdentifierTest extends YangAndXmlAndDataSch
                     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;
@@ -144,7 +144,7 @@ public class CnSnToXmlAndJsonInstanceIdentifierTest extends YangAndXmlAndDataSch
         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);
     }
index c0b616a63d547cea7eda8ebdcbe7146a64f7bdb7..72e9351ade42a67570b651d4521c0650aaa6dc86 100644 (file)
@@ -82,7 +82,7 @@ public class CutDataToCorrectDepthTest extends JerseyTest {
         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;
@@ -311,8 +311,8 @@ public class CutDataToCorrectDepthTest extends JerseyTest {
                 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() {
index ec0a666fb4e01f5fc9a1cb53ced222275de2ed23..6276457b26ef890c1e851bf0f9ee6205c4c50fc8 100644 (file)
@@ -155,7 +155,7 @@ public class InvokeRpcMethodTest {
         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());
 
@@ -309,7 +309,6 @@ public class InvokeRpcMethodTest {
 
         assertNotNull(rpcDef);
         assertNotNull(rpcInputSchemaNode);
-        assertTrue(rpcInputSchemaNode instanceof ContainerSchemaNode);
         final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> containerBuilder =
                 Builders.containerBuilder(rpcInputSchemaNode);
 
@@ -359,7 +358,6 @@ public class InvokeRpcMethodTest {
         }
         assertNotNull(rpcDef);
         assertNotNull(rpcOutputSchemaNode);
-        assertTrue(rpcOutputSchemaNode instanceof ContainerSchemaNode);
         final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> containerBuilder =
                 Builders.containerBuilder(rpcOutputSchemaNode);
         final DataSchemaNode leafSchema = rpcOutputSchemaNode
index 831fd5541c0d62edbafeaee45166ec0c217e744e..b98176433d627893b7b2b1f875d6e4a2457a97f6 100644 (file)
@@ -92,8 +92,8 @@ public class RestDeleteOperationTest extends JerseyTest {
     @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());
index 86237080677812d5dd842df18407209aad41b598..e993fb490796b67601e43406fa15a2264e7db892 100644 (file)
@@ -8,6 +8,7 @@
 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;
@@ -70,11 +71,9 @@ public class RestconfImplNotificationSubscribingTest {
     @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);
@@ -84,11 +83,9 @@ public class RestconfImplNotificationSubscribingTest {
     @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);
@@ -98,11 +95,9 @@ public class RestconfImplNotificationSubscribingTest {
     @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);
@@ -112,11 +107,9 @@ public class RestconfImplNotificationSubscribingTest {
     @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);
@@ -126,17 +119,13 @@ public class RestconfImplNotificationSubscribingTest {
     @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);
@@ -148,11 +137,9 @@ public class RestconfImplNotificationSubscribingTest {
     @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);
@@ -162,11 +149,9 @@ public class RestconfImplNotificationSubscribingTest {
     @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);
@@ -176,11 +161,9 @@ public class RestconfImplNotificationSubscribingTest {
     @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);
@@ -190,11 +173,9 @@ public class RestconfImplNotificationSubscribingTest {
     @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);
@@ -204,11 +185,9 @@ public class RestconfImplNotificationSubscribingTest {
     @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);
@@ -223,11 +202,9 @@ public class RestconfImplNotificationSubscribingTest {
         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);
index 7d610d00dad08561047e38c9a88c6cb15bb0c48d..fc0a66ad398eb18dc5a41d23a54289cd9ce28901 100644 (file)
@@ -73,7 +73,7 @@ public class NotificationListenerTest {
 
         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);
@@ -93,7 +93,7 @@ public class NotificationListenerTest {
 
         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);
 
@@ -115,7 +115,7 @@ public class NotificationListenerTest {
 
         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);
@@ -139,7 +139,7 @@ public class NotificationListenerTest {
 
         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);
@@ -158,7 +158,7 @@ public class NotificationListenerTest {
 
         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);
 
@@ -172,7 +172,7 @@ public class NotificationListenerTest {
         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);
@@ -184,7 +184,7 @@ public class NotificationListenerTest {
         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");
@@ -219,8 +219,8 @@ public class NotificationListenerTest {
         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");
index 879e2fe4897845183c44310c0980a18c1bc7a952..f32182e07207fc7192398762a1f73d565a05afaf 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.util.concurrent.CheckedFuture;
 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;
@@ -34,16 +35,15 @@ public class RestconfImplTest {
         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());
     }
 }
index ded94ef8342ee6429adc377e4665f35ec3cbd2f2..71e68a221cb06c7f51b1a096e480f957483c5dd0 100644 (file)
@@ -12,7 +12,7 @@ import static org.junit.Assert.assertNull;
 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;
@@ -61,10 +61,7 @@ public class RestconfOperationsServiceTest {
         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);
 
index ba3c43ea9588e4b76dc8faa77c10bce8b97b9ebd..5eceb84945707f1061932dd7ba8e76c46f07542d 100644 (file)
@@ -16,6 +16,7 @@ import com.google.common.util.concurrent.CheckedFuture;
 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;
@@ -40,10 +41,9 @@ public class SchemaContextHandlerTest {
         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 =
index bcb40603a5ea1cdad7aaa1b997b489701833402a..e13a4cd478a9e26a417bdcba50e6a12856e4a46e 100644 (file)
@@ -116,7 +116,7 @@ public class YangInstanceIdentifierDeserializerTest {
                 YangInstanceIdentifier.NodeIdentifier.create(leafList),
                 iterator.next());
         assertEquals("Not expected path argument",
-                new YangInstanceIdentifier.NodeWithValue(leafList, "instance"),
+                new YangInstanceIdentifier.NodeWithValue<>(leafList, "instance"),
                 iterator.next());
     }
 
@@ -209,7 +209,7 @@ public class YangInstanceIdentifierDeserializerTest {
                 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());
     }
 
index 7d5455ffa8c12b6c76e5606d51c7d9f7309c8485..22f2586067cff12407610d23315e8178157f3281 100644 (file)
@@ -89,7 +89,7 @@ public class YangInstanceIdentifierSerializerTest {
                 .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);
@@ -175,7 +175,7 @@ public class YangInstanceIdentifierSerializerTest {
     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);
index e33ea5cbd046502947b559868629cabaa41cc3f5..e8f525bb819f360db03e05fbc51e9363714ee56e 100644 (file)
@@ -37,6 +37,7 @@ import org.mockito.Mockito;
 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;
@@ -178,10 +179,9 @@ public class RestconfDataServiceImplTest {
         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());
index 378e53ae84bd4c2eccfe36aa9f3979ada2ea7b21..10547da8db20d2a8dd772eceaa52f8f1cde38d2c 100644 (file)
@@ -17,6 +17,7 @@ import org.junit.Test;
 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;
@@ -57,10 +58,9 @@ public class RestconfInvokeOperationsServiceImplTest {
         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 =
@@ -71,7 +71,7 @@ public class RestconfInvokeOperationsServiceImplTest {
     @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);
 
index e3ecf2c0af2762d90f222b07f6f6f397362382cb..330d5a24c461ff0b0bfb273741c85d7db0891b0b 100644 (file)
@@ -33,6 +33,8 @@ import org.junit.Test;
 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;
@@ -80,15 +82,15 @@ public class RestconfStreamsSubscriptionServiceImplTest {
         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);
index 5ead74cb6b2978e4782a954c3b205bf0a768907c..5d7845961f128025a0342ecd1fd4575856fadde5 100644 (file)
@@ -101,7 +101,7 @@ public class PatchDataTransactionUtilTest {
                 .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();
index 4dfbe347ecb55c27d81a930020592fd4253dfda6..e796e03e1f7315597005349aaf1bbc3c5071072b 100644 (file)
@@ -85,7 +85,7 @@ public class PostDataTransactionUtilTest {
                 .node(baseQName)
                 .build();
 
-        final LeafNode buildLeaf = Builders.leafBuilder()
+        final LeafNode<?> buildLeaf = Builders.leafBuilder()
                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(leafQname))
                 .withValue(0.2)
                 .build();
@@ -130,7 +130,7 @@ public class PostDataTransactionUtilTest {
         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))
@@ -180,7 +180,7 @@ public class PostDataTransactionUtilTest {
         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))
index c6073ae6d1d3129494c278e8379c7212eb21f39e..8abf3581c82b1a93b7ea2911b49b3f0223235729 100644 (file)
@@ -132,8 +132,8 @@ public class RestconfMappingNodeUtilTest {
             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());
                     }
                 }
             }
@@ -159,7 +159,7 @@ public class RestconfMappingNodeUtilTest {
         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);
@@ -179,7 +179,7 @@ public class RestconfMappingNodeUtilTest {
         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);
@@ -191,17 +191,17 @@ public class RestconfMappingNodeUtilTest {
         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());
             }
@@ -220,7 +220,7 @@ public class RestconfMappingNodeUtilTest {
 
         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());
@@ -231,10 +231,10 @@ public class RestconfMappingNodeUtilTest {
                             .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.",