Bug 8153: enforce check-style rules for netconf 67/57067/21
authorIvan Hrasko <ivan.hrasko@pantheon.tech>
Mon, 15 May 2017 13:50:39 +0000 (15:50 +0200)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Fri, 19 May 2017 08:37:50 +0000 (08:37 +0000)
- call-home

Change-Id: I1b5e2db2d6b0a4d3591e56d773cfcd4ffc13ae67
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
29 files changed:
netconf/callhome-protocol/pom.xml
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/AuthorizedKeysDecoder.java
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeAuthorization.java
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeAuthorizationProvider.java
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeChannelActivator.java
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeNetconfSubsystemListener.java
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeProtocolSessionContext.java
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/CallHomeSessionContext.java
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/MinaSshNettyChannel.java
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/NetconfCallHomeServer.java
netconf/callhome-protocol/src/test/java/org/opendaylight/netconf/callhome/protocol/AuthorizedKeysDecoderTest.java
netconf/callhome-protocol/src/test/java/org/opendaylight/netconf/callhome/protocol/CallHomeAuthorizationTest.java
netconf/callhome-protocol/src/test/java/org/opendaylight/netconf/callhome/protocol/CallHomeSessionContextTest.java
netconf/callhome-protocol/src/test/java/org/opendaylight/netconf/callhome/protocol/MinaSshNettyChannelTest.java
netconf/callhome-protocol/src/test/java/org/opendaylight/netconf/callhome/protocol/NetconfCallHomeServerTest.java
netconf/callhome-provider/pom.xml
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeAuthProviderImpl.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountDispatcher.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountSessionContext.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountSessionManager.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeTopology.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallhomeStatusReporter.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/Configuration.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/ContextKey.java
netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java
netconf/callhome-provider/src/main/resources/org/opendaylight/blueprint/callhome-topology.xml
netconf/callhome-provider/src/test/java/org/opendaylight/netconf/callhome/mount/CallHomeMountDispatcherTest.java
netconf/callhome-provider/src/test/java/org/opendaylight/netconf/callhome/mount/CallHomeMountSessionContextTest.java
netconf/callhome-provider/src/test/java/org/opendaylight/netconf/callhome/mount/ContextKeyTest.java

index bab86e4d82a52825756776f73a48f31a4c14ef4b..578d6a26bf2178b3879f7b608e74d3674574c6bb 100644 (file)
@@ -38,7 +38,6 @@
       <groupId>org.opendaylight.netconf</groupId>
       <artifactId>netconf-client</artifactId>
     </dependency>
-
     <dependency>
       <groupId>org.bouncycastle</groupId>
       <artifactId>bcpkix-jdk15on</artifactId>
       <scope>test</scope>
     </dependency>
   </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>
index 6702a44138c92bb4b2dcf2e3fcde06e339228e61..2f73805778256ecc488c5ad43760190ab6b8ea0a 100644 (file)
@@ -34,9 +34,8 @@ import org.bouncycastle.jce.ECPointUtil;
 import org.bouncycastle.jce.spec.ECNamedCurveParameterSpec;
 import org.bouncycastle.jce.spec.ECNamedCurveSpec;
 
-
 /**
- * FIXME: This should be probably located at AAA library
+ * FIXME: This should be probably located at AAA library.
  */
 public class AuthorizedKeysDecoder {
 
@@ -62,35 +61,41 @@ public class AuthorizedKeysDecoder {
     private byte[] bytes = new byte[0];
     private int pos = 0;
 
-
-    public PublicKey decodePublicKey(String keyLine) throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException {
+    public PublicKey decodePublicKey(String keyLine)
+            throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException {
 
         // look for the Base64 encoded part of the line to decode
         // both ssh-rsa and ssh-dss begin with "AAAA" due to the length bytes
         bytes = Base64.decodeBase64(keyLine.getBytes());
-        if (bytes.length == 0)
+        if (bytes.length == 0) {
             throw new IllegalArgumentException("No Base64 part to decode in " + keyLine);
+        }
+
         pos = 0;
 
         String type = decodeType();
-        if (type.equals(KEY_TYPE_RSA))
+        if (type.equals(KEY_TYPE_RSA)) {
             return decodeAsRSA();
+        }
 
-        if (type.equals(KEY_TYPE_DSA))
+        if (type.equals(KEY_TYPE_DSA)) {
             return decodeAsDSA();
+        }
 
-        if (type.equals(KEY_TYPE_ECDSA))
-            return decodeAsECDSA();
+        if (type.equals(KEY_TYPE_ECDSA)) {
+            return decodeAsEcDSA();
+        }
 
         throw new IllegalArgumentException("Unknown decode key type " + type + " in " + keyLine);
     }
 
-    private PublicKey decodeAsECDSA()
+    private PublicKey decodeAsEcDSA()
             throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException {
         KeyFactory ecdsaFactory = SecurityUtils.getKeyFactory(KEY_FACTORY_TYPE_ECDSA);
 
         ECNamedCurveParameterSpec spec256r1 = ECNamedCurveTable.getParameterSpec(ECDSA_SUPPORTED_CURVE_NAME_SPEC);
-        ECNamedCurveSpec params256r1 = new ECNamedCurveSpec(ECDSA_SUPPORTED_CURVE_NAME_SPEC, spec256r1.getCurve(), spec256r1.getG(), spec256r1.getN());
+        ECNamedCurveSpec params256r1 = new ECNamedCurveSpec(
+            ECDSA_SUPPORTED_CURVE_NAME_SPEC, spec256r1.getCurve(), spec256r1.getG(), spec256r1.getN());
         // copy last 65 bytes from ssh key.
         ECPoint point = ECPointUtil.decodePoint(params256r1.getCurve(), Arrays.copyOfRange(bytes, 39, bytes.length));
         ECPublicKeySpec pubKeySpec = new ECPublicKeySpec(point, params256r1);
@@ -100,11 +105,11 @@ public class AuthorizedKeysDecoder {
 
     private PublicKey decodeAsDSA() throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException {
         KeyFactory dsaFactory = SecurityUtils.getKeyFactory(KEY_FACTORY_TYPE_DSA);
-        BigInteger p = decodeBigInt();
-        BigInteger q = decodeBigInt();
-        BigInteger g = decodeBigInt();
-        BigInteger y = decodeBigInt();
-        DSAPublicKeySpec spec = new DSAPublicKeySpec(y, p, q, g);
+        BigInteger prime = decodeBigInt();
+        BigInteger subPrime = decodeBigInt();
+        BigInteger base = decodeBigInt();
+        BigInteger publicKey = decodeBigInt();
+        DSAPublicKeySpec spec = new DSAPublicKeySpec(publicKey, prime, subPrime, base);
 
         return dsaFactory.generatePublic(spec);
     }
@@ -172,17 +177,16 @@ public class AuthorizedKeysDecoder {
             dout.writeInt(ECDSA_SUPPORTED_CURVE_NAME.getBytes().length);
             dout.write(ECDSA_SUPPORTED_CURVE_NAME.getBytes());
 
-            byte[] x = ecPublicKey.getQ().getAffineXCoord().getEncoded();
-            byte[] y = ecPublicKey.getQ().getAffineYCoord().getEncoded();
-            dout.writeInt(x.length + y.length + 1);
+            byte[] coordX = ecPublicKey.getQ().getAffineXCoord().getEncoded();
+            byte[] coordY = ecPublicKey.getQ().getAffineYCoord().getEncoded();
+            dout.writeInt(coordX.length + coordY.length + 1);
             dout.writeByte(0x04);
-            dout.write(x);
-            dout.write(y);
+            dout.write(coordX);
+            dout.write(coordY);
         } else {
             throw new IllegalArgumentException("Unknown public key encoding: " + publicKey.getAlgorithm());
         }
         publicKeyEncoded = new String(Base64.encodeBase64(byteOs.toByteArray()));
         return publicKeyEncoded;
-
     }
 }
index c2b3b2dc61045cd66f62617595b94c694633bf03..03edbdac7cf609b0498eb91a00f33ab113c41a6f 100644 (file)
@@ -43,9 +43,11 @@ public abstract class CallHomeAuthorization {
     /**
      * Returns CallHomeAuthorization object with intent to
      * reject incoming connection.
+     *
      * <p>
      * {@link CallHomeAuthorizationProvider} may use returned object
-     * as return value for {@link CallHomeAuthorizationProvider#provideAuth(java.net.SocketAddress, java.security.PublicKey)}
+     * as return value for
+     * {@link CallHomeAuthorizationProvider#provideAuth(java.net.SocketAddress, java.security.PublicKey)}
      * if the incoming session should be rejected due to policy implemented
      * by provider.
      *
@@ -58,6 +60,7 @@ public abstract class CallHomeAuthorization {
     /**
      * Creates a builder for CallHomeAuthorization with intent
      * to accept incoming connection and to provide credentials.
+     *
      * <p>
      * Note: If session with same sessionName is already opened and
      * active, incoming session will be rejected.
@@ -78,7 +81,7 @@ public abstract class CallHomeAuthorization {
     public abstract boolean isServerAllowed();
 
     /**
-     * Applies provided authentification to Mina SSH Client Session
+     * Applies provided authentification to Mina SSH Client Session.
      *
      * @param session Client Session to which authorization parameters will by applied
      */
@@ -88,6 +91,7 @@ public abstract class CallHomeAuthorization {
 
     /**
      * Builder for CallHomeAuthorization which accepts incoming connection.
+     *
      * <p>
      * Use {@link CallHomeAuthorization#serverAccepted(String, String)} to instantiate
      * builder.
@@ -140,7 +144,8 @@ public abstract class CallHomeAuthorization {
         private final Set<String> passwords;
         private final Set<KeyPair> clientKeyPair;
 
-        ServerAllowed(String nodeId, String username, Collection<String> passwords, Collection<KeyPair> clientKeyPairs) {
+        ServerAllowed(String nodeId, String username, Collection<String> passwords,
+                      Collection<KeyPair> clientKeyPairs) {
             this.username = Preconditions.checkNotNull(username);
             this.passwords = ImmutableSet.copyOf(passwords);
             this.clientKeyPair = ImmutableSet.copyOf(clientKeyPairs);
index 40f180d14edd82003de4699f5a615071dd8637ab..85a1cef2f194b05bdbd9a290d1502c57a63f7efd 100644 (file)
@@ -12,7 +12,7 @@ import java.security.PublicKey;
 import javax.annotation.Nonnull;
 
 /**
- * Provider responsible for resolving CallHomeAuthorization
+ * Provider responsible for resolving CallHomeAuthorization.
  */
 public interface CallHomeAuthorizationProvider {
 
index 03cba3c42e9c4cba92a073a32c8bc2c4022df8aa..0fad0a5b1be3a8fb4911d83f04759bac23a306de 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.netconf.client.NetconfClientSessionListener;
 public interface CallHomeChannelActivator {
     /**
      * Activates Netconf Client Channel with supplied client session listener.
+     *
      * <p>
      * Activation of channel will result in start of NETCONF client
      * session negotiation on underlying ssh channel.
index 36c3df7d8b88e0365ed4a339dab5586189b5141f..32f1e21f216702875b4e4ffd88af1cc50cfe0334 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.netconf.client.NetconfClientSessionListener;
 public interface CallHomeNetconfSubsystemListener {
     /**
      * Invoked when Netconf Subsystem was successfully opened on incoming SSH Call Home connection.
+     *
      * <p>
      * Implementors of this method should use provided {@link CallHomeChannelActivator} to attach
      * {@link NetconfClientSessionListener} to session and to start NETCONF client session negotiation.
index 3985631f37efda61d620f2e9f5cb26d39183a0c8..3814e9d68324d2fd54ffe2ff005865ac87cc0a8a 100644 (file)
@@ -16,7 +16,7 @@ import java.security.PublicKey;
 public interface CallHomeProtocolSessionContext {
 
     /**
-     * Returns session identifier provided by  CallHomeAuthorizationProvider
+     * Returns session identifier provided by  CallHomeAuthorizationProvider.
      *
      * @return Returns application-provided session identifier
      */
index 3bdbd5c658dae7487237e0a56dfe28624d318ae3..4f37f987d52f2d4d3ea3f1c4e83993f5bfce9e86 100644 (file)
@@ -94,15 +94,15 @@ class CallHomeSessionContext implements CallHomeProtocolSessionContext {
         };
     }
 
-    private void channelOpenFailed(Throwable e) {
-        LOG.error("Unable to open netconf subsystem, disconnecting.", e);
+    private void channelOpenFailed(Throwable throwable) {
+        LOG.error("Unable to open netconf subsystem, disconnecting.", throwable);
         sshSession.close(false);
     }
 
     private void netconfChannelOpened(ClientChannel netconfChannel) {
         nettyChannel = newMinaSshNettyChannel(netconfChannel);
-        factory.getChannelOpenListener().onNetconfSubsystemOpened(CallHomeSessionContext.this,
-                listener -> doActivate(listener));
+        factory.getChannelOpenListener().onNetconfSubsystemOpened(
+            CallHomeSessionContext.this, this::doActivate);
     }
 
     @GuardedBy("this")
index 0188dc72e08a985c1dae915b4cae9374449f51cd..9975c94962815fce280f59113e0bbb957e716ad5 100644 (file)
@@ -45,8 +45,8 @@ class MinaSshNettyChannel extends AbstractServerChannel {
         this.context = Preconditions.checkNotNull(context);
         this.session = Preconditions.checkNotNull(session);
         this.sshChannel = Preconditions.checkNotNull(sshChannel);
-        this.sshReadHandler = new AsyncSshHandlerReader(new ConnectionClosedDuringRead(), new FireReadMessage(), "netconf",
-                sshChannel.getAsyncOut());
+        this.sshReadHandler = new AsyncSshHandlerReader(
+            new ConnectionClosedDuringRead(), new FireReadMessage(), "netconf", sshChannel.getAsyncOut());
         this.sshWriteAsyncHandler = new AsyncSshHandlerWriter(sshChannel.getAsyncIn());
         pipeline().addFirst(createChannelAdapter());
     }
@@ -163,7 +163,7 @@ class MinaSshNettyChannel extends AbstractServerChannel {
     private final class ConnectionClosedDuringRead implements AutoCloseable {
 
         /**
-         * Invoked when SSH session dropped during read using {@link AsyncSshHandlerReader}
+         * Invoked when SSH session dropped during read using {@link AsyncSshHandlerReader}.
          */
         @Override
         public void close() throws Exception {
index 46802954627e74fc9b904e38142e0e776b2760c6..34658aae5588a6bc7e5aa2426852914937c87fbf 100644 (file)
@@ -69,7 +69,6 @@ public class NetconfCallHomeServer implements AutoCloseable, ServerKeyVerifier {
         }
     }
 
-
     protected IoServiceFactory createMinaServiceFactory(SshClient sshClient) {
         return new MinaServiceFactory(sshClient);
     }
@@ -78,14 +77,14 @@ public class NetconfCallHomeServer implements AutoCloseable, ServerKeyVerifier {
         return new SessionListener() {
             @Override
             public void sessionEvent(Session session, Event event) {
-                ClientSession cSession = (ClientSession) session;
+                ClientSession clientSession = (ClientSession) session;
                 LOG.debug("SSH session {} event {}", session, event);
                 switch (event) {
                     case KeyEstablished:
-                        doAuth(cSession);
+                        doAuth(clientSession);
                         break;
                     case Authenticated:
-                        doPostAuth(cSession);
+                        doPostAuth(clientSession);
                         break;
                     default:
                         break;
@@ -108,20 +107,20 @@ public class NetconfCallHomeServer implements AutoCloseable, ServerKeyVerifier {
         };
     }
 
-    private void doPostAuth(final ClientSession cSession) {
-        CallHomeSessionContext.getFrom(cSession).openNetconfChannel();
+    private void doPostAuth(final ClientSession session) {
+        CallHomeSessionContext.getFrom(session).openNetconfChannel();
     }
 
-    private void doAuth(final ClientSession cSession) {
+    private void doAuth(final ClientSession session) {
         try {
-            final AuthFuture authFuture = CallHomeSessionContext.getFrom(cSession).authorize();
-            authFuture.addListener(newAuthSshFutureListener(cSession));
+            final AuthFuture authFuture = CallHomeSessionContext.getFrom(session).authorize();
+            authFuture.addListener(newAuthSshFutureListener(session));
         } catch (IOException e) {
-            LOG.error("Failed to authorize session {}", cSession, e);
+            LOG.error("Failed to authorize session {}", session, e);
         }
     }
 
-    private SshFutureListener<AuthFuture> newAuthSshFutureListener(final ClientSession cSession) {
+    private SshFutureListener<AuthFuture> newAuthSshFutureListener(final ClientSession session) {
         return new SshFutureListener<AuthFuture>() {
             @Override
             public void operationComplete(AuthFuture authFuture) {
@@ -140,19 +139,19 @@ public class NetconfCallHomeServer implements AutoCloseable, ServerKeyVerifier {
             }
 
             private void onFailure(Throwable throwable) {
-                ClientSessionImpl impl = (ClientSessionImpl) cSession;
-                LOG.error("Authorize failed for session {}", cSession, throwable);
+                ClientSessionImpl impl = (ClientSessionImpl) session;
+                LOG.error("Authorize failed for session {}", session, throwable);
 
                 KeyExchange kex = impl.getKex();
                 PublicKey key = kex.getServerKey();
                 recorder.reportFailedAuth(key);
 
-                cSession.close(true);
+                session.close(true);
             }
 
             private void onCanceled() {
                 LOG.warn("Authorize cancelled");
-                cSession.close(true);
+                session.close(true);
             }
         };
     }
@@ -165,13 +164,15 @@ public class NetconfCallHomeServer implements AutoCloseable, ServerKeyVerifier {
             LOG.info("Incoming session {} was rejected by Authorization Provider.", sshClientSession);
             return false;
         }
-        CallHomeSessionContext session = sessionFactory.createIfNotExists(sshClientSession, authorization, remoteAddress);
+        CallHomeSessionContext session = sessionFactory.createIfNotExists(
+            sshClientSession, authorization, remoteAddress);
         // Session was created, session with same name does not exists
         if (session != null) {
             return true;
         }
         // Session was not created, session with same name exists
-        LOG.info("Incoming session {} was rejected. Session with same name {} is already active.", sshClientSession, authorization.getSessionName());
+        LOG.info("Incoming session {} was rejected. Session with same name {} is already active.",
+            sshClientSession, authorization.getSessionName());
         return false;
     }
 
index 87bc6807e979ccfa4cad5bb396a6f4c011e327c4..a085b490194b05146b26d38a34fe8c89f22b21ae 100644 (file)
@@ -15,7 +15,6 @@ import java.security.PublicKey;
 import org.junit.Before;
 import org.junit.Test;
 
-
 public class AuthorizedKeysDecoderTest {
 
     private AuthorizedKeysDecoder instance;
@@ -25,6 +24,7 @@ public class AuthorizedKeysDecoderTest {
         instance = new AuthorizedKeysDecoder();
     }
 
+    @SuppressWarnings("checkstyle:lineLength")
     @Test
     public void authorizedKeysDecoderValidRSAKey() throws GeneralSecurityException {
         // given
@@ -35,6 +35,7 @@ public class AuthorizedKeysDecoderTest {
         assertEquals(serverKey.getAlgorithm(), "RSA");
     }
 
+    @SuppressWarnings("checkstyle:lineLength")
     @Test(expected = Exception.class)
     public void authorizedKeysDecoderInvalidRSAKey() throws GeneralSecurityException {
         // given
@@ -43,6 +44,7 @@ public class AuthorizedKeysDecoderTest {
         instance.decodePublicKey(rsaStr);
     }
 
+    @SuppressWarnings("checkstyle:lineLength")
     @Test
     public void authorizedKeysDecoderValidDSAKey() throws GeneralSecurityException {
         // given
@@ -53,6 +55,7 @@ public class AuthorizedKeysDecoderTest {
         assertEquals(serverKey.getAlgorithm(), "DSA");
     }
 
+    @SuppressWarnings("checkstyle:lineLength")
     @Test(expected = IllegalArgumentException.class)
     public void authorizedKeysDecoderInvalidDSAKey() throws GeneralSecurityException {
         // given
@@ -61,8 +64,9 @@ public class AuthorizedKeysDecoderTest {
         instance.decodePublicKey(dsaStr);
     }
 
+    @SuppressWarnings("checkstyle:lineLength")
     @Test
-    public void authorizedKeysDecoderValidECDSAKey() throws GeneralSecurityException {
+    public void authorizedKeysDecoderValidEcDSAKey() throws GeneralSecurityException {
         // given
         String ecdsaStr = "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBAP4dTrlwZmz8bZ1f901qWuFk7YelrL2WJG0jrCEAPo9UNM1wywpqjbaYUfoq+cevhLZaukDQ4N2Evux+YQ2zz0=";
         // when
@@ -71,8 +75,9 @@ public class AuthorizedKeysDecoderTest {
         assertEquals(serverKey.getAlgorithm(), "EC");
     }
 
+    @SuppressWarnings("checkstyle:lineLength")
     @Test(expected = IllegalArgumentException.class)
-    public void authorizedKeysDecoderInvalidECDSAKey() throws GeneralSecurityException {
+    public void authorizedKeysDecoderInvalidEcDSAKey() throws GeneralSecurityException {
         // given
         String ecdsaStr = "AAAAE2VjZHNhLXNoItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBAP4dTrlwZmz8bZ1f901qWuFk7YelrL2WJG0jrCEAPo9UNM1wywpqjbaYUfoq+cevhLZaukDQ4N2Evux+YQ2zz0=";
         // when
index 08f9a5fb8568e26afc1054203ad5cab65737654d..aa742581ec17af8d1a369bbd3b46a044cd7e1809 100644 (file)
@@ -24,7 +24,6 @@ import org.apache.sshd.ClientSession;
 import org.apache.sshd.client.session.ClientSessionImpl;
 import org.junit.Test;
 
-
 public class CallHomeAuthorizationTest {
     @Test
     public void anAuthorizationOfRejectedIsNotAllowed() {
index 8c80409e0b6aa3c465a76dfeebbed543babfc9d0..032679e94d5789d3cd4f2712843b080daa80c09c 100644 (file)
@@ -188,7 +188,6 @@ public class CallHomeSessionContextTest {
         // given
         instance = realFactory.createIfNotExists(mockSession, mockAuth, address);
 
-        SshFutureListener<OpenFuture> listener = instance.newSshFutureListener(mockChannel);
         OpenFuture mockFuture = mock(OpenFuture.class);
         Mockito.doReturn(false).when(mockFuture).isOpened();
         Mockito.doReturn(new RuntimeException("test")).when(mockFuture).getException();
@@ -196,6 +195,7 @@ public class CallHomeSessionContextTest {
         doReturn(null).when(mockSession).close(anyBoolean());
 
         // when
+        SshFutureListener<OpenFuture> listener = instance.newSshFutureListener(mockChannel);
         listener.operationComplete(mockFuture);
         // then
         // You'll see an error message logged to the console - it is expected.
index 20cd05d2a20a47f268a4a0775e8435b475a13081..c846f1feeaab348730fecaa13ca235bf80fa644e 100644 (file)
@@ -32,7 +32,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
 
-
 public class MinaSshNettyChannelTest {
     private CallHomeSessionContext mockContext;
     private ClientSession mockSession;
@@ -44,11 +43,12 @@ public class MinaSshNettyChannelTest {
         IoReadFuture mockFuture = mock(IoReadFuture.class);
         IoInputStream mockIn = mock(IoInputStream.class);
         Mockito.doReturn(mockFuture).when(mockIn).read(any(Buffer.class));
-        IoOutputStream mockOut = mock(IoOutputStream.class);
         mockContext = mock(CallHomeSessionContext.class);
         mockSession = mock(ClientSession.class);
         mockChannel = mock(ClientChannel.class);
         Mockito.doReturn(mockIn).when(mockChannel).getAsyncOut();
+
+        IoOutputStream mockOut = mock(IoOutputStream.class);
         Mockito.doReturn(mockOut).when(mockChannel).getAsyncIn();
 
         IoWriteFuture mockWrFuture = mock(IoWriteFuture.class);
@@ -78,9 +78,6 @@ public class MinaSshNettyChannelTest {
         Mockito.doReturn(mockHandler).when(ctx).handler();
         ChannelPromise promise = mock(ChannelPromise.class);
 
-        ByteBufAllocator mockAlloc = mock(ByteBufAllocator.class);
-        ByteBuf bytes = new EmptyByteBuf(mockAlloc);
-
         // we would really like to just verify that the async handler write() was
         // called but it is a final class, so no mocking. instead we set up the
         // mock channel to have no async input, which will cause a failure later
@@ -95,6 +92,8 @@ public class MinaSshNettyChannelTest {
 
         // when
         ChannelOutboundHandlerAdapter outadapter = (ChannelOutboundHandlerAdapter) instance.pipeline().first();
+        ByteBufAllocator mockAlloc = mock(ByteBufAllocator.class);
+        ByteBuf bytes = new EmptyByteBuf(mockAlloc);
         outadapter.write(ctx, bytes, promise);
 
         // then
index 7a68f131ccd8fbf0551a72a9911819e040b3add3..d96f17a1f4f44b0b06c38e81e398383248496ac2 100644 (file)
@@ -59,7 +59,8 @@ public class NetconfCallHomeServerTest {
         props.put("nio-workers", "1");
         Mockito.doReturn(props).when(mockSshClient).getProperties();
         Mockito.doReturn("test").when(mockSession).toString();
-        instance = new NetconfCallHomeServer(mockSshClient, mockCallHomeAuthProv, mockFactory, mockAddress, mockStatusRecorder);
+        instance = new NetconfCallHomeServer(
+            mockSshClient, mockCallHomeAuthProv, mockFactory, mockAddress, mockStatusRecorder);
     }
 
     @Test
@@ -165,7 +166,8 @@ public class NetconfCallHomeServerTest {
         Mockito.doReturn(mockAcceptor).when(mockMinaFactory).createAcceptor(any(IoHandler.class));
         Mockito.doReturn(mockAcceptor).when(mockMinaFactory).createAcceptor(any(IoHandler.class));
         Mockito.doNothing().when(mockAcceptor).bind(mockAddress);
-        instance = new TestableCallHomeServer(mockSshClient, mockCallHomeAuthProv, mockFactory, mockAddress, mockMinaFactory, mockStatusRecorder);
+        instance = new TestableCallHomeServer(
+            mockSshClient, mockCallHomeAuthProv, mockFactory, mockAddress, mockMinaFactory, mockStatusRecorder);
         // when
         instance.bind();
         // then
index a82d63fd126b6b80412a3fae51cb29224c187a9d..9b4aaa14064d269ded6a75901dc2a87d17928e61 100644 (file)
             <artifactId>mockito-core</artifactId>
         </dependency>
     </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>
index 7f50653eed4fdc143d8670d2074d3d899908a863..83869ad286e7f5f23e0305e00eedc4ace990218b 100644 (file)
@@ -89,10 +89,11 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider,
                 statusReporter.asForceListedDevice(syntheticId, serverKey);
             } else {
                 Device opDevice = deviceOp.get(serverKey);
-                if (opDevice == null)
+                if (opDevice == null) {
                     statusReporter.asUnlistedDevice(syntheticId, serverKey);
-                else
+                } else {
                     LOG.info("Repeating rejection of unlisted device with id of {}", opDevice.getUniqueId());
+                }
                 return CallHomeAuthorization.rejected();
             }
         }
index 2241d6995ae2b93c7fe90df7b13e5a2740b602fe..dab26d92c2253c7f343f0e30aba85fe7a297f31b 100644 (file)
@@ -30,10 +30,9 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 public class CallHomeMountDispatcher implements NetconfClientDispatcher, CallHomeNetconfSubsystemListener {
 
-    private final static Logger LOG = LoggerFactory.getLogger(CallHomeMountDispatcher.class);
+    private static final Logger LOG = LoggerFactory.getLogger(CallHomeMountDispatcher.class);
 
     private final String topologyId;
     private final EventExecutor eventExecutor;
@@ -99,7 +98,8 @@ public class CallHomeMountDispatcher implements NetconfClientDispatcher, CallHom
     @Override
     public void onNetconfSubsystemOpened(final CallHomeProtocolSessionContext session,
                                          final CallHomeChannelActivator activator) {
-        final CallHomeMountSessionContext deviceContext = getSessionManager().createSession(session, activator, onCloseHandler);
+        final CallHomeMountSessionContext deviceContext = getSessionManager()
+            .createSession(session, activator, onCloseHandler);
         final NodeId nodeId = deviceContext.getId();
         final Node configNode = deviceContext.getConfigNode();
         LOG.info("Provisioning fake config {}", configNode);
index 16eed1f208ae74109a0210824ea4de7a9a2fce98..539f6ab3158d66a933c7af6fd825684bccae536c 100644 (file)
@@ -95,11 +95,11 @@ class CallHomeMountSessionContext {
             }
 
             @Override
-            public void onSessionDown(NetconfClientSession session, Exception e) {
+            public void onSessionDown(NetconfClientSession session, Exception exc) {
                 try {
                     removeSelf();
                 } finally {
-                    delegate.onSessionDown(session, e);
+                    delegate.onSessionDown(session, exc);
                 }
             }
 
index 0657740e28e8692db36d382d366cac672fec4102..f26d6ba421bbb4a78e6c6ca966919d079457a942 100644 (file)
@@ -23,8 +23,10 @@ import org.opendaylight.netconf.callhome.protocol.CallHomeProtocolSessionContext
 
 public class CallHomeMountSessionManager implements CallHomeMountSessionContext.CloseCallback {
 
-    private final ConcurrentMap<SocketAddress, CallHomeMountSessionContext> contextByAddress = new ConcurrentHashMap<>();
-    private final Multimap<PublicKey, CallHomeMountSessionContext> contextByPublicKey = MultimapBuilder.hashKeys().hashSetValues().build();
+    private final ConcurrentMap<SocketAddress, CallHomeMountSessionContext> contextByAddress =
+        new ConcurrentHashMap<>();
+    private final Multimap<PublicKey, CallHomeMountSessionContext> contextByPublicKey = MultimapBuilder.hashKeys()
+        .hashSetValues().build();
 
     @Nullable
     public CallHomeMountSessionContext getByAddress(InetSocketAddress remoteAddr) {
index 71a7af1340fe6a82d1f878cfa232543baa60b64a..c722f615ceaf91db612e557583de6f1f11cdc5cd 100644 (file)
@@ -20,7 +20,6 @@ import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceSalFacade;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.netconf.topology.api.SchemaRepositoryProvider;
 
-
 public class CallHomeTopology extends BaseCallHomeTopology {
 
     public CallHomeTopology(final String topologyId, final NetconfClientDispatcher clientDispatcher,
index ba551202f92713fff13f7c85ed261201585aa91e..ee068ec1fb20e37cc1d40062e696113463f356ac 100644 (file)
@@ -52,7 +52,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 class CallhomeStatusReporter implements DataChangeListener, StatusRecorder, AutoCloseable {
     private static final InstanceIdentifier<Topology> NETCONF_TOPO_IID =
             InstanceIdentifier.create(NetworkTopology.class).child(Topology.class,
@@ -65,15 +64,16 @@ class CallhomeStatusReporter implements DataChangeListener, StatusRecorder, Auto
 
     CallhomeStatusReporter(DataBroker broker) {
         this.dataBroker = broker;
-        this.reg = dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, NETCONF_TOPO_IID.child(Node.class),
-                this, AsyncDataBroker.DataChangeScope.SUBTREE);
+        this.reg = dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+            NETCONF_TOPO_IID.child(Node.class), this, AsyncDataBroker.DataChangeScope.SUBTREE);
     }
 
     @Override
     public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
         for (InstanceIdentifier<?> removedPath : change.getRemovedPaths()) {
-            if (removedPath.getTargetType() != NetconfNode.class)
+            if (removedPath.getTargetType() != NetconfNode.class) {
                 continue;
+            }
 
             final NodeId nodeId = getNodeId(removedPath);
             if (nodeId != null) {
@@ -125,8 +125,9 @@ class CallhomeStatusReporter implements DataChangeListener, StatusRecorder, Auto
             LOG.warn("No corresponding callhome device found - exiting.");
         } else {
             Device modifiedDevice = withConnectedStatus(opDev);
-            if (modifiedDevice == null)
+            if (modifiedDevice == null) {
                 return;
+            }
             LOG.info("Setting successful status for callhome device id:{}.", nodeId);
             writeDevice(nodeId, modifiedDevice);
         }
@@ -140,8 +141,9 @@ class CallhomeStatusReporter implements DataChangeListener, StatusRecorder, Auto
             LOG.warn("No corresponding callhome device found - exiting.");
         } else {
             Device modifiedDevice = withDisconnectedStatus(opDev);
-            if (modifiedDevice == null)
+            if (modifiedDevice == null) {
                 return;
+            }
             LOG.info("Setting disconnected status for callhome device id:{}.", nodeId);
             writeDevice(nodeId, modifiedDevice);
         }
@@ -158,8 +160,9 @@ class CallhomeStatusReporter implements DataChangeListener, StatusRecorder, Auto
             LOG.warn("No corresponding callhome device found - exiting.");
         } else {
             Device modifiedDevice = withFailedStatus(opDev);
-            if (modifiedDevice == null)
+            if (modifiedDevice == null) {
                 return;
+            }
             LOG.info("Setting failed status for callhome device id:{}.", nodeId);
             writeDevice(nodeId, modifiedDevice);
         }
@@ -182,8 +185,7 @@ class CallhomeStatusReporter implements DataChangeListener, StatusRecorder, Auto
         try {
             sshEncodedKey = AuthorizedKeysDecoder.encodePublicKey(serverKey);
         } catch (IOException e) {
-            e.printStackTrace();
-            LOG.warn("Unable to encode public key to ssh format.");
+            LOG.warn("Unable to encode public key to ssh format.", e);
         }
         Device1 d1 = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.FAILEDNOTALLOWED).build();
         DeviceBuilder builder = new DeviceBuilder()
@@ -258,16 +260,15 @@ class CallhomeStatusReporter implements DataChangeListener, StatusRecorder, Auto
 
     private void setDeviceStatus(Device device) {
         WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
-        InstanceIdentifier<Device> Device_IID =
+        InstanceIdentifier<Device> deviceIId =
                 InstanceIdentifier.create(NetconfCallhomeServer.class)
                         .child(AllowedDevices.class)
                         .child(Device.class, device.getKey());
 
-        tx.merge(LogicalDatastoreType.OPERATIONAL, Device_IID, device);
+        tx.merge(LogicalDatastoreType.OPERATIONAL, deviceIId, device);
         tx.submit();
     }
 
-
     private AllowedDevices getDevices() {
         ReadOnlyTransaction rxTransaction = dataBroker.newReadOnlyTransaction();
         CheckedFuture<Optional<AllowedDevices>, ReadFailedException> devicesFuture =
@@ -302,8 +303,9 @@ class CallhomeStatusReporter implements DataChangeListener, StatusRecorder, Auto
                 PublicKey pubKey = decoder.decodePublicKey(keyString);
                 if (sshKey.getAlgorithm().equals(pubKey.getAlgorithm()) && sshKey.equals(pubKey)) {
                     Device failedDevice = withFailedAuthStatus(device);
-                    if (failedDevice == null)
+                    if (failedDevice == null) {
                         return;
+                    }
                     LOG.info("Setting auth failed status for callhome device id:{}.", failedDevice.getUniqueId());
                     setDeviceStatus(failedDevice);
                     return;
index bc00292a682764d1e876e37ab7ac381486ecffbf..6a5c11b677e21d66117f98b3be40c4dc035c841e 100644 (file)
@@ -26,8 +26,8 @@ public class Configuration {
     }
 
     public static class ReadException extends ConfigurationException {
-        ReadException(String msg, Exception e) {
-            super(msg, e);
+        ReadException(String msg, Exception exc) {
+            super(msg, exc);
         }
     }
 
@@ -102,20 +102,22 @@ public class Configuration {
 
     String get(String key) {
         String result = (String) properties.get(key);
-        if (result == null)
+        if (result == null) {
             throw new MissingException(key);
+        }
         return result;
     }
 
     public int getAsPort(String key) {
-        String s = get(key);
+        String keyValue = get(key);
         try {
-            int newPort = Integer.parseInt(s);
-            if (newPort < 0 || newPort > 65535)
-                throw new IllegalValueException(key, s);
+            int newPort = Integer.parseInt(keyValue);
+            if (newPort < 0 || newPort > 65535) {
+                throw new IllegalValueException(key, keyValue);
+            }
             return newPort;
         } catch (NumberFormatException e) {
-            throw new IllegalValueException(key, s);
+            throw new IllegalValueException(key, keyValue);
         }
     }
 }
index 124f87d39c41e1bc869cff37b719a11b250e4130..3536d66090daf0a89bc15b7bda94b79c712ac216 100644 (file)
@@ -41,12 +41,15 @@ class ContextKey {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         ContextKey other = (ContextKey) obj;
         return Objects.equal(address, other.address) && Objects.equal(port, other.port);
     }
index 43479a0b3a5a12d3930a965fd0c467662b638940..903dd9ce7154e5c38e116e33f42238c3893ea135 100644 (file)
@@ -13,7 +13,6 @@ import static com.google.common.base.Preconditions.checkArgument;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
-import java.io.File;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
@@ -44,10 +43,10 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataChangeListener {
     private static final String APPNAME = "CallHomeServer";
-    static final InstanceIdentifier<AllowedDevices> ALL_DEVICES = InstanceIdentifier.create(NetconfCallhomeServer.class).child(AllowedDevices.class);
+    static final InstanceIdentifier<AllowedDevices> ALL_DEVICES = InstanceIdentifier.create(NetconfCallhomeServer.class)
+        .child(AllowedDevices.class);
 
     private static final Logger LOG = LoggerFactory.getLogger(IetfZeroTouchCallHomeServerProvider.class);
 
@@ -75,7 +74,8 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
         try {
             LOG.info("Initializing provider for {}", APPNAME);
             initializeServer();
-            dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, ALL_DEVICES, this, AsyncDataBroker.DataChangeScope.SUBTREE);
+            dataBroker.registerDataChangeListener(
+                LogicalDatastoreType.CONFIGURATION, ALL_DEVICES, this, AsyncDataBroker.DataChangeScope.SUBTREE);
             LOG.info("Initialization complete for {}", APPNAME);
         } catch (IOException | Configuration.ConfigurationException e) {
             LOG.error("Unable to successfully initialize", e);
@@ -88,7 +88,7 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
             configuration.set(CALL_HOME_PORT_KEY, portStr);
             port = configuration.getAsPort(CALL_HOME_PORT_KEY);
             LOG.info("Setting port for call home server to {}", portStr);
-        } catch(Configuration.ConfigurationException e) {
+        } catch (Configuration.ConfigurationException e) {
             LOG.error("Problem trying to set port for call home server {}", portStr, e);
         }
     }
@@ -102,8 +102,9 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
         CallHomeAuthorizationProvider provider = this.getCallHomeAuthorization();
         NetconfCallHomeServerBuilder builder = new NetconfCallHomeServerBuilder(
                 provider, mountDispacher, statusReporter);
-        if (port > 0)
+        if (port > 0) {
             builder.setBindAddress(new InetSocketAddress(port));
+        }
         server = builder.build();
         server.bind();
         mountDispacher.createTopology();
@@ -112,8 +113,10 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
 
     @VisibleForTesting
     void assertValid(Object obj, String description) {
-        if (obj == null)
-            throw new RuntimeException(String.format("Failed to find %s in IetfZeroTouchCallHomeProvider.initialize()", description));
+        if (obj == null) {
+            throw new RuntimeException(
+                String.format("Failed to find %s in IetfZeroTouchCallHomeProvider.initialize()", description));
+        }
     }
 
     @Override
@@ -144,8 +147,9 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
         CheckedFuture<Optional<AllowedDevices>, ReadFailedException> devicesFuture =
                 roConfigTx.read(LogicalDatastoreType.CONFIGURATION, IetfZeroTouchCallHomeServerProvider.ALL_DEVICES);
 
-        if (hasDeletedDevices(change))
+        if (hasDeletedDevices(change)) {
             handleDeletedDevices(change);
+        }
 
         try {
             for (Device confDevice : getReadDevices(devicesFuture)) {
@@ -175,8 +179,9 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
             opTx.delete(LogicalDatastoreType.OPERATIONAL, removedIID);
         }
 
-        if (numRemoved > 0)
+        if (numRemoved > 0) {
             opTx.submit();
+        }
     }
 
     private List<Device> getReadDevices(CheckedFuture<Optional<AllowedDevices>, ReadFailedException> devicesFuture)
@@ -200,7 +205,8 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataC
                 .child(Device.class, new DeviceKey(cfgDevice.getUniqueId()));
 
         ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
-        CheckedFuture<Optional<Device>, ReadFailedException> deviceFuture = tx.read(LogicalDatastoreType.OPERATIONAL, deviceIID);
+        CheckedFuture<Optional<Device>, ReadFailedException> deviceFuture = tx.read(
+            LogicalDatastoreType.OPERATIONAL, deviceIID);
 
         Optional<Device> opDevGet = deviceFuture.checkedGet();
         Device1 devStatus = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.DISCONNECTED).build();
index d97360476ee12d7dc746e53c2c0b6650699eafa3..201c206282143538a087595ab9603a336ace62e4 100755 (executable)
@@ -46,5 +46,4 @@
         <argument ref="domMountPointService"/>
     </bean>
 
-
 </blueprint>
\ No newline at end of file
index cca8f5de3d56e1352e776333433abacaa518a526..1b822413a55c5809679d0b53844f9ae2c18c63c1 100644 (file)
@@ -73,6 +73,7 @@ public class CallHomeMountDispatcherTest {
             public CallHomeMountSessionManager getSessionManager() {
                 return mockSessMgr;
             }
+
             @Override
             void createTopology() {
                 this.topology = mockTopology;
index 1551181eed89477cbaa37727aa68db792ff736be..687071526101ead9343a4ff4b871a0e93eaa23e5 100644 (file)
@@ -28,7 +28,6 @@ import org.opendaylight.netconf.callhome.protocol.CallHomeProtocolSessionContext
 import org.opendaylight.netconf.client.NetconfClientSession;
 import org.opendaylight.netconf.client.NetconfClientSessionListener;
 
-
 public class CallHomeMountSessionContextTest {
     private Inet4Address someAddressIpv4;
     private InetSocketAddress someSocketAddress;
@@ -59,13 +58,13 @@ public class CallHomeMountSessionContextTest {
     public void activationOfListenerSupportsSessionUp() {
         // given
         when(mockActivator.activate(any(NetconfClientSessionListener.class)))
-                .thenAnswer(invocationOnMock -> {
-                        NetconfClientSession mockSession = mock(NetconfClientSession.class);
+            .thenAnswer(invocationOnMock -> {
+                NetconfClientSession mockSession = mock(NetconfClientSession.class);
 
-                        Object arg = invocationOnMock.getArguments()[0];
-                        ((NetconfClientSessionListener) arg).onSessionUp(mockSession);
-                        return null;
-                    });
+                Object arg = invocationOnMock.getArguments()[0];
+                ((NetconfClientSessionListener) arg).onSessionUp(mockSession);
+                return null;
+            });
 
         NetconfClientSessionListener mockListener = mock(NetconfClientSessionListener.class);
         // when
@@ -79,13 +78,13 @@ public class CallHomeMountSessionContextTest {
         // given
         when(mockActivator.activate(any(NetconfClientSessionListener.class)))
                 .thenAnswer(invocationOnMock -> {
-                        NetconfClientSession mockSession = mock(NetconfClientSession.class);
-                        NetconfTerminationReason mockReason = mock(NetconfTerminationReason.class);
+                    NetconfClientSession mockSession = mock(NetconfClientSession.class);
+                    NetconfTerminationReason mockReason = mock(NetconfTerminationReason.class);
 
-                        Object arg = invocationOnMock.getArguments()[0];
-                        ((NetconfClientSessionListener) arg).onSessionTerminated(mockSession, mockReason);
-                        return null;
-                    });
+                    Object arg = invocationOnMock.getArguments()[0];
+                    ((NetconfClientSessionListener) arg).onSessionTerminated(mockSession, mockReason);
+                    return null;
+                });
 
         NetconfClientSessionListener mockListener = mock(NetconfClientSessionListener.class);
         // when
@@ -100,13 +99,13 @@ public class CallHomeMountSessionContextTest {
         // given
         when(mockActivator.activate(any(NetconfClientSessionListener.class)))
                 .thenAnswer(invocationOnMock -> {
-                        NetconfClientSession mockSession = mock(NetconfClientSession.class);
-                        Exception mockException = mock(Exception.class);
+                    NetconfClientSession mockSession = mock(NetconfClientSession.class);
+                    Exception mockException = mock(Exception.class);
 
-                        Object arg = invocationOnMock.getArguments()[0];
-                        ((NetconfClientSessionListener) arg).onSessionDown(mockSession, mockException);
-                        return null;
-                    });
+                    Object arg = invocationOnMock.getArguments()[0];
+                    ((NetconfClientSessionListener) arg).onSessionDown(mockSession, mockException);
+                    return null;
+                });
         // given
         NetconfClientSessionListener mockListener = mock(NetconfClientSessionListener.class);
         // when
@@ -121,13 +120,13 @@ public class CallHomeMountSessionContextTest {
         // given
         when(mockActivator.activate(any(NetconfClientSessionListener.class)))
                 .thenAnswer(invocationOnMock -> {
-                        NetconfClientSession mockSession = mock(NetconfClientSession.class);
-                        NetconfMessage mockMsg = mock(NetconfMessage.class);
+                    NetconfClientSession mockSession = mock(NetconfClientSession.class);
+                    NetconfMessage mockMsg = mock(NetconfMessage.class);
 
-                        Object arg = invocationOnMock.getArguments()[0];
-                        ((NetconfClientSessionListener) arg).onMessage(mockSession, mockMsg);
-                        return null;
-                    });
+                    Object arg = invocationOnMock.getArguments()[0];
+                    ((NetconfClientSessionListener) arg).onMessage(mockSession, mockMsg);
+                    return null;
+                });
         // given
         NetconfClientSessionListener mockListener = mock(NetconfClientSessionListener.class);
         // when
index eb65226b5271a84cec58c86c964e591477800e97..cdb0462d8f95ef0a0acd704ba87d12ac680acb75 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.netconf.callhome.mount;
 
-
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
@@ -29,7 +28,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
 
-
 public class ContextKeyTest {
     private IpAddress address1;
     private IpAddress address2;