Hide NetconfTopologyRPCProvider.encryptPassword() 62/94262/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 16 Dec 2020 23:39:22 +0000 (00:39 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 16 Dec 2020 23:43:10 +0000 (00:43 +0100)
This method is exposed for testing, move its correspoding test
to the same package, reducing the method's visibility.

Change-Id: I1bdb2d893e8343e16e96797c95e59f27e43aa7bb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/util/NetconfTopologyRPCProvider.java
netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/util/NetconfTopologyRPCProviderTest.java [moved from netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfTopologyRPCProviderTest.java with 88% similarity]

index b7a1489ae901485fba9b12ee5f3596c0de35493c..cd188e1dbd1728c47f19d23a70c516e86c058e47 100644 (file)
@@ -64,7 +64,7 @@ public class NetconfTopologyRPCProvider implements NetconfNodeTopologyService {
 
     @Override
     public ListenableFuture<RpcResult<CreateDeviceOutput>> createDevice(final CreateDeviceInput input) {
-        final NetconfNode node = this.encryptPassword(input);
+        final NetconfNode node = encryptPassword(input);
         final SettableFuture<RpcResult<CreateDeviceOutput>> futureResult = SettableFuture.create();
         final NodeId nodeId = new NodeId(input.getNodeId());
         writeToConfigDS(node, nodeId, futureResult);
@@ -72,14 +72,12 @@ public class NetconfTopologyRPCProvider implements NetconfNodeTopologyService {
     }
 
     @VisibleForTesting
-    public NetconfNode encryptPassword(final CreateDeviceInput input) {
+    NetconfNode encryptPassword(final CreateDeviceInput input) {
         final NetconfNodeBuilder builder = new NetconfNodeBuilder();
         builder.fieldsFrom(input);
 
-        final Credentials credentials = handleEncryption(input.getCredentials());
-        builder.setCredentials(credentials);
-
-        return builder.build();
+        return builder.setCredentials(handleEncryption(input.getCredentials()))
+            .build();
     }
 
     private Credentials handleEncryption(final Credentials credentials) {
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.netconf.sal.connect.netconf.util;
+package org.opendaylight.netconf.sal.connect.util;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -18,7 +18,6 @@ import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.aaa.encrypt.AAAEncryptionService;
 import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.netconf.sal.connect.util.NetconfTopologyRPCProvider;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
@@ -49,7 +48,7 @@ public class NetconfTopologyRPCProviderTest {
     @Mock
     private AAAEncryptionService encryptionService;
 
-    private NetconfTopologyRPCProvider rpcProvider ;
+    private NetconfTopologyRPCProvider rpcProvider;
 
     @Before
     public void setUp() {
@@ -58,7 +57,7 @@ public class NetconfTopologyRPCProviderTest {
     }
 
     @Test
-    public void testEncryptPassword() throws Exception {
+    public void testEncryptPassword() {
 
         final NetconfNode encryptedPwNode = rpcProvider.encryptPassword(getInput(true));
 
@@ -70,7 +69,7 @@ public class NetconfTopologyRPCProviderTest {
     }
 
     @Test
-    public void testNoEncryption() throws Exception {
+    public void testNoEncryption() {
         final NetconfNode encryptedPwNode = rpcProvider.encryptPassword(getInput(false));
 
         final Credentials credentials = encryptedPwNode.getCredentials();
@@ -91,12 +90,13 @@ public class NetconfTopologyRPCProviderTest {
                     new LoginPasswordUnencryptedBuilder().setUsername("test").setPassword(TEST_PWD).build()).build();
         }
 
-        builder.setCredentials(credentials);
-        builder.setHost(new Host(new IpAddress(new Ipv4Address("10.18.16.188"))));
-        builder.setPort(new PortNumber(Uint16.valueOf(830)));
-        builder.setTcpOnly(Boolean.FALSE);
-        builder.setNodeId(NODE_ID.toString());
-        return builder.build();
+        return builder
+            .setCredentials(credentials)
+            .setHost(new Host(new IpAddress(new Ipv4Address("10.18.16.188"))))
+            .setPort(new PortNumber(Uint16.valueOf(830)))
+            .setTcpOnly(Boolean.FALSE)
+            // FIXME: do we really want 'toString()' here?
+            .setNodeId(NODE_ID.toString())
+            .build();
     }
-
 }