From: janab Date: Tue, 6 Sep 2016 22:05:55 +0000 (-0700) Subject: checkStyleViolationSeverity=error implemented for mdsal-singleton-common-api and... X-Git-Tag: release/carbon~176 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=703b1cac5f0bdd429dcb64809b7cd599e973877f;p=mdsal.git checkStyleViolationSeverity=error implemented for mdsal-singleton-common-api and mdsal-singleton-dom-impl modules Done implementing code review comments. Change-Id: I09443eeb61b09844d1e6960e7ff480dcaaface9f Signed-off-by: Brinda Jana --- diff --git a/singleton-service/mdsal-singleton-common-api/pom.xml b/singleton-service/mdsal-singleton-common-api/pom.xml index d7824e7cf6..4c14b90fe6 100644 --- a/singleton-service/mdsal-singleton-common-api/pom.xml +++ b/singleton-service/mdsal-singleton-common-api/pom.xml @@ -42,6 +42,17 @@ test + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + + + scm:git:http://git.opendaylight.org/gerrit/mdsal.git diff --git a/singleton-service/mdsal-singleton-common-api/src/main/java/org/opendaylight/mdsal/singleton/common/api/ServiceGroupIdentifier.java b/singleton-service/mdsal-singleton-common-api/src/main/java/org/opendaylight/mdsal/singleton/common/api/ServiceGroupIdentifier.java index c858a70393..d40efc644c 100644 --- a/singleton-service/mdsal-singleton-common-api/src/main/java/org/opendaylight/mdsal/singleton/common/api/ServiceGroupIdentifier.java +++ b/singleton-service/mdsal-singleton-common-api/src/main/java/org/opendaylight/mdsal/singleton/common/api/ServiceGroupIdentifier.java @@ -16,10 +16,10 @@ import org.opendaylight.yangtools.util.AbstractStringIdentifier; public class ServiceGroupIdentifier extends AbstractStringIdentifier { /** - * Method create immutable instance of {@link ServiceGroupIdentifier} + * Method to create immutable instances of {@link ServiceGroupIdentifier}. * - * @param serviceGroupIdentifier - * @return {@link ServiceGroupIdentifier} instance + * @param serviceGroupIdentifier the String identifier for the ServiceGroupIdentifier instance + * @return {@link ServiceGroupIdentifier} new instance */ public static ServiceGroupIdentifier create(final String serviceGroupIdentifier) { return new ServiceGroupIdentifier(serviceGroupIdentifier); diff --git a/singleton-service/mdsal-singleton-dom-impl/pom.xml b/singleton-service/mdsal-singleton-dom-impl/pom.xml index b97cb6ace5..238507bd62 100644 --- a/singleton-service/mdsal-singleton-dom-impl/pom.xml +++ b/singleton-service/mdsal-singleton-dom-impl/pom.xml @@ -58,6 +58,13 @@ maven-bundle-plugin true + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + diff --git a/singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/AbstractClusterSingletonServiceProviderImpl.java b/singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/AbstractClusterSingletonServiceProviderImpl.java index a1a56d8a2f..2955f6c941 100644 --- a/singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/AbstractClusterSingletonServiceProviderImpl.java +++ b/singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/AbstractClusterSingletonServiceProviderImpl.java @@ -26,8 +26,8 @@ import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipListener; import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipListenerRegistration; import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; -import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; +import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration; import org.opendaylight.yangtools.concepts.Path; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,10 +46,10 @@ import org.slf4j.LoggerFactory; * @param the GenericEntityOwnershipListenerRegistration type */ public abstract class AbstractClusterSingletonServiceProviderImpl

, E extends GenericEntity

, - C extends GenericEntityOwnershipChange, - G extends GenericEntityOwnershipListener, - S extends GenericEntityOwnershipService, - R extends GenericEntityOwnershipListenerRegistration> + C extends GenericEntityOwnershipChange, + G extends GenericEntityOwnershipListener, + S extends GenericEntityOwnershipService, + R extends GenericEntityOwnershipListenerRegistration> implements ClusterSingletonServiceProvider, GenericEntityOwnershipListener { private static final Logger LOG = LoggerFactory @@ -59,14 +59,15 @@ public abstract class AbstractClusterSingletonServiceProviderImpl

> serviceGroupMap = new ConcurrentHashMap<>(); + private final ConcurrentMap> serviceGroupMap = + new ConcurrentHashMap<>(); /* EOS Entity Listeners Registration */ private R serviceEntityListenerReg; private R asyncCloseEntityListenerReg; /** - * Class constructor + * Class constructor. * * @param entityOwnershipService relevant EOS */ @@ -130,8 +131,8 @@ public abstract class AbstractClusterSingletonServiceProviderImpl

the instance identifier path type * @param the GenericEntity type @@ -73,12 +73,13 @@ final class ClusterSingletonServiceGroupImpl

, E extends Generi private GenericEntityOwnershipCandidateRegistration asyncCloseEntityCandidateReg; /** - * Class constructor + * Class constructor. * * @param clusterSingletonServiceGroupIdentifier not empty string as identifier - * @param mainEntity - * @param closeEntity - * @param entityOwnershipService + * @param mainEntity as Entity instance + * @param closeEntity as Entity instance + * @param entityOwnershipService GenericEntityOwnershipService instance + * @param allServiceGroups concurrentMap of String and ClusterSingletonServiceGroup type */ ClusterSingletonServiceGroupImpl(final String clusterSingletonServiceGroupIdentifier, final E mainEntity, final E closeEntity, final S entityOwnershipService, @@ -92,15 +93,17 @@ final class ClusterSingletonServiceGroupImpl

, E extends Generi this.allServiceGroups = Preconditions.checkNotNull(allServiceGroups); } + @SuppressWarnings("checkstyle:IllegalCatch") @Override - public final ListenableFuture> closeClusterSingletonGroup() { + public ListenableFuture> closeClusterSingletonGroup() { LOG.debug("Close method for service Provider {}", clusterSingletonGroupIdentifier); boolean needReleaseLock = false; final ListenableFuture> destroyFuture; try { needReleaseLock = clusterLock.tryAcquire(10, TimeUnit.SECONDS); } catch (final Exception e) { - LOG.warn("Unexpected Exception for service Provider {} in closing phase.", clusterSingletonGroupIdentifier, e); + LOG.warn("Unexpected Exception for service Provider {} in closing phase.", + clusterSingletonGroupIdentifier, e); } finally { if (serviceEntityCandidateReg != null) { serviceEntityCandidateReg.close(); @@ -119,8 +122,9 @@ final class ClusterSingletonServiceGroupImpl

, E extends Generi return destroyFuture; } + @SuppressWarnings("checkstyle:IllegalCatch") @Override - public final void initializationClusterSingletonGroup() { + public void initializationClusterSingletonGroup() { LOG.debug("Initialization ClusterSingletonGroup {}", clusterSingletonGroupIdentifier); boolean needReleaseLock = false; boolean needCloseProviderInstance = false; @@ -139,8 +143,9 @@ final class ClusterSingletonServiceGroupImpl

, E extends Generi } } + @SuppressWarnings("checkstyle:IllegalCatch") @Override - public final ClusterSingletonServiceRegistration registerService(final ClusterSingletonService service) { + public ClusterSingletonServiceRegistration registerService(final ClusterSingletonService service) { LOG.debug("RegisterService method call for ClusterSingletonServiceGroup {}", clusterSingletonGroupIdentifier); Verify.verify(clusterSingletonGroupIdentifier.equals(service.getIdentifier().getValue())); boolean needReleaseLock = false; @@ -164,8 +169,9 @@ final class ClusterSingletonServiceGroupImpl

, E extends Generi return reg; } + @SuppressWarnings("checkstyle:IllegalCatch") @Override - public final void unregisterService(final ClusterSingletonService service) { + public void unregisterService(final ClusterSingletonService service) { LOG.debug("UnregisterService method call for ClusterSingletonServiceGroup {}", clusterSingletonGroupIdentifier); Verify.verify(clusterSingletonGroupIdentifier.equals(service.getIdentifier().getValue())); boolean needReleaseLock = false; @@ -188,8 +194,9 @@ final class ClusterSingletonServiceGroupImpl

, E extends Generi } } + @SuppressWarnings("checkstyle:IllegalCatch") @Override - public final void ownershipChanged(final C ownershipChange) { + public void ownershipChanged(final C ownershipChange) { LOG.debug("Ownership change {} for ClusterSingletonServiceGrou {}", ownershipChange, clusterSingletonGroupIdentifier); try { @@ -239,7 +246,7 @@ final class ClusterSingletonServiceGroupImpl

, E extends Generi } else { LOG.warn("Unexpected EntityOwnershipChangeEvent for entity {}", ownershipChange); } - } catch (final Exception e) { + } catch (Exception e) { LOG.error("Unexpected Exception for service Provider {}", clusterSingletonGroupIdentifier, e); // TODO : think about close ... is it necessary? } @@ -249,6 +256,7 @@ final class ClusterSingletonServiceGroupImpl

, E extends Generi * Help method to registered DoubleCandidateEntity. It is first step * before the actual instance take Leadership. */ + @SuppressWarnings("checkstyle:IllegalCatch") private void tryToTakeOwnership() { LOG.debug("TryToTakeLeadership method for service Provider {}", clusterSingletonGroupIdentifier); boolean needReleaseLock = false; @@ -259,7 +267,7 @@ final class ClusterSingletonServiceGroupImpl

, E extends Generi Verify.verify(serviceEntityCandidateReg != null); Verify.verify(asyncCloseEntityCandidateReg == null); asyncCloseEntityCandidateReg = entityOwnershipService.registerCandidate(doubleCandidateEntity); - } catch (final Exception e) { + } catch (Exception e) { LOG.error("Unexpected exception state for service Provider {} in TryToTakeLeadership", clusterSingletonGroupIdentifier, e); needCloseProviderInstance = true; @@ -271,6 +279,7 @@ final class ClusterSingletonServiceGroupImpl

, E extends Generi /* * Help method calls setupService method for create single cluster-wide service instance. */ + @SuppressWarnings("checkstyle:IllegalCatch") private void takeOwnership() { LOG.debug("TakeLeadership method for service Provider {}", clusterSingletonGroupIdentifier); boolean needReleaseLock = false; @@ -298,6 +307,7 @@ final class ClusterSingletonServiceGroupImpl

, E extends Generi * The last async. step has to close DoubleCandidateRegistration reference what should initialize * new election for DoubleCandidateEntity. */ + @SuppressWarnings("checkstyle:IllegalCatch") private void lostOwnership() { LOG.debug("LostLeadership method for service Provider {}", clusterSingletonGroupIdentifier); boolean needReleaseLock = false; @@ -350,8 +360,8 @@ final class ClusterSingletonServiceGroupImpl

, E extends Generi } @Override - public void onFailure(final Throwable t) { - removeThisGroupFromProvider(t); + public void onFailure(final Throwable throwable) { + removeThisGroupFromProvider(throwable); } }); } @@ -360,9 +370,9 @@ final class ClusterSingletonServiceGroupImpl

, E extends Generi /* * Help method for final ClusterSingletonGroup removing */ - protected final void removeThisGroupFromProvider(@Nullable final Throwable t) { + protected void removeThisGroupFromProvider(@Nullable final Throwable throwable) { LOG.debug("Removing ClusterSingletonServiceGroup {}", clusterSingletonGroupIdentifier); - if (t != null) { + if (throwable != null) { LOG.warn("Unexpected problem by closingResources ClusterSingletonServiceGroup {}", clusterSingletonGroupIdentifier); } @@ -373,9 +383,9 @@ final class ClusterSingletonServiceGroupImpl

, E extends Generi * Help method creates FutureCallback for suspend Future */ private FutureCallback> newAsyncCloseCallback(@Nullable final Semaphore semaphore) { - final Consumer closeEntityCandidateRegistration = (@Nullable final Throwable t) -> { - if (t != null) { - LOG.warn("Unexpected error closing service instance {}", clusterSingletonGroupIdentifier, t); + final Consumer closeEntityCandidateRegistration = (@Nullable final Throwable throwable) -> { + if (throwable != null) { + LOG.warn("Unexpected error closing service instance {}", clusterSingletonGroupIdentifier, throwable); } else { LOG.debug("Destroy service Instance {} is success", clusterSingletonGroupIdentifier); } @@ -397,8 +407,8 @@ final class ClusterSingletonServiceGroupImpl

, E extends Generi } @Override - public void onFailure(final Throwable t) { - closeEntityCandidateRegistration.accept(t); + public void onFailure(final Throwable throwable) { + closeEntityCandidateRegistration.accept(throwable); } }; } diff --git a/singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/ClusterSingletonServiceRegistrationDelegator.java b/singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/ClusterSingletonServiceRegistrationDelegator.java index b7eabf6c42..8728298c13 100644 --- a/singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/ClusterSingletonServiceRegistrationDelegator.java +++ b/singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/ClusterSingletonServiceRegistrationDelegator.java @@ -20,6 +20,7 @@ import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; * Close registration means remove {@link ClusterSingletonService} instance from internal * ClusterSingletonServiceGroup list reference. * + *

* Close {@link ClusterSingletonServiceRegistration} is prepared for a possible restart * service or application in osgi container. Any another services from group can not be * stopped. diff --git a/singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/DOMClusterSingletonServiceProviderImpl.java b/singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/DOMClusterSingletonServiceProviderImpl.java index 17a2b7162e..e834a0eead 100644 --- a/singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/DOMClusterSingletonServiceProviderImpl.java +++ b/singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/DOMClusterSingletonServiceProviderImpl.java @@ -18,7 +18,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; /** - * Binding version of {@link AbstractClusterSingletonServiceProviderImpl} + * Binding version of {@link AbstractClusterSingletonServiceProviderImpl}. */ public final class DOMClusterSingletonServiceProviderImpl extends AbstractClusterSingletonServiceProviderImpl mockCloseEntityCandReg; @Mock - private GenericEntityOwnershipListener> mockEosListener; + private GenericEntityOwnershipListener> mockEosListener; @Mock - private GenericEntityOwnershipService>> mockEosService; - - private ClusterSingletonServiceGroupImpl, - GenericEntityOwnershipListener>, - GenericEntityOwnershipService>>> singletonServiceGroup; + private GenericEntityOwnershipService>> mockEosService; + + private ClusterSingletonServiceGroupImpl, + GenericEntityOwnershipListener>, + GenericEntityOwnershipService>>> singletonServiceGroup; private final TestEntity mainEntity = new TestEntity(SERVICE_ENTITY_TYPE, SERVICE_IDENTIFIER); private final TestEntity closeEntity = new TestEntity(CLOSE_SERVICE_ENTITY_TYPE, SERVICE_IDENTIFIER); private final ConcurrentMap> map = new ConcurrentHashMap<>(); /** - * Initialization functionality for every Tests in this suite + * Initialization functionality for every Tests in this suite. * * @throws Exception - unexpected exception */ - @Before - public void setup() throws Exception { - MockitoAnnotations.initMocks(this); + @Before + public void setup() throws Exception { + MockitoAnnotations.initMocks(this); - doReturn(mockEntityCandReg).when(mockEosService).registerCandidate(mainEntity); - doReturn(mockCloseEntityCandReg).when(mockEosService).registerCandidate(closeEntity); - doNothing().when(mockEntityCandReg).close(); - doNothing().when(mockCloseEntityCandReg).close(); - doNothing().when(mockClusterSingletonService).instantiateServiceInstance(); - doReturn(Futures.immediateFuture(null)).when(mockClusterSingletonService).closeServiceInstance(); + doReturn(mockEntityCandReg).when(mockEosService).registerCandidate(mainEntity); + doReturn(mockCloseEntityCandReg).when(mockEosService).registerCandidate(closeEntity); + doNothing().when(mockEntityCandReg).close(); + doNothing().when(mockCloseEntityCandReg).close(); + doNothing().when(mockClusterSingletonService).instantiateServiceInstance(); + doReturn(Futures.immediateFuture(null)).when(mockClusterSingletonService).closeServiceInstance(); doReturn(SERVICE_GROUP_IDENT).when(mockClusterSingletonService).getIdentifier(); doReturn(SERVICE_GROUP_IDENT).when(mockClusterSingletonServiceSecond).getIdentifier(); - singletonServiceGroup = new ClusterSingletonServiceGroupImpl(SERVICE_IDENTIFIER, mainEntity, closeEntity, mockEosService, map); + singletonServiceGroup = new ClusterSingletonServiceGroupImpl( + SERVICE_IDENTIFIER, mainEntity, closeEntity, mockEosService, map); } /** - * Test NULL ServiceIdent input for new ServiceGroup instance + * Test NULL ServiceIdent input for new ServiceGroup instance. * * @throws Exception - unexpected exception */ @Test(expected = IllegalArgumentException.class) public void instantiationClusterSingletonServiceGroupNullIdentTest() throws Exception { - singletonServiceGroup = new ClusterSingletonServiceGroupImpl(null, mainEntity, closeEntity, mockEosService, map); + singletonServiceGroup = new ClusterSingletonServiceGroupImpl( + null, mainEntity, closeEntity, mockEosService, map); } /** - * Test empty ServiceIdent input for new ServiceGroup instance + * Test empty ServiceIdent input for new ServiceGroup instance. * * @throws Exception - unexpected exception */ @@ -109,47 +116,51 @@ public class ClusterSingletonServiceGroupImplTest { } /** - * Test NULL MainEntity input for new ServiceGroup instance + * Test NULL MainEntity input for new ServiceGroup instance. * * @throws Exception - unexpected exception */ @Test(expected = NullPointerException.class) public void instantiationClusterSingletonServiceGroupNullMainEntityTest() throws Exception { - singletonServiceGroup = new ClusterSingletonServiceGroupImpl(SERVICE_IDENTIFIER, null, closeEntity, mockEosService, map); + singletonServiceGroup = new ClusterSingletonServiceGroupImpl( + SERVICE_IDENTIFIER, null, closeEntity, mockEosService, map); } /** - * Test NULL MainEntity input for new ServiceGroup instance + * Test NULL MainEntity input for new ServiceGroup instance. * * @throws Exception - unexpected exception */ @Test(expected = NullPointerException.class) public void instantiationClusterSingletonServiceGroupNullCloseEntityTest() throws Exception { - singletonServiceGroup = new ClusterSingletonServiceGroupImpl(SERVICE_IDENTIFIER, mainEntity, null, mockEosService, map); + singletonServiceGroup = new ClusterSingletonServiceGroupImpl( + SERVICE_IDENTIFIER, mainEntity, null, mockEosService, map); } /** - * Test NULL MainEntity input for new ServiceGroup instance + * Test NULL MainEntity input for new ServiceGroup instance. * * @throws Exception - unexpected exception */ @Test(expected = NullPointerException.class) public void instantiationClusterSingletonServiceGroupNullEOS_Test() throws Exception { - singletonServiceGroup = new ClusterSingletonServiceGroupImpl(SERVICE_IDENTIFIER, mainEntity, closeEntity, null, map); + singletonServiceGroup = new ClusterSingletonServiceGroupImpl( + SERVICE_IDENTIFIER, mainEntity, closeEntity, null, map); } /** - * Test NULL MainEntity input for new ServiceGroup instance + * Test NULL MainEntity input for new ServiceGroup instance. * * @throws Exception - unexpected exception */ @Test(expected = NullPointerException.class) public void instantiationClusterSingletonServiceGroupNullMapRefTest() throws Exception { - singletonServiceGroup = new ClusterSingletonServiceGroupImpl(SERVICE_IDENTIFIER, mainEntity, closeEntity, mockEosService, null); + singletonServiceGroup = new ClusterSingletonServiceGroupImpl( + SERVICE_IDENTIFIER, mainEntity, closeEntity, mockEosService, null); } /** - * Test GoldPath for initialization ServiceGroup + * Test GoldPath for initialization ServiceGroup. * * @throws Exception - unexpected exception */ @@ -160,7 +171,7 @@ public class ClusterSingletonServiceGroupImplTest { } /** - * Test GoldPath for NO-TO-SLAVE entity Candidate role change + * Test GoldPath for NO-TO-SLAVE entity Candidate role change. * * @throws Exception - unexpected exception */ @@ -177,7 +188,7 @@ public class ClusterSingletonServiceGroupImplTest { } /** - * Test GoldPath for NO-TO-SLAVE but without MASTER entity Candidate role change + * Test GoldPath for NO-TO-SLAVE but without MASTER entity Candidate role change. * * @throws Exception - unexpected exception */ @@ -194,7 +205,7 @@ public class ClusterSingletonServiceGroupImplTest { } /** - * Test GoldPath for InJeopardy entity Candidate role change + * Test GoldPath for InJeopardy entity Candidate role change. * * @throws Exception - unexpected exception */ @@ -214,7 +225,7 @@ public class ClusterSingletonServiceGroupImplTest { } /** - * Test GoldPath for registration SingletonService + * Test GoldPath for registration SingletonService. * * @throws Exception - unexpected exception */ @@ -228,7 +239,7 @@ public class ClusterSingletonServiceGroupImplTest { } /** - * Test GoldPath for registration SingletonService + * Test GoldPath for registration SingletonService. * * @throws Exception - unexpected exception */ @@ -246,7 +257,7 @@ public class ClusterSingletonServiceGroupImplTest { /** * Test GoldPath for unregistration SingletonService don't call closeServiceInstance - * without mastership and don't remove ServiceGroup from map + * without mastership and don't remove ServiceGroup from map. * * @throws Exception - unexpected exception */ @@ -266,7 +277,7 @@ public class ClusterSingletonServiceGroupImplTest { /** * Test GoldPath for unregistration SingletonService don't call closeServiceInstance - * without mastership and don't remove ServiceGroup from map + * without mastership and don't remove ServiceGroup from map. * * @throws Exception - unexpected exception */ @@ -288,7 +299,7 @@ public class ClusterSingletonServiceGroupImplTest { } /** - * Test GoldPath get Slave role for registered main entity + * Test GoldPath get Slave role for registered main entity. * * @throws Exception - unexpected exception */ @@ -304,7 +315,7 @@ public class ClusterSingletonServiceGroupImplTest { } /** - * Test GoldPath get Master role for registered main entity + * Test GoldPath get Master role for registered main entity. * * @throws Exception - unexpected exception */ @@ -321,7 +332,7 @@ public class ClusterSingletonServiceGroupImplTest { } /** - * Test GoldPath get Master role for registered close entity + * Test GoldPath get Master role for registered close entity. * * @throws Exception - unexpected exception */ @@ -341,7 +352,7 @@ public class ClusterSingletonServiceGroupImplTest { /** * Test GoldPath get Master role for registered entity but initial Slave - * role for closeEntity + * role for closeEntity. * * @throws Exception - unexpected exception */ @@ -364,7 +375,7 @@ public class ClusterSingletonServiceGroupImplTest { } /** - * Test inJeopardy validation during wait phase for Master role for closeEntity + * Test inJeopardy validation during wait phase for Master role for closeEntity. * * @throws Exception - unexpected exception */ @@ -387,7 +398,7 @@ public class ClusterSingletonServiceGroupImplTest { } /** - * Test inJeopardy validation during wait phase for Master role for closeEntity + * Test inJeopardy validation during wait phase for Master role for closeEntity. * * @throws Exception - unexpected exception */ @@ -413,7 +424,7 @@ public class ClusterSingletonServiceGroupImplTest { } /** - * Test inJeopardy validation for holding leadership + * Test inJeopardy validation for holding leadership. * * @throws Exception - unexpected exception */ @@ -437,7 +448,7 @@ public class ClusterSingletonServiceGroupImplTest { } /** - * Test GoldPath for SLAVE-TO-MASTER entity Candidate role change + * Test GoldPath for SLAVE-TO-MASTER entity Candidate role change. * * @throws Exception - unexpected exception */ @@ -459,8 +470,8 @@ public class ClusterSingletonServiceGroupImplTest { /** * Test checks validation Error processing for SLAVE-TO-MASTER entity Candidate role change. - * Not initialized provider has to close and remove all singletonServices from Group and - * Group itself remove too. + * Not initialized provider has to close and remove all singletonServices from Group and + * Group itself remove too. * * @throws Exception - unexpected exception */ @@ -475,7 +486,7 @@ public class ClusterSingletonServiceGroupImplTest { } /** - * Test checks closing procesing for close {@link ClusterSingletonServiceRegistration} + * Test checks closing procesing for close {@link ClusterSingletonServiceRegistration}. * * @throws Exception - unexpected exception */ @@ -497,7 +508,7 @@ public class ClusterSingletonServiceGroupImplTest { } /** - * Test checks validation Error processing for MASTER-TO-SLAVE closeEntity Candidate role change + * Test checks validation Error processing for MASTER-TO-SLAVE closeEntity Candidate role change. * * @throws Exception - unexpected exception */ @@ -522,7 +533,7 @@ public class ClusterSingletonServiceGroupImplTest { /** * Test checks validation Error processing for MASTER-TO-SLAVE closeEntity Candidate role change - * without closeEntity registration + * without closeEntity registration. * * @throws Exception - unexpected exception */ @@ -568,7 +579,8 @@ public class ClusterSingletonServiceGroupImplTest { } private GenericEntityOwnershipChange getEntityToJeopardy() { - return new GenericEntityOwnershipChange<>(mainEntity, EntityOwnershipChangeState.from(false, false, false), true); + return new GenericEntityOwnershipChange<>(mainEntity, + EntityOwnershipChangeState.from(false, false, false), true); } } diff --git a/singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/ClusterSingletonServiceRegistrationDelegatorTest.java b/singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/ClusterSingletonServiceRegistrationDelegatorTest.java index d79b09b3df..b16d61472f 100644 --- a/singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/ClusterSingletonServiceRegistrationDelegatorTest.java +++ b/singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/ClusterSingletonServiceRegistrationDelegatorTest.java @@ -12,6 +12,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; + import com.google.common.util.concurrent.Futures; import org.junit.Assert; import org.junit.Before; @@ -20,12 +21,9 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; -import org.opendaylight.mdsal.singleton.dom.impl.ClusterSingletonServiceGroup; -import org.opendaylight.mdsal.singleton.dom.impl.ClusterSingletonServiceGroupImpl; -import org.opendaylight.mdsal.singleton.dom.impl.ClusterSingletonServiceRegistrationDelegator; /** - * Testing {@link ClusterSingletonServiceRegistrationDelegator} + * Testing {@link ClusterSingletonServiceRegistrationDelegator}. */ public class ClusterSingletonServiceRegistrationDelegatorTest { @@ -41,7 +39,7 @@ public class ClusterSingletonServiceRegistrationDelegatorTest { private ClusterSingletonServiceRegistrationDelegator delegator; /** - * Initialization functionality for every Tests in this suite + * Initialization functionality for every Tests in this suite. * * @throws Exception - unexpected setup exception */ @@ -59,7 +57,7 @@ public class ClusterSingletonServiceRegistrationDelegatorTest { } /** - * Test create input with {@link ClusterSingletonService} as null + * Test create input with {@link ClusterSingletonService} as null. */ @Test(expected = NullPointerException.class) public void testSetupNullService() { @@ -67,7 +65,7 @@ public class ClusterSingletonServiceRegistrationDelegatorTest { } /** - * Test create input with {@link ClusterSingletonServiceGroupImpl} as null + * Test create input with {@link ClusterSingletonServiceGroupImpl} as null. */ @Test(expected = NullPointerException.class) public void testSetupNullGroup() { @@ -75,7 +73,7 @@ public class ClusterSingletonServiceRegistrationDelegatorTest { } /** - * Test a method delegation {@link ClusterSingletonService#instantiateServiceInstance()} + * Test a method delegation {@link ClusterSingletonService#instantiateServiceInstance()}. */ @Test public void testInstatiateServiceDelegMethod() { @@ -84,7 +82,7 @@ public class ClusterSingletonServiceRegistrationDelegatorTest { } /** - * Test a method delegation {@link ClusterSingletonService#instantiateServiceInstance()} + * Test a method delegation {@link ClusterSingletonService#instantiateServiceInstance()}. */ @Test public void testCloseServiceDelegMethod() { @@ -93,7 +91,7 @@ public class ClusterSingletonServiceRegistrationDelegatorTest { } /** - * Test a method delegation {@link ClusterSingletonService#getIdentifier()} + * Test a method delegation {@link ClusterSingletonService#getIdentifier()}. */ @Test public void testGetServiceIdentifierDelegMethod() { @@ -103,7 +101,8 @@ public class ClusterSingletonServiceRegistrationDelegatorTest { } /** - * Test a close method delegation to {@link ClusterSingletonServiceGroupImpl#unregisterService(ClusterSingletonService)} + * Test a close method delegation to + * {@link ClusterSingletonServiceGroupImpl#unregisterService(ClusterSingletonService)}. * * @throws Exception is from AutoclosableInterface */ diff --git a/singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/DOMClusterSingletonServiceProviderImplTest.java b/singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/DOMClusterSingletonServiceProviderImplTest.java index 6a05eb1cbb..096b875931 100644 --- a/singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/DOMClusterSingletonServiceProviderImplTest.java +++ b/singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/DOMClusterSingletonServiceProviderImplTest.java @@ -15,6 +15,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; + import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import org.junit.Assert; @@ -34,7 +35,7 @@ import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegist import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; /** - * Testing {@link DOMClusterSingletonServiceProviderImpl} implementation + * Testing {@link DOMClusterSingletonServiceProviderImpl} implementation. */ public class DOMClusterSingletonServiceProviderImplTest { @@ -61,9 +62,9 @@ public class DOMClusterSingletonServiceProviderImplTest { private final DOMEntity doubleEntity = new DOMEntity(CLOSE_SERVICE_ENTITY_TYPE, SERVICE_NAME); /** - * Initialization functionality for every Tests in this suite + * Initialization functionality for every Tests in this suite. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Before public void setup() throws Exception { @@ -93,9 +94,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test checks NullPointer for null {@link DOMEntityOwnershipService} input value + * Test checks NullPointer for null {@link DOMEntityOwnershipService} input value. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test(expected = NullPointerException.class) public void initializationClusterSingletonServiceProviderNullInputTest() throws Exception { @@ -103,9 +104,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test GoldPath for close {@link DOMClusterSingletonServiceProviderImpl} + * Test GoldPath for close {@link DOMClusterSingletonServiceProviderImpl}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void closeClusterSingletonServiceProviderTest() throws Exception { @@ -117,9 +118,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test parser ServiceIdentifier from Entity + * Test parser ServiceIdentifier from Entity. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void makeEntityClusterSingletonServiceProviderTest() throws Exception { @@ -131,9 +132,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test parser ServiceIdentifier from Entity + * Test parser ServiceIdentifier from Entity. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void getIdentifierClusterSingletonServiceProviderTest() throws Exception { @@ -144,9 +145,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test GoldPath for initialization {@link ClusterSingletonService} + * Test GoldPath for initialization {@link ClusterSingletonService}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void initializationClusterSingletonServiceTest() throws Exception { @@ -158,9 +159,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test GoldPath for initialization with init ownership result SLAVE {@link ClusterSingletonService} + * Test GoldPath for initialization with init ownership result SLAVE {@link ClusterSingletonService}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void slaveInitClusterSingletonServiceTest() throws Exception { @@ -174,9 +175,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test GoldPath for initialization with init ownership result SLAVE, but NO-MASTER {@link ClusterSingletonService} + * Test GoldPath for initialization with init ownership result SLAVE, but NO-MASTER {@link ClusterSingletonService}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void slaveInitNoMasterClusterSingletonServiceTest() throws Exception { @@ -190,9 +191,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test GoldPath for initialization with init ownership result MASTER {@link ClusterSingletonService} + * Test GoldPath for initialization with init ownership result MASTER {@link ClusterSingletonService}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void masterInitClusterSingletonServiceTest() throws Exception { @@ -206,9 +207,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test GoldPath for initialization with init ownership result MASTER {@link ClusterSingletonService} + * Test GoldPath for initialization with init ownership result MASTER {@link ClusterSingletonService}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void masterInitSlaveDoubleCandidateClusterSingletonServiceTest() throws Exception { @@ -223,9 +224,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test GoldPath for takeLeadership with ownership result MASTER {@link ClusterSingletonService} + * Test GoldPath for takeLeadership with ownership result MASTER {@link ClusterSingletonService}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void takeLeadershipClusterSingletonServiceTest() throws Exception { @@ -241,9 +242,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test GoldPath for initialization with init ownership result MASTER {@link ClusterSingletonService} + * Test GoldPath for initialization with init ownership result MASTER {@link ClusterSingletonService}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void masterInitClusterSingletonServiceTwoServicesTest() throws Exception { @@ -261,9 +262,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test GoldPath for takeLeadership with ownership result MASTER {@link ClusterSingletonService} + * Test GoldPath for takeLeadership with ownership result MASTER {@link ClusterSingletonService}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void takeLeadershipClusterSingletonServiceTwoAddDuringWaitPhaseServicesTest() throws Exception { @@ -284,9 +285,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test GoldPath for takeLeadership with ownership result MASTER {@link ClusterSingletonService} + * Test GoldPath for takeLeadership with ownership result MASTER {@link ClusterSingletonService}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void takeLeadershipClusterSingletonServiceTowServicesTest() throws Exception { @@ -306,9 +307,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test checks CandidateAlreadyRegisteredException processing in initialization phase + * Test checks CandidateAlreadyRegisteredException processing in initialization phase. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void initializationClusterSingletonServiceCandidateAlreadyRegistredTest() throws Exception { @@ -320,9 +321,9 @@ public class DOMClusterSingletonServiceProviderImplTest { /** * Test GoldPath for lostLeadership during tryToTakeLeadership with ownership result MASTER - * {@link ClusterSingletonService} + * {@link ClusterSingletonService}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void lostLeadershipDuringTryToTakeLeadershipClusterSingletonServiceTest() throws Exception { @@ -340,9 +341,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test GoldPath for lostLeadership with ownership result MASTER-TO-SLAVE {@link ClusterSingletonService} + * Test GoldPath for lostLeadership with ownership result MASTER-TO-SLAVE {@link ClusterSingletonService}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void lostLeadershipClusterSingletonServiceTest() throws Exception { @@ -362,9 +363,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test checks umexpected change for MASTER-TO-SLAVE double Candidate role change + * Test checks umexpected change for MASTER-TO-SLAVE double Candidate role change. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void unexpectedLostLeadershipDoubleCandidateTest() throws Exception { @@ -387,9 +388,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test checks inJeopardy Cluster Node state for Master Instance + * Test checks inJeopardy Cluster Node state for Master Instance. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void inJeopardyMasterTest() throws Exception { @@ -413,9 +414,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test checks inJeopardy Cluster Node state for Slave Instance + * Test checks inJeopardy Cluster Node state for Slave Instance. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void inJeopardySlaveTest() throws Exception { @@ -435,9 +436,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test checks close procesing for {@link ClusterSingletonServiceRegistration} + * Test checks close processing for {@link ClusterSingletonServiceRegistration}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void closeClusterSingletonServiceRegistrationNoRoleTest() throws Exception { @@ -455,9 +456,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test checks close procesing for {@link ClusterSingletonServiceRegistration} + * Test checks close procesing for {@link ClusterSingletonServiceRegistration}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void closeClusterSingletonServiceRegistrationNoRoleTwoServicesTest() throws Exception { @@ -480,9 +481,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test checks close procesing for {@link ClusterSingletonServiceRegistration} + * Test checks close procesing for {@link ClusterSingletonServiceRegistration}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void closeClusterSingletonServiceRegistrationSlaveTest() throws Exception { @@ -501,9 +502,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test checks close procesing for {@link ClusterSingletonServiceRegistration} + * Test checks close procesing for {@link ClusterSingletonServiceRegistration}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void closeClusterSingletonServiceRegistrationSlaveTwoServicesTest() throws Exception { @@ -527,9 +528,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test checks close procesing for {@link ClusterSingletonServiceRegistration} + * Test checks close procesing for {@link ClusterSingletonServiceRegistration}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void closeClusterSingletonServiceRegistrationMasterTest() throws Exception { @@ -551,9 +552,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test checks close procesing for {@link ClusterSingletonServiceRegistration} + * Test checks close procesing for {@link ClusterSingletonServiceRegistration}. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void closeClusterSingletonServiceRegistrationMasterTwoServicesTest() throws Exception { @@ -581,9 +582,9 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Test checks validation Error processing for SLAVE-TO-MASTER entity Candidate role change + * Test checks validation Error processing for SLAVE-TO-MASTER entity Candidate role change. * - * @throws Exception + * @throws Exception if the condition does not meet */ @Test public void tryToTakeLeaderForClosedServiceRegistrationTest() throws Exception { @@ -643,32 +644,32 @@ public class DOMClusterSingletonServiceProviderImplTest { } /** - * Base states for AbstractClusterProjectProvider + * Base states for AbstractClusterProjectProvider. */ - static enum TestClusterSingletonServiceState { + enum TestClusterSingletonServiceState { /** - * State represents a correct Instantiated process + * State represents a correct Instantiated process. */ STARTED, /** - * State represents a correct call abstract method instantiatingProject + * State represents a correct call abstract method instantiatingProject. */ INITIALIZED, /** - * State represents a correct call abstract method destryingProject + * State represents a correct call abstract method destryingProject. */ DESTROYED; } /** - * Test implementation of {@link ClusterSingletonService} + * Test implementation of {@link ClusterSingletonService}. */ class TestClusterSingletonServiceInstance implements ClusterSingletonService { - private final ServiceGroupIdentifier SERVICE_IDENT = ServiceGroupIdentifier.create(SERVICE_NAME); + private final ServiceGroupIdentifier serviceIndent = ServiceGroupIdentifier.create(SERVICE_NAME); private TestClusterSingletonServiceState serviceState; - public TestClusterSingletonServiceInstance() { + TestClusterSingletonServiceInstance() { this.serviceState = TestClusterSingletonServiceState.INITIALIZED; } @@ -689,7 +690,7 @@ public class DOMClusterSingletonServiceProviderImplTest { @Override public ServiceGroupIdentifier getIdentifier() { - return SERVICE_IDENT; + return serviceIndent; } } } diff --git a/singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/util/TestInstanceIdentifier.java b/singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/util/TestInstanceIdentifier.java index 92597bceb4..b7b07045f0 100644 --- a/singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/util/TestInstanceIdentifier.java +++ b/singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/util/TestInstanceIdentifier.java @@ -23,11 +23,6 @@ public class TestInstanceIdentifier implements Path { private final ImmutableList path; - /** - * {@link TestInstanceIdentifier} constructor - * - * @param path - path - */ public TestInstanceIdentifier(final Iterable path) { Preconditions.checkArgument(path != null); final List tiis = new LinkedList<>();