Migrate test asserts 26/9626/4
authorRobert Varga <rovarga@cisco.com>
Sun, 3 Aug 2014 12:51:21 +0000 (14:51 +0200)
committerRobert Varga <rovarga@cisco.com>
Thu, 7 Aug 2014 16:42:12 +0000 (16:42 +0000)
With update to JUnit 4.11 we need to migrate tests to use
proper non-deprecated methods/classes. Also removes wildcard imports.

Change-Id: I969f482a2dd85242fd32c22e7c5807d643e3e554
Signed-off-by: Robert Varga <rovarga@cisco.com>
29 files changed:
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/NodeWrappedTypeTest.java
code-generator/binding-generator-util/src/test/java/org/opendaylight/yangtools/binding/generator/util/generated/type/builder/AnnotationBuilderTest.java
code-generator/binding-type-provider/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/NodeWrappedTypeTest.java
common/mockito-configuration/src/test/java/org/mockito/configuration/DefaultAnswerTest.java
common/util/src/test/java/org/opendaylight/yangtools/util/concurrent/DeadlockDetectingListeningExecutorServiceTest.java
integration-test/yang-runtime-tests/src/test/java/org/opendaylight/yangtools/it/yang/runtime/tests/RuntimeCodecAugmentationWithGroupingsAndCasesTest.java
model/ietf/ietf-inet-types/src/test/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/inet/types/rev100924/HostBuilderTest.java
restconf/restconf-util/src/test/java/org/opendaylight/yangtools/restconf/utils/Bug1196Test.java
restconf/restconf-util/src/test/java/org/opendaylight/yangtools/restconf/utils/Bug527Test.java
restconf/restconf-util/src/test/java/org/opendaylight/yangtools/restconf/utils/RestconfUtilsTest.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlDocumentUtils.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/test/RpcReplyToDomTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/CompositeNodeTOImplTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/NodeModificationBuilderImplTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlDocumentUtilsTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/xml/XmlStreamUtilsTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/transform/dom/serializer/NormalizedNodeXmlTranslationTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/TreeNodeUtilsTest.java
yang/yang-data-operations/src/test/java/org/opendaylight/yangtools/yang/data/operations/YangDataOperationsTest.java
yang/yang-maven-plugin-it/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/it/YangToSourcesPluginTestIT.java
yang/yang-maven-plugin/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/GenerateSourcesTest.java
yang/yang-maven-plugin/src/test/java/org/opendaylight/yangtools/yang2sources/plugin/UtilTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/Int8Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/YangModelValidationListTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/YangModelValidationModuleTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/YangModelValidationSubModuleTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/YangModelValidationTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/util/ModuleDependencySortTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/util/TopologicalSortTest.java

index 317f02e6d91e077cc44187b9ca2900210c1af692..e6d895d69eef48e418ffc0bed72d0d548f434596 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.yangtools.sal.binding.yang.types;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 
index 63f91d575586d94efb38db5c46030b05e5bbc7df..f71399441d9091e7c7562b8df5e444e3a36181f4 100644 (file)
@@ -7,7 +7,10 @@
  */
 package org.opendaylight.yangtools.binding.generator.util.generated.type.builder;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 import java.util.List;
index 317f02e6d91e077cc44187b9ca2900210c1af692..e6d895d69eef48e418ffc0bed72d0d548f434596 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.yangtools.sal.binding.yang.types;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 
index c2019ed67c187b2d1f370fb881189b4089e3db81..a478dc1b6fc73db0dabc8b81ecc5a4b90f2d2306 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.mockito.configuration;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 import java.io.Closeable;
 import java.io.IOException;
@@ -16,18 +17,14 @@ import org.junit.Test;
 import org.mockito.Mockito;
 
 public class DefaultAnswerTest {
-
-       @Test
-       public void testAnswering() throws IOException {
-               Closeable mock = Mockito.mock(Closeable.class);
-               try {
-                       mock.close();
-                       fail();
-               } catch (UnstubbedMethodException e) {
-                       assertEquals("closeable.close(); was not stubbed", e.getMessage());
-               }
-       }
-
-
-
+    @Test
+    public void testAnswering() throws IOException {
+        Closeable mock = Mockito.mock(Closeable.class);
+        try {
+            mock.close();
+            fail();
+        } catch (UnstubbedMethodException e) {
+            assertEquals("closeable.close(); was not stubbed", e.getMessage());
+        }
+    }
 }
index 6bba351dcabb28a56a7c3cf434c32f29b63adfae..f35a977528d78f2c0dd7f1b1b692e2757c9e7a74 100644 (file)
@@ -8,7 +8,20 @@
 
 package org.opendaylight.yangtools.util.concurrent;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.opendaylight.yangtools.util.concurrent.AsyncNotifyingListeningExecutorServiceTest.testListenerCallback;
+import static org.opendaylight.yangtools.util.concurrent.CommonTestUtils.SUBMIT_CALLABLE;
+import static org.opendaylight.yangtools.util.concurrent.CommonTestUtils.SUBMIT_RUNNABLE;
+import static org.opendaylight.yangtools.util.concurrent.CommonTestUtils.SUBMIT_RUNNABLE_WITH_RESULT;
+
+import com.google.common.base.Function;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
 
 import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
@@ -21,19 +34,7 @@ import java.util.concurrent.atomic.AtomicReference;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
-import static org.opendaylight.yangtools.util.concurrent.AsyncNotifyingListeningExecutorServiceTest.testListenerCallback;
-import static org.opendaylight.yangtools.util.concurrent.CommonTestUtils.Invoker;
-import static org.opendaylight.yangtools.util.concurrent.CommonTestUtils.SUBMIT_CALLABLE;
-import static org.opendaylight.yangtools.util.concurrent.CommonTestUtils.SUBMIT_RUNNABLE;
-import static org.opendaylight.yangtools.util.concurrent.CommonTestUtils.SUBMIT_RUNNABLE_WITH_RESULT;
+import org.opendaylight.yangtools.util.concurrent.CommonTestUtils.Invoker;
 
 /**
  * Unit tests for DeadlockDetectingListeningExecutorService.
@@ -48,14 +49,14 @@ public class DeadlockDetectingListeningExecutorServiceTest {
 
     static final InitialInvoker SUBMIT = new InitialInvoker() {
         @Override
-        public void invokeExecutor( ListeningExecutorService executor, Runnable task ) {
+        public void invokeExecutor( final ListeningExecutorService executor, final Runnable task ) {
             executor.submit( task );
         }
     };
 
     static final InitialInvoker EXECUTE = new InitialInvoker() {
         @Override
-        public void invokeExecutor( ListeningExecutorService executor, Runnable task ) {
+        public void invokeExecutor( final ListeningExecutorService executor, final Runnable task ) {
             executor.execute( task );
         }
     };
@@ -66,7 +67,7 @@ public class DeadlockDetectingListeningExecutorServiceTest {
 
     public static Function<Void, Exception> DEADLOCK_EXECUTOR_FUNCTION = new Function<Void, Exception>() {
         @Override
-        public Exception apply( Void notUsed ) {
+        public Exception apply( final Void notUsed ) {
             return new TestDeadlockException();
         }
     };
@@ -136,8 +137,8 @@ public class DeadlockDetectingListeningExecutorServiceTest {
         testNonBlockingSubmitOnExecutorThread( EXECUTE, SUBMIT_CALLABLE );
     }
 
-    void testNonBlockingSubmitOnExecutorThread( InitialInvoker initialInvoker,
-                                                final Invoker invoker ) throws Throwable {
+    void testNonBlockingSubmitOnExecutorThread( final InitialInvoker initialInvoker,
+            final Invoker invoker ) throws Throwable {
 
         final AtomicReference<Throwable> caughtEx = new AtomicReference<>();
         final CountDownLatch futureCompletedLatch = new CountDownLatch( 1 );
@@ -149,12 +150,12 @@ public class DeadlockDetectingListeningExecutorServiceTest {
 
                 Futures.addCallback( invoker.invokeExecutor( executor, null ), new FutureCallback() {
                     @Override
-                    public void onSuccess( Object result ) {
+                    public void onSuccess( final Object result ) {
                         futureCompletedLatch.countDown();
                     }
 
                     @Override
-                    public void onFailure( Throwable t ) {
+                    public void onFailure( final Throwable t ) {
                         caughtEx.set( t );
                         futureCompletedLatch.countDown();
                     }
@@ -166,7 +167,7 @@ public class DeadlockDetectingListeningExecutorServiceTest {
         initialInvoker.invokeExecutor( executor, task );
 
         assertTrue( "Task did not complete - executor likely deadlocked",
-                    futureCompletedLatch.await( 5, TimeUnit.SECONDS ) );
+                futureCompletedLatch.await( 5, TimeUnit.SECONDS ) );
 
         if( caughtEx.get() != null ) {
             throw caughtEx.get();
@@ -185,8 +186,8 @@ public class DeadlockDetectingListeningExecutorServiceTest {
         testBlockingSubmitOnExecutorThread( EXECUTE, SUBMIT_CALLABLE );
     }
 
-    void testBlockingSubmitOnExecutorThread( InitialInvoker initialInvoker,
-                                             final Invoker invoker ) throws Exception {
+    void testBlockingSubmitOnExecutorThread( final InitialInvoker initialInvoker,
+            final Invoker invoker ) throws Exception {
 
         final AtomicReference<Throwable> caughtEx = new AtomicReference<>();
         final CountDownLatch latch = new CountDownLatch( 1 );
@@ -211,7 +212,7 @@ public class DeadlockDetectingListeningExecutorServiceTest {
         initialInvoker.invokeExecutor( executor, task );
 
         assertTrue( "Task did not complete - executor likely deadlocked",
-                    latch.await( 5, TimeUnit.SECONDS ) );
+                latch.await( 5, TimeUnit.SECONDS ) );
 
         assertNotNull( "Expected exception thrown", caughtEx.get() );
         assertEquals( "Caught exception type", TestDeadlockException.class, caughtEx.get().getClass() );
@@ -227,7 +228,7 @@ public class DeadlockDetectingListeningExecutorServiceTest {
         executor = new DeadlockDetectingListeningExecutorService(
                 Executors.newSingleThreadExecutor(
                         new ThreadFactoryBuilder().setNameFormat( "SingleThread" ).build() ),
-                DEADLOCK_EXECUTOR_FUNCTION, listenerExecutor );
+                        DEADLOCK_EXECUTOR_FUNCTION, listenerExecutor );
 
         try {
             testListenerCallback( executor, SUBMIT_CALLABLE, listenerThreadPrefix );
index 2e8b046fa46f5d0d6aaba02eca6e09aaa9817078..a642b690c29afa6b60b56c678c53e519f10aa02e 100644 (file)
@@ -1,8 +1,10 @@
 package org.opendaylight.yangtools.it.yang.runtime.tests;
 
-import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import com.google.common.base.Optional;
+
 import java.util.AbstractMap.SimpleEntry;
 import java.util.Map.Entry;
 
@@ -25,8 +27,6 @@ import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-import com.google.common.base.Optional;
-
 public class RuntimeCodecAugmentationWithGroupingsAndCasesTest {
 
     private static final InstanceIdentifier<ExtWithGroupingAugmentations> GROUPING_AUGMENTATIONS_PATH = InstanceIdentifier
@@ -63,12 +63,12 @@ public class RuntimeCodecAugmentationWithGroupingsAndCasesTest {
     public void testSerialization() {
 
         ExtWithGroupingAugmentations caseData = new ExtWithGroupingAugmentationsBuilder() //
-                .setGroupingData(new GroupingDataBuilder() //
-                        .addAugmentation(InUsesAugment.class, new InUsesAugmentBuilder() //
-                                .setExtAumentation("InUses") //
-                                .build()) //
-                        .build()) //
-                .build();
+        .setGroupingData(new GroupingDataBuilder() //
+        .addAugmentation(InUsesAugment.class, new InUsesAugmentBuilder() //
+        .setExtAumentation("InUses") //
+        .build()) //
+        .build()) //
+        .build();
 
         Entry<org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, CompositeNode> result = mappingService
                 .toDataDom(new SimpleEntry(GROUPING_AUGMENTATIONS_PATH, caseData));
index fa316d174adb9c9763e3b4e1230653959bfaf439..1339fc06cf7e101ae6d1e1183a5c6aabeb9721db 100644 (file)
@@ -8,7 +8,8 @@
 
 package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924;
 
-import junit.framework.Assert;
+import static org.junit.Assert.assertEquals;
+
 import org.junit.Test;
 
 public class HostBuilderTest {
@@ -16,7 +17,7 @@ public class HostBuilderTest {
     @Test
     public void testGetDefaultInstanceIpv4() throws Exception {
         Host host = HostBuilder.getDefaultInstance("127.0.0.1");
-        Assert.assertEquals(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))), host);
+        assertEquals(new Host(new IpAddress(new Ipv4Address("127.0.0.1"))), host);
     }
 
     @Test
@@ -25,14 +26,14 @@ public class HostBuilderTest {
         testIpv6("2001:db8:85a3::8a2e:370:7334");
     }
 
-    private void testIpv6(String ivp6string) {
+    private void testIpv6(final String ivp6string) {
         Host host = HostBuilder.getDefaultInstance(ivp6string);
-        Assert.assertEquals(new Host(new IpAddress(new Ipv6Address(ivp6string))), host);
+        assertEquals(new Host(new IpAddress(new Ipv6Address(ivp6string))), host);
     }
 
     @Test
     public void testGetDefaultInstanceDomain() throws Exception {
         Host host = HostBuilder.getDefaultInstance("localhost");
-        Assert.assertEquals(new Host(new DomainName("localhost")), host);
+        assertEquals(new Host(new DomainName("localhost")), host);
     }
 }
\ No newline at end of file
index a1b2488144764ca306d67cf00af994175c8d2c72..20c68aeb31e7cb5ca107a1c858ac3141edebeacf 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.yangtools.restconf.utils;
 
-import static junit.framework.Assert.assertNotNull;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import java.io.InputStream;
 import java.util.AbstractMap.SimpleEntry;
index 1bbbe8d6fd65333f9877959a39676c661ec06c1d..6d66f9261f61807c34e7a42a7ee509a1b58aa7f3 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.yangtools.restconf.utils;
 
-import static junit.framework.Assert.assertNotNull;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
 import java.io.InputStream;
index e9131fbd43959f5b000acb538f4fa4c75efabeb5..0ba364f74f21b0d84cf71d0b143907480153c21b 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.yangtools.restconf.utils;
 
-import static junit.framework.Assert.assertNotNull;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import java.io.InputStream;
 
index 17d4e31919cb2d6302eb3a51beccaed821cc4173..f0d82c33b9829ee97e85d063c2fcff0b40a27a94 100644 (file)
@@ -17,8 +17,13 @@ import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
 
 import java.net.URI;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Set;
 
 import javax.activation.UnsupportedDataTypeException;
 import javax.xml.parsers.DocumentBuilder;
@@ -38,7 +43,19 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
 import org.opendaylight.yangtools.yang.data.impl.SimpleNodeTOImpl;
 import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec;
-import org.opendaylight.yangtools.yang.model.api.*;
+import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -406,14 +423,14 @@ public class XmlDocumentUtils {
      * returns <code>null</code>
      */
     public static CompositeNode rpcReplyToDomNodes(final Document document, final QName rpcName,
-        final SchemaContext context) {
+            final SchemaContext context) {
         Preconditions.checkNotNull(document);
         Preconditions.checkNotNull(rpcName);
         Preconditions.checkNotNull(context);
 
         Optional<RpcDefinition> rpcDefinition = findRpc(rpcName, context);
         if (rpcDefinition.isPresent()) {
-             RpcDefinition rpc = rpcDefinition.get();
+            RpcDefinition rpc = rpcDefinition.get();
 
             final Collection<DataSchemaNode> outputNode = rpc.getOutput().getChildNodes();
             final Element rpcReplyElement = document.getDocumentElement();
@@ -422,7 +439,7 @@ public class XmlDocumentUtils {
             if (RPC_REPLY_QNAME.equals(partialQName)) {
                 final List<Node<?>> domNodes = toDomNodes(rpcReplyElement, Optional.fromNullable(outputNode), context);
                 List<Node<?>> rpcOutNodes = Collections.<Node<?>>singletonList(ImmutableCompositeNode.create(
-                    rpc.getOutput().getQName(), domNodes));
+                        rpc.getOutput().getQName(), domNodes));
                 return ImmutableCompositeNode.create(rpcName, rpcOutNodes);
             }
         }
@@ -437,7 +454,7 @@ public class XmlDocumentUtils {
      * @param context Schema Context
      * @return Rpc Definition if is present within given Schema Context, otherwise returns Optional.absent().
      */
-    private static Optional<RpcDefinition> findRpc(QName rpc, SchemaContext context) {
+    private static Optional<RpcDefinition> findRpc(final QName rpc, final SchemaContext context) {
         Preconditions.checkNotNull(rpc);
         Preconditions.checkNotNull(context);
         for (final RpcDefinition rpcDefinition : context.getOperations()) {
index e7a42614ae529ad09bb13b304f270e2f8ee96de5..32134ddf907759914c4c0f409ccd071c3fbc7c87 100644 (file)
@@ -7,17 +7,19 @@
  */
 package org.opendaylight.yangtools.yang.data.codec.xml.test;
 
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
+
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -63,7 +65,7 @@ public class RpcReplyToDomTest {
     @Before
     public void setup() throws Exception {
         final List<InputStream> modelsToParse = Collections
-            .singletonList(getClass().getResourceAsStream(RES_SCHEMA_DIR + "/rpc-test-model.yang"));
+                .singletonList(getClass().getResourceAsStream(RES_SCHEMA_DIR + "/rpc-test-model.yang"));
         assertNotNull(modelsToParse);
         assertNotNull(modelsToParse.get(0));
 
@@ -86,7 +88,7 @@ public class RpcReplyToDomTest {
         assertNotNull(testPayload2);
     }
 
-    private static Document readXmlToDocument(InputStream xmlContent) throws SAXException, IOException {
+    private static Document readXmlToDocument(final InputStream xmlContent) throws SAXException, IOException {
         DocumentBuilder dBuilder;
         try {
             dBuilder = BUILDER_FACTORY.newDocumentBuilder();
@@ -102,7 +104,7 @@ public class RpcReplyToDomTest {
     @Test
     public void test() {
         final CompositeNode rockNode = XmlDocumentUtils
-            .rpcReplyToDomNodes(testPayload1, ROCK_THE_HOUSE_QNAME, schemaContext);
+                .rpcReplyToDomNodes(testPayload1, ROCK_THE_HOUSE_QNAME, schemaContext);
         assertNotNull(rockNode);
 
         final String namespace = "org:opendaylight:rpc-reply:test:ns:yang";
@@ -112,25 +114,25 @@ public class RpcReplyToDomTest {
         assertNotNull(output);
 
         final SimpleNode<?> zipCode = output.getFirstSimpleByName(
-            QName.create(namespace, revision, "zip-code"));
+                QName.create(namespace, revision, "zip-code"));
         assertNotNull(zipCode);
 
         final CompositeNode activNode = XmlDocumentUtils
-            .rpcReplyToDomNodes(testPayload2, ACTIV_SW_IMAGE_QNAME, schemaContext);
+                .rpcReplyToDomNodes(testPayload2, ACTIV_SW_IMAGE_QNAME, schemaContext);
         assertNotNull(activNode);
 
         output = activNode.getFirstCompositeByName(RPC_OUTPUT_QNAME);
         assertNotNull(output);
 
         final CompositeNode imgProps = output
-            .getFirstCompositeByName(QName.create(namespace, revision, "image-properties"));
+                .getFirstCompositeByName(QName.create(namespace, revision, "image-properties"));
         assertNotNull(imgProps);
         final CompositeNode imgProperty = imgProps
-            .getFirstCompositeByName(QName.create(namespace, revision, "image-property"));
+                .getFirstCompositeByName(QName.create(namespace, revision, "image-property"));
         assertNotNull(imgProperty);
 
         final SimpleNode<?> imgId = imgProperty
-            .getFirstSimpleByName(QName.create(namespace, revision, "image-id"));
+                .getFirstSimpleByName(QName.create(namespace, revision, "image-id"));
         assertNotNull(imgId);
     }
 }
index 7e06c8439e404b157288b2297a6ad498a3ae3a97..70bffc08bdaa17a31b6f2a61345cbe9bf78ba41a 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.data.impl;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 import java.util.List;
index 5c1d53bc50460bdddc4493bd9807fa42524e939d..70c2c81ab15fc63ca1771f693b5deb6f2758a68b 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.data.impl;
 
+import static org.junit.Assert.assertSame;
+
 import java.net.URI;
 import java.util.Date;
 
-import junit.framework.Assert;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -81,7 +81,7 @@ public class NodeModificationBuilderImplTest {
         Node<?> mutableEquivalent = nodeModificationBuilder.getMutableEquivalent(topologies);
         CompositeNode topologiesMutable = rootMutable.getCompositesByName("topologies").iterator().next();
 
-        Assert.assertSame(topologiesMutable, mutableEquivalent);
+        assertSame(topologiesMutable, mutableEquivalent);
     }
 
     /**
index 8ee05ff447de3b1871101c7adc9eb3c203bacd99..b716c8cbe7d605b3dba073d15309752f00ead2f7 100644 (file)
@@ -8,18 +8,22 @@
 
 package org.opendaylight.yangtools.yang.data.impl.codec.xml;
 
+import static org.junit.Assert.assertEquals;
+
 import com.google.common.base.Charsets;
 import com.google.common.base.Optional;
 import com.google.common.collect.Lists;
 import com.google.common.io.ByteSource;
+
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+
 import javax.activation.UnsupportedDataTypeException;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
-import junit.framework.Assert;
+
 import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Before;
 import org.junit.Test;
@@ -77,7 +81,7 @@ public class XmlDocumentUtilsTest {
 
         final CompositeNode node = inputXmlToCompositeNode(input);
         final SimpleNode<?> refParsed = node.getSimpleNodesByName("ref").iterator().next();
-        Assert.assertEquals(YangInstanceIdentifier.class, refParsed.getValue().getClass());
+        assertEquals(YangInstanceIdentifier.class, refParsed.getValue().getClass());
         final Document serializedDocument = inputCompositeNodeToXml(node);
 
         XMLUnit.compareXML(inputDocument, serializedDocument);
index 1a35875eadaa51e8752b8e26b006f4541d4daf22..dbdfadb3453218f70ea1b3d36d2695e268481d2d 100644 (file)
@@ -8,15 +8,20 @@
 
 package org.opendaylight.yangtools.yang.data.impl.codec.xml;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 import com.google.common.base.Optional;
 import com.google.common.collect.Maps;
+
 import java.io.ByteArrayOutputStream;
 import java.net.URI;
 import java.util.AbstractMap;
 import java.util.Map;
+
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamWriter;
-import junit.framework.Assert;
+
 import org.custommonkey.xmlunit.Diff;
 import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Test;
@@ -51,7 +56,7 @@ public class XmlStreamUtilsTest {
         final String xmlAsString = new String(out.toByteArray());
 
         final Map<String, String> mappedPrefixes = mapPrefixed(randomPrefix.getPrefixes());
-        Assert.assertEquals(2, mappedPrefixes.size());
+        assertEquals(2, mappedPrefixes.size());
         final String randomPrefixValue = mappedPrefixes.get("namespace2");
 
         final String expectedXmlAsString = "<element xmlns:prefix=\"namespace\" prefix:attr=\"value\" xmlns:" + randomPrefixValue + "=\"namespace2\" " + randomPrefixValue + ":attr=\"value\"></element>";
@@ -62,7 +67,7 @@ public class XmlStreamUtilsTest {
         final Diff diff = XMLUnit.compareXML(control, test);
 
         final boolean identical = diff.identical();
-        Assert.assertTrue("Xml differs: " + diff.toString(), identical);
+        assertTrue("Xml differs: " + diff.toString(), identical);
     }
 
     private Map<String, String> mapPrefixed(final Iterable<Map.Entry<URI, String>> prefixes) {
index 47bc9ea5437f7f4098b51a6b693e081ac705f6fc..8979339abbb159610674b4fbe7616149f0840b5c 100644 (file)
@@ -239,7 +239,7 @@ public class NormalizedNodeXmlTranslationTest {
                         Collections.singletonList(doc.getDocumentElement()), containerNode);
 
         if (expectedNode != null) {
-            junit.framework.Assert.assertEquals(expectedNode, built);
+            org.junit.Assert.assertEquals(expectedNode, built);
         }
 
         logger.info("{}", built);
index cba1f506b245e1b017421a7e55e8ad92627b2cf8..bc1f6cef4f50f835268179cf855b7093f63d7778 100644 (file)
@@ -1,7 +1,18 @@
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
+
 import com.google.common.base.Optional;
-import junit.framework.Assert;
+
+import java.util.Map;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -16,11 +27,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Map;
-
-import static org.junit.Assert.*;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.*;
-
 
 public class TreeNodeUtilsTest {
     private static final Logger LOG = LoggerFactory.getLogger(TreeNodeUtilsTest.class);
@@ -48,7 +54,7 @@ public class TreeNodeUtilsTest {
                     .withChild(mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_ONE_NAME)) //
                     .withChild(mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_TWO_NAME)) //
                     .build()) //
-            .build();
+                    .build();
 
     private SchemaContext schemaContext;
     private RootModificationApplyOperation rootOper;
@@ -74,8 +80,8 @@ public class TreeNodeUtilsTest {
                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
                 .withChild(
                         mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
-                                .withChild(mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
-                                .withChild(BAR_NODE).build()).build();
+                        .withChild(mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID))
+                        .withChild(BAR_NODE).build()).build();
     }
 
     private static <T> T assertPresentAndType(final Optional<?> potential, final Class<T> type) {
@@ -103,7 +109,7 @@ public class TreeNodeUtilsTest {
                 .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 3) //
                 .build();
         Optional<TreeNode> node = TreeNodeUtils.findNode(rootNode, outerList1InvalidPath);
-        Assert.assertFalse(node.isPresent());
+        assertFalse(node.isPresent());
     }
 
     @Test
@@ -117,7 +123,7 @@ public class TreeNodeUtilsTest {
         } catch (IllegalArgumentException e) {
             fail("Illegal argument exception was thrown and should not have been" + e.getMessage());
         }
-        Assert.assertNotNull(foundNode);
+        assertNotNull(foundNode);
     }
 
     @Test
@@ -144,7 +150,7 @@ public class TreeNodeUtilsTest {
         Optional<TreeNode> expectedNode = TreeNodeUtils.findNode(rootNode, TWO_TWO_PATH);
         assertPresentAndType(expectedNode, TreeNode.class);
         Map.Entry<YangInstanceIdentifier, TreeNode> actualNode = TreeNodeUtils.findClosest(rootNode, TWO_TWO_PATH);
-        Assert.assertEquals("Expected node and actual node are not the same", expectedNode.get(), actualNode.getValue());
+        assertEquals("Expected node and actual node are not the same", expectedNode.get(), actualNode.getValue());
     }
 
     @Test
@@ -162,7 +168,7 @@ public class TreeNodeUtilsTest {
         Optional<TreeNode> expectedNode = TreeNodeUtils.findNode(rootNode, outerListInnerListPath);
         assertPresentAndType(expectedNode, TreeNode.class);
         Map.Entry<YangInstanceIdentifier, TreeNode> actualNode = TreeNodeUtils.findClosest(rootNode, twoTwoInvalidPath);
-        Assert.assertEquals("Expected node and actual node are not the same", expectedNode.get(), actualNode.getValue());
+        assertEquals("Expected node and actual node are not the same", expectedNode.get(), actualNode.getValue());
     }
 
     @Test
@@ -182,6 +188,6 @@ public class TreeNodeUtilsTest {
         TreeNode rootNode = inMemoryDataTreeSnapshot.getRootNode();
         Optional<TreeNode> node = TreeNodeUtils.getChild(Optional.fromNullable(rootNode),
                 TestModel.OUTER_LIST_PATH.getLastPathArgument());
-        Assert.assertFalse(node.isPresent());
+        assertFalse(node.isPresent());
     }
 }
index 5b56f0c74ab0941bbbdde7497796a1332c6e1c34..bebee24315bc0cef52fbf13d492e6b71643b4a30 100644 (file)
@@ -7,6 +7,16 @@
  */
 package org.opendaylight.yangtools.yang.data.operations;
 
+import static org.junit.Assert.assertNull;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+import com.google.common.io.Files;
+
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -48,14 +58,6 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
-import com.google.common.base.Charsets;
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-import com.google.common.io.Files;
-
 @RunWith(Parameterized.class)
 public class YangDataOperationsTest {
 
@@ -74,28 +76,28 @@ public class YangDataOperationsTest {
     @Parameterized.Parameters()
     public static Collection<Object[]> data() {
         return Arrays.asList(new Object[][] {
-            // Container
-            { "/containerTest_createContainer" },
-            { "/containerTest_deleteContainer" },
-            { "/containerTest_innerContainerContainer" },
-            { "/containerTest_innerLeavesBaseOperationsContainer" },
-            { "/containerTest_noneContainer" },
-            { "/containerTest_removeContainer"},
-            { "/containerTest_replaceContainer"},
-            { "/containerTest_choiceActualModificationSameCase"},
-            { "/containerTest_choiceActualModificationDifferentCases"},
-            { "/containerTest_choiceActualOneCaseModificationOtherCase"},
-//            LeafList
-            { "/leafListTest" },
-            // List
-            { "/listTest" },
-            // Additional
-            {"/none_NoChange"},
-            {"/listTest_alterInnerValue"}
+                // Container
+                { "/containerTest_createContainer" },
+                { "/containerTest_deleteContainer" },
+                { "/containerTest_innerContainerContainer" },
+                { "/containerTest_innerLeavesBaseOperationsContainer" },
+                { "/containerTest_noneContainer" },
+                { "/containerTest_removeContainer"},
+                { "/containerTest_replaceContainer"},
+                { "/containerTest_choiceActualModificationSameCase"},
+                { "/containerTest_choiceActualModificationDifferentCases"},
+                { "/containerTest_choiceActualOneCaseModificationOtherCase"},
+                //            LeafList
+                { "/leafListTest" },
+                // List
+                { "/listTest" },
+                // Additional
+                {"/none_NoChange"},
+                {"/listTest_alterInnerValue"}
         });
     }
 
-    public YangDataOperationsTest(String testDir) throws Exception {
+    public YangDataOperationsTest(final String testDir) throws Exception {
         SchemaContext schema = parseTestSchema();
         containerNode = (ContainerSchemaNode) getSchemaNode(schema, "test", "container");
         this.testDirName = testDir;
@@ -127,13 +129,13 @@ public class YangDataOperationsTest {
         if (result.isPresent()) {
             verifyModificationResult(result, expectedResult);
         } else {
-            junit.framework.Assert.assertNull("Result of modification is empty node, result xml should not be present "
+            assertNull("Result of modification is empty node, result xml should not be present "
                     + expectedResultXmlPath, getClass().getResourceAsStream(expectedResultXmlPath));
         }
 
     }
 
-    private ModifyAction loadModifyAction(String path) throws Exception {
+    private ModifyAction loadModifyAction(final String path) throws Exception {
         URL resource = getClass().getResource(path);
         if (resource == null) {
             return ModifyAction.MERGE;
@@ -142,7 +144,7 @@ public class YangDataOperationsTest {
         return ModifyAction.fromXmlValue(Files.toString(new File(resource.toURI()), Charsets.UTF_8).trim());
     }
 
-    private void verifyModificationResult(Optional<ContainerNode> result, Optional<ContainerNode> expectedResult)
+    private void verifyModificationResult(final Optional<ContainerNode> result, final Optional<ContainerNode> expectedResult)
             throws UnsupportedDataTypeException {
         Assert.assertEquals(
                 String.format(
@@ -151,7 +153,7 @@ public class YangDataOperationsTest {
                         toString(toDom(expectedResult.get()))), expectedResult.get(), result.get());
     }
 
-    private Element toDom(ContainerNode container) {
+    private Element toDom(final ContainerNode container) {
         Iterable<Element> a =
                 DomFromNormalizedNodeSerializerFactory.getInstance(newDocument(), DomUtils.defaultValueCodecProvider())
                 .getContainerNodeSerializer().serialize(containerNode, container);
@@ -166,7 +168,7 @@ public class YangDataOperationsTest {
         }
     }
 
-    private Optional<ContainerNode> loadXmlToCompositeNode(String xmlPath) throws IOException, SAXException {
+    private Optional<ContainerNode> loadXmlToCompositeNode(final String xmlPath) throws IOException, SAXException {
         InputStream resourceAsStream = getClass().getResourceAsStream(xmlPath);
         if (resourceAsStream == null) {
             return Optional.absent();
@@ -189,21 +191,22 @@ public class YangDataOperationsTest {
 
         return Lists.newArrayList(Collections2.transform(Lists.newArrayList("/schemas/test.yang"),
                 new Function<String, InputStream>() {
-                    @Override
-                    public InputStream apply(String input) {
-                        InputStream resourceAsStream = getClass().getResourceAsStream(input);
-                        Preconditions.checkNotNull(resourceAsStream, "File %s was null", resourceAsStream);
-                        return resourceAsStream;
-                    }
-                }));
+            @Override
+            public InputStream apply(final String input) {
+                InputStream resourceAsStream = getClass().getResourceAsStream(input);
+                Preconditions.checkNotNull(resourceAsStream, "File %s was null", resourceAsStream);
+                return resourceAsStream;
+            }
+        }));
     }
 
-    DataSchemaNode getSchemaNode(SchemaContext context, String moduleName, String childNodeName) {
+    DataSchemaNode getSchemaNode(final SchemaContext context, final String moduleName, final String childNodeName) {
         for (Module module : context.getModules()) {
             if (module.getName().equals(moduleName)) {
                 for (DataSchemaNode dataSchemaNode : module.getChildNodes()) {
-                    if (dataSchemaNode.getQName().getLocalName().equals(childNodeName))
+                    if (dataSchemaNode.getQName().getLocalName().equals(childNodeName)) {
                         return dataSchemaNode;
+                    }
                 }
             }
         }
@@ -222,7 +225,7 @@ public class YangDataOperationsTest {
         BUILDERFACTORY = factory;
     }
 
-    private Document readXmlToDocument(InputStream xmlContent) throws IOException, SAXException {
+    private Document readXmlToDocument(final InputStream xmlContent) throws IOException, SAXException {
         DocumentBuilder dBuilder;
         try {
             dBuilder = BUILDERFACTORY.newDocumentBuilder();
@@ -235,7 +238,7 @@ public class YangDataOperationsTest {
         return doc;
     }
 
-    public static String toString(Element xml) {
+    public static String toString(final Element xml) {
         try {
             Transformer transformer = TransformerFactory.newInstance().newTransformer();
             transformer.setOutputProperty(OutputKeys.INDENT, "yes");
index 45fe983d0aa180af63a9cf8b834f8267cea4498a..381274a098c72740672a40ece39870d42439c393 100644 (file)
@@ -7,11 +7,12 @@
  */
 package org.opendaylight.yangtools.yang2sources.plugin.it;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
 
 import com.google.common.base.Joiner;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
@@ -20,6 +21,7 @@ import java.net.URL;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
+
 import org.apache.maven.it.VerificationException;
 import org.apache.maven.it.Verifier;
 import org.junit.Test;
@@ -59,9 +61,9 @@ public class YangToSourcesPluginTestIT {
                 + "files marked as resources: META-INF/yang");
         v.verifyTextInLog(
                 Joiner.on(File.separator).join(
-                Arrays.asList("target", "generated-sources", "spi"))
+                        Arrays.asList("target", "generated-sources", "spi"))
 
-                + " marked as resources for generator: org.opendaylight.yangtools.yang2sources.spi.CodeGeneratorTestImpl");
+                        + " marked as resources for generator: org.opendaylight.yangtools.yang2sources.spi.CodeGeneratorTestImpl");
     }
 
     @Test
@@ -93,7 +95,7 @@ public class YangToSourcesPluginTestIT {
         v.verifyTextInLog("[WARNING] Naming conflict for type 'org.opendaylight.yang.gen.v1.urn.yang.test.rev140303.NetworkTopologyRef': file with same name already exists and will not be generated.");
     }
 
-    static void verifyCorrectLog(Verifier v) throws VerificationException {
+    static void verifyCorrectLog(final Verifier v) throws VerificationException {
         v.verifyErrorFreeLog();
         v.verifyTextInLog("[INFO] yang-to-sources: YANG files parsed from");
         v.verifyTextInLog("[INFO] yang-to-sources: Code generator instantiated from org.opendaylight.yangtools.yang2sources.spi.CodeGeneratorTestImpl");
@@ -130,19 +132,20 @@ public class YangToSourcesPluginTestIT {
         v.verifyTextInLog("[INFO] yang-to-sources: No input files found");
     }
 
-    static void assertVerificationException(VerificationException e,
-            String string) {
+    static void assertVerificationException(final VerificationException e,
+            final String string) {
         assertThat(e.getMessage(), containsString(string));
     }
 
-    static Verifier setUp(String project, boolean ignoreF)
+    static Verifier setUp(final String project, final boolean ignoreF)
             throws VerificationException, URISyntaxException {
         final URL path = YangToSourcesPluginTestIT.class.getResource("/"
                 + project + "pom.xml");
         File parent = new File(path.toURI());
         Verifier verifier = new Verifier(parent.getParent());
-        if (ignoreF)
+        if (ignoreF) {
             verifier.addCliOption("-fn");
+        }
         verifier.setMavenDebug(true);
         verifier.executeGoal("generate-sources");
         return verifier;
@@ -163,7 +166,7 @@ public class YangToSourcesPluginTestIT {
 
         Properties sp = new Properties();
         try (InputStream is = new FileInputStream(v1.getBasedir() + "/it-project.properties")) {
-             sp.load(is);
+            sp.load(is);
         }
         String buildDir = sp.getProperty("target.dir");
 
@@ -178,7 +181,7 @@ public class YangToSourcesPluginTestIT {
 
         sp = new Properties();
         try (InputStream is = new FileInputStream(v2.getBasedir() + "/it-project.properties")) {
-             sp.load(is);
+            sp.load(is);
         }
         buildDir = sp.getProperty("target.dir");
 
index c2616caeed9450f2a11f674639c07d74444f5a91..1200e16cc5a2a1660d3348348189d3e9d2d37160 100644 (file)
@@ -7,11 +7,17 @@
  */
 package org.opendaylight.yangtools.yang2sources.plugin;
 
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
-import static org.junit.matchers.JUnitMatchers.containsString;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+import com.google.common.collect.Lists;
 
 import java.io.File;
 import java.io.IOException;
@@ -33,8 +39,6 @@ import org.opendaylight.yangtools.yang2sources.plugin.ConfigArg.CodeGeneratorArg
 import org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.YangProvider;
 import org.opendaylight.yangtools.yang2sources.spi.CodeGenerator;
 
-import com.google.common.collect.Lists;
-
 public class GenerateSourcesTest {
 
     private String yang;
@@ -68,9 +72,9 @@ public class GenerateSourcesTest {
     @Test
     public void test() throws Exception {
         mojo.execute();
-        assertThat(GeneratorMock.called, is(1));
-        assertThat(GeneratorMock.outputDir, is(outDir));
-        assertThat(GeneratorMock.project, is(project));
+        assertEquals(1, GeneratorMock.called);
+        assertEquals(outDir, GeneratorMock.outputDir);
+        assertEquals(project, GeneratorMock.project);
         assertNotNull(GeneratorMock.log);
         assertTrue(GeneratorMock.additionalCfg.isEmpty());
         assertThat(GeneratorMock.resourceBaseDir.toString(), containsString("target" + File.separator
@@ -87,7 +91,7 @@ public class GenerateSourcesTest {
         private static MavenProject project;
 
         @Override
-        public Collection<File> generateSources(SchemaContext context, File outputBaseDir, Set<Module> currentModules)
+        public Collection<File> generateSources(final SchemaContext context, final File outputBaseDir, final Set<Module> currentModules)
                 throws IOException {
             called++;
             outputDir = outputBaseDir;
@@ -95,23 +99,23 @@ public class GenerateSourcesTest {
         }
 
         @Override
-        public void setLog(Log log) {
+        public void setLog(final Log log) {
             GeneratorMock.log = log;
         }
 
         @Override
-        public void setAdditionalConfig(Map<String, String> additionalConfiguration) {
+        public void setAdditionalConfig(final Map<String, String> additionalConfiguration) {
             GeneratorMock.additionalCfg = additionalConfiguration;
         }
 
         @Override
-        public void setResourceBaseDir(File resourceBaseDir) {
+        public void setResourceBaseDir(final File resourceBaseDir) {
             GeneratorMock.resourceBaseDir = resourceBaseDir;
 
         }
 
         @Override
-        public void setMavenProject(MavenProject project) {
+        public void setMavenProject(final MavenProject project) {
             GeneratorMock.project = project;
         }
     }
index 6945ef930377fc6bb8748cbd0ded426babe82924..a73b14e62a52a20f19042b8adf2eabbfada1b216 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.yangtools.yang2sources.plugin;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 import java.util.Collection;
index dbb20318e81fdf368d113bec6aeb6d190fba3dc0..6c1d9c102825a64011abdeabcdc6383352cd1a9e 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.model.util;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 
index 33a5e3f4a9b7981e7d4af84e37fe8e69c4ca3202..b4fab3b81a5a692eab798ac3e2245bf99304b6b0 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.parser.impl;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.containsString;
 
 import org.junit.Before;
 import org.junit.Test;
index b6fe186f26d166394c0111fd3d7facd5e53b8216..47dce2c29a31a642f469237b071a9e4865c009e1 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.parser.impl;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.containsString;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 
@@ -161,8 +161,8 @@ public class YangModelValidationModuleTest {
         valid.enterYang_version_stmt(ctx);
     }
 
-    private static Revision_stmtContext mockModuleWithRevision(String date,
-            String moduleName) {
+    private static Revision_stmtContext mockModuleWithRevision(final String date,
+            final String moduleName) {
         Revision_stmtContext mockedRev = YangModelValidationTest.mockStatement(
                 Revision_stmtContext.class, date);
         Revision_stmtsContext revs = YangModelValidationTest.mockStatement(
index d3db090e0b54da252876bcee3cad677c2475dd17..f8ce226ab35469afe526af59a2b002d79c531a0a 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.parser.impl;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.containsString;
 import static org.mockito.Mockito.mock;
 
 import org.antlr.v4.runtime.tree.ParseTree;
@@ -76,8 +76,8 @@ public class YangModelValidationSubModuleTest {
         }
     }
 
-    private Submodule_stmtContext mockSubmoduleParent(ParseTree child,
-            String moduleName) {
+    private Submodule_stmtContext mockSubmoduleParent(final ParseTree child,
+            final String moduleName) {
         Submodule_stmtContext ctx = YangModelValidationTest.mockStatement(
                 Submodule_stmtContext.class, moduleName);
         YangModelValidationTest.addChild(ctx, child);
index 7b11d502dd6405ee27420e9ed9e57c014c54516c..1ed60643bcda1fd7d932b97c21e6afe85cce053e 100644 (file)
@@ -7,21 +7,23 @@
  */
 package org.opendaylight.yangtools.yang.parser.impl;
 
-import static org.hamcrest.core.Is.is;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import com.google.common.collect.Sets;
+
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.List;
+
 import org.antlr.v4.runtime.Token;
 import org.antlr.v4.runtime.tree.ParseTree;
 import org.antlr.v4.runtime.tree.TerminalNode;
@@ -162,7 +164,7 @@ public class YangModelValidationTest {
             }
         }
 
-        assertThat(thrown, is(3));
+        assertEquals(3, thrown);
     }
 
     @Test(expected = YangValidationException.class)
@@ -200,7 +202,7 @@ public class YangModelValidationTest {
         types.add(Deviate_delete_stmtContext.class);
 
         int count = ValidationUtil.countPresentChildrenOfType(ctx, types);
-        assertThat(count, is(2));
+        assertEquals(2, count);
     }
 
     @Test(expected = YangValidationException.class)
@@ -214,7 +216,7 @@ public class YangModelValidationTest {
         }
     }
 
-    private Import_stmtContext mockImport(String name, String prefixName) {
+    private Import_stmtContext mockImport(final String name, final String prefixName) {
         Import_stmtContext impor = mockStatement(Import_stmtContext.class, name);
 
         Prefix_stmtContext prefix = mockStatement(Prefix_stmtContext.class, prefixName);
@@ -229,7 +231,7 @@ public class YangModelValidationTest {
         return new SimpleDateFormat("yyyy-MM-dd").format(new Date());
     }
 
-    private Include_stmtContext mockInclude(String name) {
+    private Include_stmtContext mockInclude(final String name) {
         Include_stmtContext incl = mockStatement(Include_stmtContext.class, name);
 
         Revision_date_stmtContext revDate = mockStatement(Revision_date_stmtContext.class, getFormattedDate());
@@ -238,7 +240,7 @@ public class YangModelValidationTest {
         return incl;
     }
 
-    static void mockName(ParseTree stmt, String name) {
+    static void mockName(final ParseTree stmt, final String name) {
         doReturn(1).when(stmt).getChildCount();
 
         TerminalNode terminalNode = mock(TerminalNode.class);
@@ -252,17 +254,18 @@ public class YangModelValidationTest {
         doReturn(Collections.singletonList(terminalNode)).when(nameCtx).STRING();
     }
 
-    static <T extends ParseTree> T mockStatement(Class<T> stmtType, String name) {
+    static <T extends ParseTree> T mockStatement(final Class<T> stmtType, final String name) {
         T stmt = stmtType.cast(mock(stmtType));
 
         doReturn(0).when(stmt).getChildCount();
 
-        if (name != null)
+        if (name != null) {
             mockName(stmt, name);
+        }
         return stmt;
     }
 
-    static void addChild(ParseTree parent, ParseTree child) {
+    static void addChild(final ParseTree parent, final ParseTree child) {
         int childCount = parent.getChildCount() + 1;
         doReturn(childCount).when(parent).getChildCount();
         doReturn(child).when(parent).getChild(childCount - 1);
index b1d9e9f0781804effdf90dc03137866c2f62d723..3cea37136676b6118d57d8f472ab05614f88de59 100644 (file)
@@ -7,14 +7,16 @@
  */
 package org.opendaylight.yangtools.yang.parser.util;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.core.AnyOf.anyOf;
-import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.containsString;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 
 import com.google.common.collect.Sets;
+
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
@@ -25,6 +27,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+
 import org.hamcrest.Matcher;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
@@ -54,13 +57,12 @@ public class ModuleDependencySortTest {
         assertDependencyGraph(ModuleDependencySort.createModuleGraph(ModuleOrModuleBuilder.fromAll(
                 Collections.<Module>emptySet(), Arrays.asList(builders))));
 
-        @SuppressWarnings("unchecked")
-        Matcher<String> cOrD = anyOf(is(c.getName()), is(d.getName()));
+        Matcher<String> cOrD = anyOf(equalTo(c.getName()), equalTo(d.getName()));
 
         assertThat(l.get(0).getName(), cOrD);
         assertThat(l.get(1).getName(), cOrD);
-        assertThat(l.get(2).getName(), is(b.getName()));
-        assertThat(l.get(3).getName(), is(a.getName()));
+        assertEquals(b.getName(), l.get(2).getName());
+        assertEquals(a.getName(), l.get(3).getName());
     }
 
     @Test
@@ -79,9 +81,9 @@ public class ModuleDependencySortTest {
 
         List<Module> l = ModuleDependencySort.sort(builders);
 
-        assertThat(l.get(0).getName(), is(c.getName()));
-        assertThat(l.get(1).getName(), is(b.getName()));
-        assertThat(l.get(2).getName(), is(a.getName()));
+        assertEquals(c.getName(), l.get(0).getName());
+        assertEquals(b.getName(), l.get(1).getName());
+        assertEquals(a.getName(), l.get(2).getName());
     }
 
     @Test(expected = YangValidationException.class)
@@ -163,8 +165,8 @@ public class ModuleDependencySortTest {
     }
 
     private void assertEdgeCount(final Set<Edge> inEdges, final int i, final Set<Edge> outEdges, final int j) {
-        assertThat(inEdges.size(), is(i));
-        assertThat(outEdges.size(), is(j));
+        assertEquals(i, inEdges.size());
+        assertEquals(j, outEdges.size());
     }
 
     private void mockDependency(final ModuleBuilder a, final ModuleBuilder b) {
index 72fb3ff8707e3368a4da63fdb07a20eb000e2a9d..568adcf74b03b609010322f31458bb2688e5dc76 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.parser.util;
 
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
 
 import com.google.common.collect.Sets;
+
 import java.util.List;
 import java.util.Set;
+
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.Node;
 import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.NodeImpl;
@@ -61,10 +62,10 @@ public class TopologicalSortTest {
 
         List<Node> sorted = TopologicalSort.sort(nodes);
 
-        assertThat(sorted.get(0), is(node4));
-        assertThat(sorted.get(1), is(node2));
-        assertThat(sorted.get(2), is(node3));
-        assertThat(sorted.get(3), is(node1));
+        assertEquals(node4, sorted.get(0));
+        assertEquals(node2, sorted.get(1));
+        assertEquals(node3, sorted.get(2));
+        assertEquals(node1, sorted.get(3));
     }
 
 }