Fix unit test CS warnings in sal-distributed-datastore
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / utils / NormalizedNodeAggregatorTest.java
index e1764954bcc70740e34bc930ce3859318525d245..f84e51672011ac2e9fb9f0d2f0b3bad3875a20aa 100644 (file)
@@ -10,8 +10,9 @@ package org.opendaylight.controller.cluster.datastore.utils;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+
 import com.google.common.base.Optional;
-import com.google.common.collect.Lists;
+import com.google.common.collect.ImmutableList;
 import com.google.common.util.concurrent.CheckedFuture;
 import java.util.Collection;
 import java.util.concurrent.ExecutionException;
@@ -20,6 +21,7 @@ import org.junit.Test;
 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
 import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
@@ -36,25 +38,27 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 public class NormalizedNodeAggregatorTest {
 
     @Test
-    public void testAggregate() throws InterruptedException, ExecutionException, ReadFailedException, DataValidationFailedException {
+    public void testAggregate() throws InterruptedException, ExecutionException, ReadFailedException,
+            DataValidationFailedException {
         SchemaContext schemaContext = SchemaContextHelper.full();
         NormalizedNode<?, ?> expectedNode1 = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
         NormalizedNode<?, ?> expectedNode2 = ImmutableNodes.containerNode(CarsModel.CARS_QNAME);
 
-        Optional<NormalizedNode<?, ?>> optional = NormalizedNodeAggregator.aggregate(YangInstanceIdentifier.builder().build(),
-                Lists.newArrayList(
+        Optional<NormalizedNode<?, ?>> optional = NormalizedNodeAggregator.aggregate(YangInstanceIdentifier.EMPTY,
+                ImmutableList.of(
                         Optional.<NormalizedNode<?, ?>>of(getRootNode(expectedNode1, schemaContext)),
                         Optional.<NormalizedNode<?, ?>>of(getRootNode(expectedNode2, schemaContext))),
-                schemaContext);
+                schemaContext, LogicalDatastoreType.CONFIGURATION);
 
 
         NormalizedNode<?,?> normalizedNode = optional.get();
 
         assertTrue("Expect value to be a Collection", normalizedNode.getValue() instanceof Collection);
 
+        @SuppressWarnings("unchecked")
         Collection<NormalizedNode<?,?>> collection = (Collection<NormalizedNode<?,?>>) normalizedNode.getValue();
 
-        for(NormalizedNode<?,?> node : collection){
+        for (NormalizedNode<?,?> node : collection) {
             assertTrue("Expected " + node + " to be a ContainerNode", node instanceof ContainerNode);
         }
 
@@ -77,7 +81,7 @@ public class NormalizedNodeAggregatorTest {
 
             DOMStoreWriteTransaction writeTransaction = store.newWriteOnlyTransaction();
 
-            writeTransaction.merge(YangInstanceIdentifier.builder().node(moduleNode.getNodeType()).build(), moduleNode);
+            writeTransaction.merge(YangInstanceIdentifier.of(moduleNode.getNodeType()), moduleNode);
 
             DOMStoreThreePhaseCommitCohort ready = writeTransaction.ready();
 
@@ -88,7 +92,7 @@ public class NormalizedNodeAggregatorTest {
             DOMStoreReadTransaction readTransaction = store.newReadOnlyTransaction();
 
             CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read = readTransaction
-                    .read(YangInstanceIdentifier.builder().build());
+                    .read(YangInstanceIdentifier.EMPTY);
 
             Optional<NormalizedNode<?, ?>> nodeOptional = read.checkedGet();
 
@@ -96,14 +100,13 @@ public class NormalizedNodeAggregatorTest {
         }
     }
 
-    public static NormalizedNode<?,?> findChildWithQName(Collection<NormalizedNode<?, ?>> collection, QName qName) {
-        for(NormalizedNode<?,?> node : collection){
-            if(node.getNodeType().equals(qName)){
+    public static NormalizedNode<?,?> findChildWithQName(Collection<NormalizedNode<?, ?>> collection, QName qname) {
+        for (NormalizedNode<?, ?> node : collection) {
+            if (node.getNodeType().equals(qname)) {
                 return node;
             }
         }
 
         return null;
     }
-
-}
\ No newline at end of file
+}