From d37c71292d9cbdd892f328d63f49a8027b1f13c4 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Thu, 13 Jun 2019 10:39:55 -0400 Subject: Fix simple sonar issues in models Added @FunctionalInterface where needed. Replaced anonymous classes with lambda expressions. Replaced duplicate strings with a constant. Removed unused BeforeClass & AfterClass test methods. Removed some trailing spaces. Fixed: aai actor.appc actor.appclcm actor.sdnc actor.sdnr actor.so actor.vfc actorServiceProvider appc appclcm cds events Change-Id: I0e21cbb10db6d1217bbd0e00e6dd4fac3eb84e31 Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn --- .../onap/policy/cds/client/BasicAuthClientHeaderInterceptor.java | 7 ++++--- .../java/org/onap/policy/cds/properties/CdsServerProperties.java | 1 - .../policy/cds/client/BasicAuthClientHeaderInterceptorTest.java | 6 +++--- .../org/onap/policy/cds/client/CdsProcessorGrpcClientTest.java | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'models-interactions/model-impl/cds') diff --git a/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/BasicAuthClientHeaderInterceptor.java b/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/BasicAuthClientHeaderInterceptor.java index 3957fe5e4..17eefd227 100644 --- a/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/BasicAuthClientHeaderInterceptor.java +++ b/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/client/BasicAuthClientHeaderInterceptor.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Bell Canada. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,12 +50,12 @@ public class BasicAuthClientHeaderInterceptor implements ClientInterceptor { } @Override - public ClientCall interceptCall(MethodDescriptor method, + public ClientCall interceptCall(MethodDescriptor method, CallOptions callOptions, Channel channel) { Key authHeader = Key.of(BASIC_AUTH_HEADER_KEY, Metadata.ASCII_STRING_MARSHALLER); - return new ForwardingClientCall.SimpleForwardingClientCall(channel.newCall(method, callOptions)) { + return new ForwardingClientCall.SimpleForwardingClientCall(channel.newCall(method, callOptions)) { @Override - public void start(Listener responseListener, Metadata headers) { + public void start(Listener

responseListener, Metadata headers) { headers.put(authHeader, props.getBasicAuth()); super.start(responseListener, headers); } diff --git a/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/properties/CdsServerProperties.java b/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/properties/CdsServerProperties.java index 94a336b6d..2e919814b 100644 --- a/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/properties/CdsServerProperties.java +++ b/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/properties/CdsServerProperties.java @@ -39,7 +39,6 @@ public class CdsServerProperties implements ParameterGroup { private static final int MIN_USER_PORT = 1024; private static final int MAX_USER_PORT = 65535; - private static final String INVALID_PROP = "Invalid CDS property: "; private static final String SERVER_PROPERTIES_TYPE = "CDS gRPC Server Properties"; // CDS carrier properties diff --git a/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/BasicAuthClientHeaderInterceptorTest.java b/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/BasicAuthClientHeaderInterceptorTest.java index 3b6ad7da1..fedf4703c 100644 --- a/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/BasicAuthClientHeaderInterceptorTest.java +++ b/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/BasicAuthClientHeaderInterceptorTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Bell Canada. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -127,9 +128,8 @@ public class BasicAuthClientHeaderInterceptorTest { private static class TestServerInterceptor implements ServerInterceptor { @Override - public Listener interceptCall(final ServerCall serverCall, - final Metadata metadata, - final ServerCallHandler serverCallHandler) { + public Listener interceptCall(final ServerCall serverCall, + final Metadata metadata, final ServerCallHandler serverCallHandler) { return serverCallHandler.startCall(serverCall, metadata); } } diff --git a/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/CdsProcessorGrpcClientTest.java b/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/CdsProcessorGrpcClientTest.java index b9a9a84cd..17b4dc534 100644 --- a/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/CdsProcessorGrpcClientTest.java +++ b/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/CdsProcessorGrpcClientTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Bell Canada. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +20,8 @@ package org.onap.policy.cds.client; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; @@ -128,13 +128,13 @@ public class CdsProcessorGrpcClientTest { @Test public void testCdsProcessorGrpcClientConstructor() { - new CdsProcessorGrpcClient(listener, props); + new CdsProcessorGrpcClient(listener, props).close(); } @Test(expected = IllegalStateException.class) public void testCdsProcessorGrpcClientConstructorFailure() { props.setHost(null); - new CdsProcessorGrpcClient(listener, props); + new CdsProcessorGrpcClient(listener, props).close(); } @Test -- cgit 1.2.3-korg