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 30183ebff30547a3b2f164aa9cb0df476b4f9a40..11e5bfc63ead7c5fb2852ff2546a973cc9d9ff1b 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 4e89a653b8bf4453f8d04c36e7690e377387d050..85f0af7e54a0343161a13d3682ba3e387f5524ba 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 eb3676ccebff5625db2f68b64b9f834488433ea2..8fa7fdfddef8b61922bf71accc0327ccc616bfe1 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 23a4424a0b028f313147f1e7109a43202464eb04..25f7e2de9f425e4124e4ae0cd2a1233efbfca0cc 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 e8639d588197c146483b434fd83b4fb653a32c49..0cbbbab912d3cce521fda7de34837092613b9a47 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 1d8c3bbc30bff75a5f41d51dd5af2e06ca919dff..a5d77eabe014bc60ca5ecf162f41ac7e8ea4dbe2 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 919aeda5ae299ae465db50f2ca073a9a53c602ed..deb202cf002c1bee08aeb5d8de099cbc73947113 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 5fbe8688e0d8a2893ef4a56539cb4739da913f68..eabf8ec52041b4d7c5b038aa0f2e2d95d3e27de0 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 c7b98a14d009b7a5299a1c3f9159acc22f064b34..9263e42948959ae9778dbebe77624915c75a54cc 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 27515cf9698e4756f4e9ee0844862a2d61302f7b..9b9a92270a37354af1b5f7defa414ec245b18487 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 63a33a30315b55a3ad1ac65c9bc99a6691dec609..20a127ed23820c49e57ff4cb818b1f6b487c9748 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 029b347ccaa20f578a90ff21c2e42a782b9e599f..018fea86ed1b0c779fd48e8a27ca773c982f12c9 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 47b6d100c975de02bd5583e5f6b47aa99556bcad..7d426be66289e5a6b58b01702a9e17746c385255 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 0545fbf65fdcbba7b947511226d81d89fb8fb3ca..72d65262252247d7aed93b3055b87fa4c070f095 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 5a04594c14c466fa0b9e5ee239e26da0acb8e562..77d48f6ac5347bbf8c501a558c80be3d69807afe 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 19e6ef3b78baed4f3a55af2ad1ba650d96053337..451980c3ef9bafdd6c57e51dc2100f6b0a7c0b45 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 a15839d2d5b886104f21e8de88a551bdbbf14c12..df08f894c9151349e0356b8205c77d3ef3469961 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);