From 93c91c2fc80a31585c8f902c86bc4e1faf5b966d Mon Sep 17 00:00:00 2001 From: Vidyashree Rama Date: Tue, 23 Apr 2019 09:29:36 +0530 Subject: Test coverage imporvement and code refactoring of restconf discovery node. Test coverage imporvement and code refactoring of restconf discovery node. Issue-ID: CCSDK-1236 Change-Id: Ic44899d71b92be3d7b88be3abb0feb311e6ad8c0 Signed-off-by: Vidyashree Rama --- .../restconfdiscovery/RestconfDiscoveryNode.java | 48 +++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'restconf-client/provider/src/main') diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java index 5c7d695d..cf69d7a3 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/RestconfDiscoveryNode.java @@ -141,7 +141,7 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { WebTarget target = null; try { RestapiCallNode restapi = restconfApiCallNode.getRestapiCallNode(); - p = restapi.getParameters(paramMap, new Parameters()); + p = RestapiCallNode.getParameters(paramMap, new Parameters()); Client client = ignoreSslClient().register(SseFeature.class); target = restapi.addAuthType(client, p).target(url); } catch (SvcLogicException e) { @@ -166,37 +166,37 @@ public class RestconfDiscoveryNode implements SvcLogicDiscoveryPlugin { eventSource.close(); log.info("Closed connection to SSE source"); } - } - - private Client ignoreSslClient() { - SSLContext sslcontext = null; - try { - sslcontext = SSLContext.getInstance("TLS"); - sslcontext.init(null, new TrustManager[]{new X509TrustManager() { - @Override - public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { - } + private Client ignoreSslClient() { + SSLContext sslcontext = null; - @Override - public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { - } + try { + sslcontext = SSLContext.getInstance("TLS"); + sslcontext.init(null, new TrustManager[]{new X509TrustManager() { + @Override + public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + } }, new java.security.SecureRandom()); + } catch (NoSuchAlgorithmException | KeyManagementException e) { + throw new IllegalStateException(e); + } - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } - } }, new java.security.SecureRandom()); - } catch (NoSuchAlgorithmException | KeyManagementException e) { - throw new IllegalStateException(e); + return ClientBuilder.newBuilder().sslContext(sslcontext).hostnameVerifier((s1, s2) -> true).build(); } - - return ClientBuilder.newBuilder().sslContext(sslcontext).hostnameVerifier((s1, s2) -> true).build(); } protected String getTokenId(String customHttpHeaders) { if (customHttpHeaders.contains("=")) { - String s[] = customHttpHeaders.split("="); + String[] s = customHttpHeaders.split("="); return s[1]; } return customHttpHeaders; -- cgit 1.2.3-korg