Fix Eclipse warnings in config-manager 70/56470/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 3 May 2017 13:34:13 +0000 (15:34 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 3 May 2017 19:39:00 +0000 (21:39 +0200)
Change-Id: I0ed9bc52d4cf4e5ee7a4da8bd53355191326cba6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
17 files changed:
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerInternal.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AbstractDynamicWrapper.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BundleContextBackedModuleFactoriesResolver.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/AbstractConfigTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/ConfigRegistryImplLookupTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImplTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImplTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverManagerTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AnnotationsTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/BlankTransactionServiceTrackerTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/BundleContextBackedModuleFactoriesResolverTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/util/OsgiRegistrationUtilTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/scheduledthreadpool/test/RuntimeBeanTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/threadpool/test/SimpleConfigurationTest.java

index 30183eb..11e5bfc 100644 (file)
@@ -27,7 +27,7 @@ interface ConfigTransactionControllerInternal extends
     /**
      * 1, Copy already committed modules to current transaction.
      * 2, Diff: compute added and removed factories from last run, then create new modules using
-     * {@link org.opendaylight.controller.config.spi.ModuleFactory#getDefaultModules(org.opendaylight.controller.config.api.DependencyResolverFactory)}
+     * {@link org.opendaylight.controller.config.spi.ModuleFactory#getDefaultModules(org.opendaylight.controller.config.api.DependencyResolverFactory, BundleContext)}
      * and remove modules belonging to removed factories.
      */
     void copyExistingModulesAndProcessFactoryDiff(Collection<ModuleInternalInfo> entries, List<ModuleFactory> lastListOfFactories);
index 4e89a65..85f0af7 100644 (file)
@@ -160,25 +160,20 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
                 return "initial";
             }
         };
-        ServiceReferenceTransactionRegistratorFactory serviceReferenceRegistratorFactory = new ServiceReferenceTransactionRegistratorFactory(){
+        ServiceReferenceTransactionRegistratorFactory serviceReferenceRegistratorFactory = () -> new ServiceReferenceRegistrator() {
             @Override
-            public ServiceReferenceRegistrator create() {
-                return new ServiceReferenceRegistrator() {
-                    @Override
-                    public String getNullableTransactionName() {
-                        throw new UnsupportedOperationException();
-                    }
-
-                    @Override
-                    public ServiceReferenceJMXRegistration registerMBean(final ServiceReferenceMXBeanImpl object, final ObjectName on) throws InstanceAlreadyExistsException {
-                        throw new UnsupportedOperationException();
-                    }
-
-                    @Override
-                    public void close() {
-
-                    }
-                };
+            public String getNullableTransactionName() {
+                throw new UnsupportedOperationException();
+            }
+
+            @Override
+            public ServiceReferenceJMXRegistration registerMBean(final ServiceReferenceMXBeanImpl object, final ObjectName on) throws InstanceAlreadyExistsException {
+                throw new UnsupportedOperationException();
+            }
+
+            @Override
+            public void close() {
+
             }
         };
         return new ServiceReferenceRegistryImpl(Collections.<String, ModuleFactory>emptyMap(), lookupRegistry,
@@ -351,7 +346,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
     public synchronized void checkServiceReferenceExists(final ObjectName objectName) throws InstanceNotFoundException {
         String actualTransactionName = ObjectNameUtil.getTransactionName(objectName);
         String expectedTransactionName = serviceReferenceRegistrator.getNullableTransactionName();
-        if (writable && actualTransactionName == null || (writable && !actualTransactionName.equals(expectedTransactionName))) {
+        if (writable && actualTransactionName == null || writable && !actualTransactionName.equals(expectedTransactionName)) {
             throw new IllegalArgumentException("Mismatched transaction name in " + objectName);
         }
         String serviceQName = ObjectNameUtil.getServiceQName(objectName);
@@ -442,9 +437,9 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         if (writable) {
             return ObjectNameUtil.createTransactionServiceON(serviceReferenceRegistrator.getNullableTransactionName(),
                     serviceReference.getServiceInterfaceQName(), serviceReference.getRefName());
-        } else {
-            return ObjectNameUtil.createReadOnlyServiceON(serviceReference.getServiceInterfaceQName(), serviceReference.getRefName());
         }
+
+        return ObjectNameUtil.createReadOnlyServiceON(serviceReference.getServiceInterfaceQName(), serviceReference.getRefName());
     }
 
     @Override
index eb3676c..8fa7fdf 100644 (file)
@@ -143,9 +143,6 @@ final class DependencyResolverImpl implements DependencyResolver,
         return translatedDependentReadOnlyON;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     //TODO: check for cycles
     @Override
     public <T> T resolveInstance(final Class<T> expectedType, final ObjectName dependentReadOnlyON,
@@ -158,20 +155,16 @@ final class DependencyResolverImpl implements DependencyResolver,
         final AutoCloseable instance = module.getInstance();
         if (instance == null) {
             final String message = String.format(
-                    "Error while %s resolving instance %s. getInstance() returned null. "
-                            + "Expected type %s , attribute %s", this.name,
-                    module.getIdentifier(), expectedType, jmxAttribute
-            );
+                "Error while %s resolving instance %s. getInstance() returned null. Expected type %s, attribute %s",
+                this.name, module.getIdentifier(), expectedType, jmxAttribute);
             throw new JmxAttributeValidationException(message, jmxAttribute);
         }
         try {
             return expectedType.cast(instance);
         } catch (final ClassCastException e) {
             final String message = String.format(
-                    "Instance cannot be cast to expected type. Instance class is %s , "
-                            + "expected type %s , attribute %s",
-                    instance.getClass(), expectedType, jmxAttribute
-            );
+                "Instance cannot be cast to expected type. Instance class is %s, expected type %s , attribute %s",
+                instance.getClass(), expectedType, jmxAttribute);
             throw new JmxAttributeValidationException(message, e, jmxAttribute);
         }
     }
@@ -197,9 +190,10 @@ final class DependencyResolverImpl implements DependencyResolver,
 
         final Module currentModule = resolveModuleInstance(objectName, jmxAttribute);
         final ModuleIdentifier identifier = currentModule.getIdentifier();
-        final ModuleInternalTransactionalInfo moduleInternalTransactionalInfo = this.modulesHolder.findModuleInternalTransactionalInfo(identifier);
+        final ModuleInternalTransactionalInfo moduleInternalTransactionalInfo = this.modulesHolder
+                .findModuleInternalTransactionalInfo(identifier);
 
-        if(moduleInternalTransactionalInfo.hasOldModule()) {
+        if (moduleInternalTransactionalInfo.hasOldModule()) {
             final Module oldModule = moduleInternalTransactionalInfo.getOldInternalInfo().getReadableModule().getModule();
             return currentModule.canReuse(oldModule);
         }
@@ -207,7 +201,8 @@ final class DependencyResolverImpl implements DependencyResolver,
     }
 
     @Override
-    public <T extends BaseIdentity> Class<? extends T> resolveIdentity(final IdentityAttributeRef identityRef, final Class<T> expectedBaseClass) {
+    public <T extends BaseIdentity> Class<? extends T> resolveIdentity(final IdentityAttributeRef identityRef,
+            final Class<T> expectedBaseClass) {
         final QName qName = QName.create(identityRef.getqNameOfIdentity());
         final Class<?> deserialized  = this.bindingContextProvider.getBindingContext().getIdentityClass(qName);
         if (deserialized == null) {
@@ -216,15 +211,15 @@ final class DependencyResolverImpl implements DependencyResolver,
         }
         if (expectedBaseClass.isAssignableFrom(deserialized)) {
             return (Class<T>) deserialized;
-        } else {
-            LOG.error("Cannot resolve class of identity {} : deserialized class {} is not a subclass of {}.",
-                    identityRef, deserialized, expectedBaseClass);
-            throw new IllegalArgumentException("Deserialized identity " + deserialized + " cannot be cast to " + expectedBaseClass);
         }
+        LOG.error("Cannot resolve class of identity {} : deserialized class {} is not a subclass of {}.", identityRef,
+            deserialized, expectedBaseClass);
+        throw new IllegalArgumentException("Deserialized identity " + deserialized + " cannot be cast to " + expectedBaseClass);
     }
 
     @Override
-    public <T extends BaseIdentity> void validateIdentity(final IdentityAttributeRef identityRef, final Class<T> expectedBaseClass, final JmxAttribute jmxAttribute) {
+    public <T extends BaseIdentity> void validateIdentity(final IdentityAttributeRef identityRef,
+            final Class<T> expectedBaseClass, final JmxAttribute jmxAttribute) {
         try {
             resolveIdentity(identityRef, expectedBaseClass);
         } catch (final Exception e) {
@@ -281,7 +276,7 @@ final class DependencyResolverImpl implements DependencyResolver,
                         chainForDetectingCycles2);
                 dependentDRI.maxDependencyDepth = subDepth;
             }
-            if ((subDepth + 1) > maxDepth) {
+            if (subDepth + 1 > maxDepth) {
                 maxDepth = subDepth + 1;
             }
         }
index 23a4424..25f7e2d 100644 (file)
@@ -302,9 +302,9 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
         String transactionName = ObjectNameUtil.getTransactionName(on);
         if (transactionName != null) {
             return ObjectNameUtil.withoutTransactionName(on);
-        } else {
-            return on;
         }
+
+        return on;
     }
 
     @Override
index e8639d5..0cbbbab 100644 (file)
@@ -22,14 +22,12 @@ import org.slf4j.LoggerFactory;
 /**
  * Retrieves list of currently registered Module Factories using bundlecontext.
  */
-public class BundleContextBackedModuleFactoriesResolver implements
-        ModuleFactoriesResolver {
-    private static final Logger LOG = LoggerFactory
-            .getLogger(BundleContextBackedModuleFactoriesResolver.class);
+public class BundleContextBackedModuleFactoriesResolver implements ModuleFactoriesResolver {
+    private static final Logger LOG = LoggerFactory.getLogger(BundleContextBackedModuleFactoriesResolver.class);
     private final BundleContext bundleContext;
 
     public BundleContextBackedModuleFactoriesResolver(
-            BundleContext bundleContext) {
+            final BundleContext bundleContext) {
         this.bundleContext = bundleContext;
     }
 
@@ -37,8 +35,7 @@ public class BundleContextBackedModuleFactoriesResolver implements
     public Map<String, Map.Entry<ModuleFactory, BundleContext>> getAllFactories() {
         Collection<ServiceReference<ModuleFactory>> serviceReferences;
         try {
-            serviceReferences = bundleContext.getServiceReferences(
-                    ModuleFactory.class, null);
+            serviceReferences = bundleContext.getServiceReferences(ModuleFactory.class, null);
         } catch (InvalidSyntaxException e) {
             throw new IllegalStateException(e);
         }
@@ -49,7 +46,7 @@ public class BundleContextBackedModuleFactoriesResolver implements
             // returned by a ServiceFactory does not
             // implement the classes under which it was registered or the
             // ServiceFactory threw an exception.
-            if(factory == null) {
+            if (factory == null) {
                 throw new NullPointerException("ServiceReference of class" + serviceReference.getClass() + "not found.");
             }
 
@@ -65,15 +62,15 @@ public class BundleContextBackedModuleFactoriesResolver implements
 
             Map.Entry<ModuleFactory, BundleContext> conflicting = result.get(moduleName);
             if (conflicting != null) {
-                String error = String
-                        .format("Module name is not unique. Found two conflicting factories with same name '%s': '%s' '%s'",
-                                moduleName, conflicting.getKey(), factory);
+                String error = String.format(
+                    "Module name is not unique. Found two conflicting factories with same name '%s': '%s' '%s'",
+                    moduleName, conflicting.getKey(), factory);
                 LOG.error(error);
                 throw new IllegalArgumentException(error);
-            } else {
-                result.put(moduleName, new AbstractMap.SimpleImmutableEntry<>(factory,
-                        serviceReference.getBundle().getBundleContext()));
             }
+
+            result.put(moduleName, new AbstractMap.SimpleImmutableEntry<>(factory,
+                    serviceReference.getBundle().getBundleContext()));
         }
         return result;
     }
index 1d8c3bb..a5d77ea 100644 (file)
@@ -74,18 +74,11 @@ public class ConfigManagerActivator implements BundleActivator, SynchronousBundl
             final ModuleFactoryBundleTracker moduleFactoryTracker = new ModuleFactoryBundleTracker(
                     blankTransactionServiceTracker);
 
-            final boolean scanResolvedBundlesForModuleInfo = true;
-            BundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> moduleInfoResolvedBundleTracker = null;
-            ExtensibleBundleTracker<?> moduleFactoryBundleTracker;
-            if(scanResolvedBundlesForModuleInfo) {
-                moduleInfoResolvedBundleTracker = new BundleTracker<>(context, Bundle.RESOLVED | Bundle.STARTING |
-                            Bundle.STOPPING | Bundle.ACTIVE, moduleInfoBundleTracker);
-                moduleFactoryBundleTracker = new ExtensibleBundleTracker<>(context, moduleFactoryTracker);
-            } else {
-                moduleFactoryBundleTracker = new ExtensibleBundleTracker<>(context,
-                        moduleFactoryTracker, moduleInfoBundleTracker);
-            }
-
+            BundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> moduleInfoResolvedBundleTracker =
+                    new BundleTracker<>(context, Bundle.RESOLVED | Bundle.STARTING | Bundle.STOPPING | Bundle.ACTIVE,
+                            moduleInfoBundleTracker);
+            ExtensibleBundleTracker<?> moduleFactoryBundleTracker = new ExtensibleBundleTracker<>(context,
+                    moduleFactoryTracker);
             moduleInfoBundleTracker.open(moduleInfoResolvedBundleTracker);
 
             // start extensible tracker
@@ -156,7 +149,7 @@ public class ConfigManagerActivator implements BundleActivator, SynchronousBundl
 
         // If the system bundle (id 0) is stopping close the ConfigRegistry so it destroys all modules. On
         // shutdown the system bundle is stopped first.
-        if((event.getBundle().getBundleId() == SYSTEM_BUNDLE_ID) && (event.getType() == BundleEvent.STOPPING)) {
+        if(event.getBundle().getBundleId() == SYSTEM_BUNDLE_ID && event.getType() == BundleEvent.STOPPING) {
             this.configRegistry.close();
         }
     }
index 919aeda..deb202c 100644 (file)
@@ -12,13 +12,12 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.mock;
+
 import com.google.common.base.Preconditions;
 import java.io.File;
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
-import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.Dictionary;
 import java.util.LinkedList;
@@ -144,7 +143,7 @@ public abstract class AbstractConfigTest extends AbstractLockedPlatformMBeanServ
         doNothing().when(this.mockedServiceRegistration).unregister();
         final RegisterServiceAnswer answer = new RegisterServiceAnswer();
         doAnswer(answer).when(this.mockedContext).registerService(Matchers.<String>any(), any(), Matchers.<Dictionary<String, ?>>any());
-        doAnswer(answer).when(this.mockedContext).registerService(Matchers.<Class>any(), any(), Matchers.<Dictionary<String, ?>>any());
+        doAnswer(answer).when(this.mockedContext).registerService(Matchers.<Class<?>>any(), any(), Matchers.<Dictionary<String, ?>>any());
     }
 
     @After
@@ -262,20 +261,17 @@ public abstract class AbstractConfigTest extends AbstractLockedPlatformMBeanServ
     protected <T> T rethrowCause(final T innerObject) {
         @SuppressWarnings("unchecked")
         final T proxy = (T)Proxy.newProxyInstance(innerObject.getClass().getClassLoader(),
-                innerObject.getClass().getInterfaces(), new InvocationHandler() {
-                        @Override
-                        public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
-                            try {
-                                return method.invoke(innerObject, args);
-                            } catch (final InvocationTargetException e) {
-                                try {
-                                    throw e.getTargetException();
-                                } catch (final RuntimeMBeanException e2) {
-                                    throw e2.getTargetException();
-                                }
-                            }
+                innerObject.getClass().getInterfaces(), (proxy1, method, args) -> {
+                    try {
+                        return method.invoke(innerObject, args);
+                    } catch (final InvocationTargetException e) {
+                        try {
+                            throw e.getTargetException();
+                        } catch (final RuntimeMBeanException e2) {
+                            throw e2.getTargetException();
                         }
                     }
+                }
         );
         return proxy;
     }
index 5fbe868..eabf8ec 100644 (file)
@@ -85,16 +85,15 @@ public class ConfigRegistryImplLookupTest extends
 
     }
 
-    private void registerModuleBean(TestingRuntimeBean testingRuntimeBean,
-            BaseJMXRegistrator baseJMXRegistrator, ObjectName objectName)
+    private static void registerModuleBean(final TestingRuntimeBean testingRuntimeBean,
+            final BaseJMXRegistrator baseJMXRegistrator, final ObjectName objectName)
             throws InstanceAlreadyExistsException {
         baseJMXRegistrator.createModuleJMXRegistrator().registerMBean(
                 testingRuntimeBean, objectName);
     }
 
-    private void registerRuntimeBean(RuntimeBean object,
-            BaseJMXRegistrator baseJMXRegistrator, ObjectName runtimeON)
-            throws InstanceAlreadyExistsException {
+    private static void registerRuntimeBean(final RuntimeBean object, final BaseJMXRegistrator baseJMXRegistrator,
+            final ObjectName runtimeON) throws InstanceAlreadyExistsException {
         String factoryName = ObjectNameUtil.getFactoryName(runtimeON);
         String instanceName = ObjectNameUtil.getInstanceName(runtimeON);
         Map<String, String> properties = ObjectNameUtil
index c7b98a1..9263e42 100644 (file)
@@ -61,12 +61,9 @@ public class ConfigTransactionControllerImplTest extends
         transactionsMBeanServer = MBeanServerFactory.createMBeanServer();
         Map<String, Map.Entry<ModuleFactory, BundleContext>> currentlyRegisteredFactories = new HashMap<>();
 
-        ConfigTransactionLookupRegistry txLookupRegistry = new ConfigTransactionLookupRegistry(new TransactionIdentifier(transactionName123), new TransactionJMXRegistratorFactory() {
-            @Override
-            public TransactionJMXRegistrator create() {
-                return baseJMXRegistrator.createTransactionJMXRegistrator(transactionName123);
-            }
-        }, currentlyRegisteredFactories);
+        ConfigTransactionLookupRegistry txLookupRegistry = new ConfigTransactionLookupRegistry(
+            new TransactionIdentifier(transactionName123), () ->
+            baseJMXRegistrator.createTransactionJMXRegistrator(transactionName123), currentlyRegisteredFactories);
 
         SearchableServiceReferenceWritableRegistry writableRegistry = ServiceReferenceRegistryImpl.createSRWritableRegistry(
                 ServiceReferenceRegistryImpl.createInitialSRLookupRegistry(), txLookupRegistry, currentlyRegisteredFactories);
@@ -98,8 +95,6 @@ public class ConfigTransactionControllerImplTest extends
 
     /**
      * Tests if lookup method returns all beans with defined transaction name
-     *
-     * @throws Exception
      */
     @Test
     public void testLookupConfigBeans() {
index 27515cf..9b9a922 100644 (file)
@@ -85,7 +85,7 @@ public class ServiceReferenceRegistryImplTest extends AbstractParallelAPSPTest {
         assertEquals(1, registrations.size());
         RegistrationHolder record = registrations.get(0);
         assertEquals(TestingThreadPoolIfc.class, record.clazz);
-        assertEquals(ImmutableMap.of("name","ref"), (Map<String, String>) record.props);
+        assertEquals(ImmutableMap.of("name","ref"), record.props);
 
         // switch reference to scheduled
         ConfigTransactionJMXClient transaction2 = configRegistryClient.createTransaction();
@@ -118,7 +118,7 @@ public class ServiceReferenceRegistryImplTest extends AbstractParallelAPSPTest {
         assertTrue(serviceMapping.isEmpty());
     }
 
-    private void checkApspThreadCount(int fixedNrOfThreads) throws MBeanException, AttributeNotFoundException,
+    private void checkApspThreadCount(final int fixedNrOfThreads) throws MBeanException, AttributeNotFoundException,
             InstanceNotFoundException, ReflectionException {
         ObjectName apspON = ObjectNameUtil.createReadOnlyModuleON(TestingParallelAPSPModuleFactory.NAME, apsp1);
         assertEquals(fixedNrOfThreads, platformMBeanServer.getAttribute(apspON, "MaxNumberOfThreads"));
index 63a33a3..20a127e 100644 (file)
@@ -85,16 +85,16 @@ public class DependencyResolverManagerTest extends AbstractLockedPlatformMBeanSe
      * Simulate dependentResolver resolving its dependency identified by
      * dependentName.
      */
-    private void declareDependency(DependencyResolverImpl dependerResolver,
-            ModuleIdentifier dependentName) {
+    private static void declareDependency(final DependencyResolverImpl dependerResolver,
+            final ModuleIdentifier dependentName) {
         JmxAttribute dummyAttribute = new JmxAttribute("dummy");
         dependerResolver.resolveInstance(Object.class,
                 ObjectNameUtil.createReadOnlyModuleON(dependentName),
                 dummyAttribute);
     }
 
-    private static void mockGetInstance(DependencyResolverManager tested,
-            ModuleIdentifier moduleIdentifier) {
+    private static void mockGetInstance(final DependencyResolverManager tested,
+            final ModuleIdentifier moduleIdentifier) {
 
         ModuleFactory moduleFactory = mock(ModuleFactory.class);
         ModuleInternalInfo maybeOldInternalInfo = null;
index 029b347..018fea8 100644 (file)
@@ -33,10 +33,8 @@ 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);
@@ -48,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);
@@ -72,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 {
@@ -84,10 +80,8 @@ 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());
     }
 
@@ -104,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) {
 
         }
     }
@@ -139,7 +133,7 @@ public class AnnotationsTest {
 
     public static class SubClassWithEmptyMethod extends SuperClass {
         @Override
-        public void setSomething(ObjectName objectName) {
+        public void setSomething(final ObjectName objectName) {
 
         }
     }
@@ -169,25 +163,21 @@ 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"));
         }
     }
 
@@ -195,8 +185,7 @@ public class AnnotationsTest {
         void setSomething(ObjectName objectName);
     }
 
-    public static class SubClassWithoutMethodWithInterface extends SuperClass
-            implements HasSomeMethod {
+    public static class SubClassWithoutMethodWithInterface extends SuperClass implements HasSomeMethod {
 
     }
 
@@ -214,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 {
 
     }
 
@@ -239,41 +227,32 @@ public class AnnotationsTest {
 
     @Test
     public void testFindAnnotation2() throws Exception {
-        assertNoDescriptionOnClass(SuperClassWithInterface.class,
-                emptySetOfInterfaces());
+        assertNoDescriptionOnClass(SuperClassWithInterface.class, emptySetOfInterfaces());
     }
 
     @Description("class")
     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<>(Arrays
-                        .asList(HasSomeMethodWithAnnotations.class)), "class");
+        assertDescriptionOnClass(HasSomeMethodWithAnnotationsImpl.class,
+                new HashSet<>(Arrays.asList(HasSomeMethodWithAnnotations.class)), "class");
     }
-
 }
index 47b6d10..7d426be 100644 (file)
@@ -13,6 +13,7 @@ import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
+
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Collections;
 import javax.management.ObjectName;
@@ -70,7 +71,7 @@ public class BlankTransactionServiceTrackerTest {
         verify(blankTx, times(maxAttempts)).hit();
     }
 
-    private ServiceReference<ModuleFactory> getMockServiceReference() {
+    private static ServiceReference<ModuleFactory> getMockServiceReference() {
         return mock(ServiceReference.class);
     }
 }
index 0545fbf..72d6526 100644 (file)
@@ -15,6 +15,7 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
+
 import com.google.common.collect.Lists;
 import java.util.Map;
 import org.junit.Before;
@@ -49,7 +50,7 @@ public class BundleContextBackedModuleFactoriesResolverTest {
         resolver = new BundleContextBackedModuleFactoriesResolver(bundleContext);
     }
 
-    private ModuleFactory getMockFactory(final String name) {
+    private static ModuleFactory getMockFactory(final String name) {
         ModuleFactory mock = mock(ModuleFactory.class);
         doReturn(name).when(mock).toString();
         doReturn(name).when(mock).getImplementationName();
index 5a04594..77d48f6 100644 (file)
@@ -56,7 +56,7 @@ public class OsgiRegistrationUtilTest {
         verify(sTracker).close();
     }
 
-    private ServiceRegistration<?> mockServiceRegistration() {
+    private static ServiceRegistration<?> mockServiceRegistration() {
         ServiceRegistration<?> mock = mock(ServiceRegistration.class);
         doNothing().when(mock).unregister();
         return mock;
index 19e6ef3..451980c 100644 (file)
@@ -72,21 +72,21 @@ public class RuntimeBeanTest extends AbstractScheduledTest {
 
     private void checkRuntimeBeans() throws Exception {
         // check runtime bean - on 2 places
-        for (ObjectName on : allObjectNames)
+        for (ObjectName on : allObjectNames) {
             checkRuntimeBean(on);
+        }
     }
 
-    private void checkRuntimeBean(ObjectName on) throws Exception {
-        assertEquals(0,
-                platformMBeanServer.getAttribute(on, "ActualNumberOfThreads"));
+    private static void checkRuntimeBean(final ObjectName on) throws Exception {
+        assertEquals(0, platformMBeanServer.getAttribute(on, "ActualNumberOfThreads"));
     }
 
-    private void checkRuntimeBeanDoesNotExist(ObjectName on) throws Exception {
+    private static void checkRuntimeBeanDoesNotExist(final ObjectName on) throws Exception {
         try {
             checkRuntimeBean(on);
             fail();
         } catch (InstanceNotFoundException e) {
-
+            // No-op
         }
     }
 
@@ -149,8 +149,9 @@ public class RuntimeBeanTest extends AbstractScheduledTest {
         configTransaction.destroyModule(ObjectNameUtil
                 .createTransactionModuleON(configTransaction.getTransactionName(), createdConfigBean));
         configTransaction.commit();
-        for (ObjectName on : allObjectNames)
+        for (ObjectName on : allObjectNames) {
             checkRuntimeBeanDoesNotExist(on);
+        }
     }
 
 }
index a15839d..df08f89 100644 (file)
@@ -38,6 +38,7 @@ import org.opendaylight.controller.config.manager.impl.factoriesresolver.Hardcod
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPool;
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean;
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory;
+import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingThreadPoolIfc;
 import org.opendaylight.controller.config.util.ConfigTransactionClient;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 
@@ -95,7 +96,7 @@ public class SimpleConfigurationTest extends AbstractConfigTest {
     }
 
     static ObjectName createFixedThreadPool(
-            ConfigTransactionJMXClient transaction)
+            final ConfigTransactionJMXClient transaction)
             throws InstanceAlreadyExistsException, InstanceNotFoundException {
         transaction.assertVersion(0, 1);
 
@@ -130,7 +131,7 @@ public class SimpleConfigurationTest extends AbstractConfigTest {
     }
 
 
-    private void testValidation(ConfigTransactionClient transaction)
+    private static void testValidation(final ConfigTransactionClient transaction)
             throws InstanceAlreadyExistsException, ReflectionException,
             InstanceNotFoundException, MBeanException, ConflictingVersionException {
         ObjectName fixed1names = transaction.createModule(
@@ -276,8 +277,8 @@ public class SimpleConfigurationTest extends AbstractConfigTest {
         checkThreadPools(1, numberOfThreads2);
     }
 
-    private void checkThreadPools(int expectedTotalNumberOfExecutors,
-            int expectedNumberOfThreadsInLastExecutor) {
+    private static void checkThreadPools(final int expectedTotalNumberOfExecutors,
+            final int expectedNumberOfThreadsInLastExecutor) {
         assertEquals(expectedTotalNumberOfExecutors,
                 TestingFixedThreadPool.allExecutors.size());
         for (int i = 0; i < expectedTotalNumberOfExecutors - 1; i++) {
@@ -309,9 +310,8 @@ public class SimpleConfigurationTest extends AbstractConfigTest {
     }
 
     // return MBeanProxy for 'fixed1' and current transaction
-    private TestingFixedThreadPoolConfigMXBean startReconfiguringFixed1ThreadPool(
-            ConfigTransactionJMXClient transaction)
-            throws InstanceNotFoundException {
+    private static TestingFixedThreadPoolConfigMXBean startReconfiguringFixed1ThreadPool(
+            final ConfigTransactionJMXClient transaction) throws InstanceNotFoundException {
         ObjectName fixed1name = transaction.lookupConfigBean(
                 TestingFixedThreadPoolModuleFactory.NAME, fixed1);
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.