Fix Eclipse warnings in config-manager
[controller.git] / opendaylight / config / config-manager / src / test / java / org / opendaylight / controller / config / manager / impl / dynamicmbean / AnnotationsTest.java
index cf6ed18c6cd96b4483ac8f1f9064a84ae2ea1db2..018fea86ed1b0c779fd48e8a27ca773c982f12c9 100644 (file)
@@ -13,6 +13,8 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import com.google.common.base.Throwables;
+import com.google.common.collect.Sets;
 import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.Collections;
@@ -20,26 +22,19 @@ import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.Executor;
 import java.util.concurrent.ExecutorService;
-
 import javax.management.ObjectName;
-
 import org.junit.Test;
 import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
 import org.opendaylight.controller.config.api.annotations.Description;
 import org.opendaylight.controller.config.api.annotations.RequireInterface;
 import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
 
-import com.google.common.base.Throwables;
-import com.google.common.collect.Sets;
-
 public class AnnotationsTest {
 
     private final String setSomethingString = "setSomething";
 
-    private void assertRequireInterfaceAnnotationHasCorrectValue(
-            Class<?> clazz, String methodName,
-            Set<Class<?>> inspectedInterfaces,
-            Class<? extends AbstractServiceInterface> expectedValue) {
+    private static void assertRequireInterfaceAnnotationHasCorrectValue(final Class<?> clazz, final String methodName,
+            final Set<Class<?>> inspectedInterfaces, final Class<? extends AbstractServiceInterface> expectedValue) {
         Method setter = findMethod(clazz, methodName);
         RequireInterface found = AttributeHolder
                 .findRequireInterfaceAnnotation(setter, inspectedInterfaces);
@@ -51,19 +46,18 @@ public class AnnotationsTest {
         }
     }
 
-    private Method findMethod(Class<?> clazz, String methodName) {
+    private static Method findMethod(final Class<?> clazz, final String methodName) {
         Method setter;
         try {
-            setter = clazz.getMethod(methodName,
-                    new Class[] { ObjectName.class });
+            setter = clazz.getMethod(methodName, new Class[] { ObjectName.class });
         } catch (Exception e) {
             throw Throwables.propagate(e);
         }
         return setter;
     }
 
-    private void assertDescription(Class<?> clazz, String methodName,
-            Set<Class<?>> exportedInterfaces, String expectedValue) {
+    private static void assertDescription(final Class<?> clazz, final String methodName,
+            final Set<Class<?>> exportedInterfaces, final String expectedValue) {
         Method setter = findMethod(clazz, methodName);
         String found = AttributeHolder.findDescription(setter,
                 exportedInterfaces);
@@ -75,10 +69,9 @@ public class AnnotationsTest {
         }
     }
 
-    private void assertDescriptionOnClass(Class<?> clazz,
-            Set<Class<?>> jmxInterfaces, String expectedValue) {
-        String found = AbstractDynamicWrapper.findDescription(clazz,
-                jmxInterfaces);
+    private static void assertDescriptionOnClass(final Class<?> clazz, final Set<Class<?>> jmxInterfaces,
+            final String expectedValue) {
+        String found = AbstractDynamicWrapper.findDescription(clazz, jmxInterfaces);
         if (expectedValue == null) {
             assertNull(found);
         } else {
@@ -87,18 +80,17 @@ public class AnnotationsTest {
         }
     }
 
-    private void assertNoDescriptionOnClass(Class<?> clazz,
-            Set<Class<?>> jmxInterfaces) {
-        String found = AbstractDynamicWrapper.findDescription(clazz,
-                jmxInterfaces);
+    private static void assertNoDescriptionOnClass(final Class<?> clazz, final Set<Class<?>> jmxInterfaces) {
+        String found = AbstractDynamicWrapper.findDescription(clazz, jmxInterfaces);
         assertTrue(found.isEmpty());
     }
 
     static final String SIMPLE = "simple";
     static final String SUBCLASS2 = "subclass2";
 
-    @ServiceInterfaceAnnotation(value = SIMPLE, osgiRegistrationType = Executor.class)
-    static interface SimpleSI extends AbstractServiceInterface {
+    @ServiceInterfaceAnnotation(value = SIMPLE, osgiRegistrationType = Executor.class,
+        namespace = "ns", revision = "rev", localName = SIMPLE)
+    interface SimpleSI extends AbstractServiceInterface {
 
     }
 
@@ -106,7 +98,7 @@ public class AnnotationsTest {
     public static class SuperClass {
         @RequireInterface(SimpleSI.class)
         @Description("descr")
-        public void setSomething(ObjectName objectName) {
+        public void setSomething(final ObjectName objectName) {
 
         }
     }
@@ -141,7 +133,7 @@ public class AnnotationsTest {
 
     public static class SubClassWithEmptyMethod extends SuperClass {
         @Override
-        public void setSomething(ObjectName objectName) {
+        public void setSomething(final ObjectName objectName) {
 
         }
     }
@@ -157,12 +149,13 @@ public class AnnotationsTest {
                 emptySetOfInterfaces(), "class");
     }
 
-    static interface SubSI extends SimpleSI {
+    interface SubSI extends SimpleSI {
 
     }
 
-    @ServiceInterfaceAnnotation(value = SUBCLASS2, osgiRegistrationType = ExecutorService.class)
-    static interface SubSI2 extends SubSI {
+    @ServiceInterfaceAnnotation(value = SUBCLASS2, osgiRegistrationType = ExecutorService.class,
+        namespace = "ns", revision = "rev", localName = SUBCLASS2)
+    interface SubSI2 extends SubSI {
 
     }
 
@@ -170,34 +163,29 @@ public class AnnotationsTest {
         @Override
         @RequireInterface(SubSI2.class)
         @Description("descr2")
-        public void setSomething(ObjectName objectName) {
+        public void setSomething(final ObjectName objectName) {
 
         }
     }
 
     @Test
     public void testFindAnnotation_SubClassWithAnnotation() throws Exception {
-        assertDescription(SubClassWithAnnotation.class, setSomethingString,
-                emptySetOfInterfaces(), "descr2\ndescr");
+        assertDescription(SubClassWithAnnotation.class, setSomethingString, emptySetOfInterfaces(), "descr2\ndescr");
         try {
-            assertRequireInterfaceAnnotationHasCorrectValue(
-                    SubClassWithAnnotation.class, setSomethingString,
-                    emptySetOfInterfaces(), SubSI2.class);
+            assertRequireInterfaceAnnotationHasCorrectValue(SubClassWithAnnotation.class, setSomethingString,
+                emptySetOfInterfaces(), SubSI2.class);
             fail();
         } catch (IllegalStateException e) {
-            assertTrue(
-                    e.getMessage(),
-                    e.getMessage()
-                            .startsWith("Error finding @RequireInterface. More than one value specified"));
+            assertTrue(e.getMessage(),
+                e.getMessage().startsWith("Error finding @RequireInterface. More than one value specified"));
         }
     }
 
-    public static interface HasSomeMethod {
+    public interface HasSomeMethod {
         void setSomething(ObjectName objectName);
     }
 
-    public static class SubClassWithoutMethodWithInterface extends SuperClass
-            implements HasSomeMethod {
+    public static class SubClassWithoutMethodWithInterface extends SuperClass implements HasSomeMethod {
 
     }
 
@@ -215,14 +203,13 @@ public class AnnotationsTest {
         @Override
         @RequireInterface(SubSI2.class)
         @Description("descr")
-        public void setSomething(ObjectName objectName) {
+        public void setSomething(final ObjectName objectName) {
 
         }
     }
 
     @Description("class")
-    public static class SubClassOfSuperClassWithInterface extends
-            SuperClassWithInterface {
+    public static class SubClassOfSuperClassWithInterface extends SuperClassWithInterface {
 
     }
 
@@ -240,41 +227,32 @@ public class AnnotationsTest {
 
     @Test
     public void testFindAnnotation2() throws Exception {
-        assertNoDescriptionOnClass(SuperClassWithInterface.class,
-                emptySetOfInterfaces());
+        assertNoDescriptionOnClass(SuperClassWithInterface.class, emptySetOfInterfaces());
     }
 
     @Description("class")
-    static interface HasSomeMethodWithAnnotations {
-
+    interface HasSomeMethodWithAnnotations {
         @RequireInterface(SubSI2.class)
         @Description("descr")
         void setSomething(ObjectName objectName);
     }
 
-    static class HasSomeMethodWithAnnotationsImpl implements
-            HasSomeMethodWithAnnotations {
+    static class HasSomeMethodWithAnnotationsImpl implements HasSomeMethodWithAnnotations {
         @Override
-        public void setSomething(ObjectName objectName) {
+        public void setSomething(final ObjectName objectName) {
         }
-
     }
 
     @Test
     public void testHasSomeMethodWithAnnotationsImpl() {
         HashSet<Class<?>> exportedInterfaces = Sets
                 .<Class<?>> newHashSet(HasSomeMethodWithAnnotations.class);
-        assertRequireInterfaceAnnotationHasCorrectValue(
-                HasSomeMethodWithAnnotationsImpl.class, setSomethingString,
+        assertRequireInterfaceAnnotationHasCorrectValue(HasSomeMethodWithAnnotationsImpl.class, setSomethingString,
                 exportedInterfaces, SubSI2.class);
 
-        assertDescription(HasSomeMethodWithAnnotationsImpl.class,
-                setSomethingString, exportedInterfaces, "descr");
+        assertDescription(HasSomeMethodWithAnnotationsImpl.class, setSomethingString, exportedInterfaces, "descr");
 
-        assertDescriptionOnClass(
-                HasSomeMethodWithAnnotationsImpl.class,
-                new HashSet<Class<?>>(Arrays
-                        .asList(HasSomeMethodWithAnnotations.class)), "class");
+        assertDescriptionOnClass(HasSomeMethodWithAnnotationsImpl.class,
+                new HashSet<>(Arrays.asList(HasSomeMethodWithAnnotations.class)), "class");
     }
-
 }