diff options
author | 2021-07-13 15:52:23 +0200 | |
---|---|---|
committer | 2021-07-13 15:52:23 +0200 | |
commit | 7949b1a9d135263c0ffcdeae80131a83ca8cf63c (patch) | |
tree | e11f0c93b1931c9f589e5c264c54febd613a34a1 /certService/src/test/java/org/onap | |
parent | 78b60d22b8779d1fbf3e27287b9774862f71404b (diff) |
[OOM-CERT-SERVICE] Fix sonar and checkstyle issues, code cleanup
Issue-ID: OOM-2753
Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com>
Change-Id: Id88b6b2bceba7258745e4ce999dd375fb9ce438f
Diffstat (limited to 'certService/src/test/java/org/onap')
6 files changed, 23 insertions, 23 deletions
diff --git a/certService/src/test/java/org/onap/oom/certservice/api/CertificationControllerTest.java b/certService/src/test/java/org/onap/oom/certservice/api/CertificationControllerTest.java index 81c2d39a..d3738747 100644 --- a/certService/src/test/java/org/onap/oom/certservice/api/CertificationControllerTest.java +++ b/certService/src/test/java/org/onap/oom/certservice/api/CertificationControllerTest.java @@ -162,7 +162,7 @@ class CertificationControllerTest { @Test void shouldUpdateEndpointReturnDataAboutCsrBaseOnEncodedParameters() - throws DecryptionException, CmpClientException, CertificateDecryptionException { + throws DecryptionException, CmpClientException { // Given CertificationResponseModel testCertificationResponseModel = new CertificationResponseModel( Arrays.asList("ENTITY_CERT", "INTERMEDIATE_CERT"), @@ -183,7 +183,7 @@ class CertificationControllerTest { @Test void shouldThrowCertificateDecryptionExceptionWhenCreatingPemModelFails() - throws DecryptionException, CertificateDecryptionException, CmpClientException { + throws DecryptionException, CmpClientException { // Given String expectedMessage = "Incorrect certificate, decryption failed"; when(certificationResponseModelFactory.provideCertificationModelFromUpdateRequest(TEST_CERTIFICATE_UPDATE_MODEL)) diff --git a/certService/src/test/java/org/onap/oom/certservice/certification/CertificationProviderTest.java b/certService/src/test/java/org/onap/oom/certservice/certification/CertificationProviderTest.java index 192050dc..042b2aec 100644 --- a/certService/src/test/java/org/onap/oom/certservice/certification/CertificationProviderTest.java +++ b/certService/src/test/java/org/onap/oom/certservice/certification/CertificationProviderTest.java @@ -140,7 +140,7 @@ class CertificationProviderTest { // When when( cmpClient.executeKeyUpdateRequest(any(CsrModel.class), any(Cmpv2Server.class), any(OldCertificateModel.class)) - ).thenReturn(getCMPv2CertificationModel()); + ).thenReturn(getCmpv2CertificationModel()); CertificationResponseModel certificationModel = certificationProvider .executeKeyUpdateRequest(csrModel, server, oldCertificateModel); @@ -162,7 +162,7 @@ class CertificationProviderTest { when( cmpClient.executeInitializationRequest(any(CsrModel.class), any(Cmpv2Server.class)) - ).thenReturn(getCMPv2CertificationModel()); + ).thenReturn(getCmpv2CertificationModel()); CertificationResponseModel certificationModel = certificationProvider .executeInitializationRequest(csrModel, server); @@ -214,7 +214,7 @@ class CertificationProviderTest { return string.replace("\n", "").replace("\r", ""); } - private Cmpv2CertificationModel getCMPv2CertificationModel() throws IOException, CertificateException { + private Cmpv2CertificationModel getCmpv2CertificationModel() throws IOException, CertificateException { List<X509Certificate> certificateChain = getX509CertificateFromPem(TEST_CMPv2_KEYSTORE); List<X509Certificate> trustedCertificates = getX509CertificateFromPem(TEST_CMPv2_TRUSTSTORE); return new Cmpv2CertificationModel(certificateChain, trustedCertificates); diff --git a/certService/src/test/java/org/onap/oom/certservice/certification/CertificationResponseModelFactoryTest.java b/certService/src/test/java/org/onap/oom/certservice/certification/CertificationResponseModelFactoryTest.java index 205513f5..90dc2359 100644 --- a/certService/src/test/java/org/onap/oom/certservice/certification/CertificationResponseModelFactoryTest.java +++ b/certService/src/test/java/org/onap/oom/certservice/certification/CertificationResponseModelFactoryTest.java @@ -204,7 +204,7 @@ class CertificationResponseModelFactoryTest { @Test void shouldPerformKurWhenCsrAndOldCertDataMatch() - throws CertificateDecryptionException, DecryptionException, CmpClientException { + throws DecryptionException, CmpClientException { // Given CsrModel csrModel = mockCsrFactoryModelCreation(); Cmpv2Server testServer = mockCmpv2ProviderServerSelection(); @@ -229,7 +229,7 @@ class CertificationResponseModelFactoryTest { @Test void shouldThrowCmpClientExceptionWhenUpdateRequestFailed() - throws DecryptionException, CmpClientException, CertificateDecryptionException { + throws DecryptionException, CmpClientException { // Given String expectedMessage = "Exception occurred while send request to CMPv2 Server"; @@ -254,7 +254,7 @@ class CertificationResponseModelFactoryTest { @Test void shouldPerformCrWhenCsrAndOldCertDataDontMatch() - throws CertificateDecryptionException, DecryptionException, CmpClientException { + throws DecryptionException, CmpClientException { // Given CsrModel csrModel = mockCsrFactoryModelCreation(); Cmpv2Server testServer = mockCmpv2ProviderServerSelection(); diff --git a/certService/src/test/java/org/onap/oom/certservice/certification/TestData.java b/certService/src/test/java/org/onap/oom/certservice/certification/TestData.java index 3c47d866..8a4ba645 100644 --- a/certService/src/test/java/org/onap/oom/certservice/certification/TestData.java +++ b/certService/src/test/java/org/onap/oom/certservice/certification/TestData.java @@ -29,7 +29,7 @@ public final class TestData { public static final String EXPECTED_CERT_SUBJECT = "C=US,ST=California,L=San-Francisco,O=Linux-Foundation,OU=ONAP,CN=onap.org"; public static final String EXPECTED_CERT_SANS = - "SANs: [onap@onap.org, localhost, onap.org, test.onap.org, onap://cluster.local/, " + LOCALHOST_IP_IN_HEX +"]"; + "SANs: [onap@onap.org, localhost, onap.org, test.onap.org, onap://cluster.local/, " + LOCALHOST_IP_IN_HEX + "]"; public static final String TEST_CSR = "-----BEGIN CERTIFICATE REQUEST-----\n" diff --git a/certService/src/test/java/org/onap/oom/certservice/cmpv2client/ClientTestData.java b/certService/src/test/java/org/onap/oom/certservice/cmpv2client/ClientTestData.java index 845361ef..e3896acd 100644 --- a/certService/src/test/java/org/onap/oom/certservice/cmpv2client/ClientTestData.java +++ b/certService/src/test/java/org/onap/oom/certservice/cmpv2client/ClientTestData.java @@ -43,27 +43,27 @@ public final class ClientTestData { private static final OldCertificateModelFactory factory = new OldCertificateModelFactory(new PemStringToCertificateConverter(), new X509CertificateParser()); - static final OldCertificateModel createCorrectOldCertificateModel() throws CertificateDecryptionException { + static OldCertificateModel createCorrectOldCertificateModel() throws CertificateDecryptionException { return createOldCertificateModel(TEST_ENCODED_OLD_CERT, TEST_ENCODED_OLD_PRIVATE_KEY); } - static final OldCertificateModel createOldCertificateModelWithWrongCert() throws CertificateDecryptionException { + static OldCertificateModel createOldCertificateModelWithWrongCert() throws CertificateDecryptionException { return createOldCertificateModel(WRONG_OLD_CERT, TEST_ENCODED_OLD_PRIVATE_KEY); } - static final OldCertificateModel createOldCertificateModelWithWrongPrivateKey() throws CertificateDecryptionException { + static OldCertificateModel createOldCertificateModelWithWrongPrivateKey() throws CertificateDecryptionException { return createOldCertificateModel(TEST_ENCODED_OLD_CERT, WRONG_OLD_PRIVATE_KEY); } - static final OldCertificateModel createOldCertificateModelWithPrivateKeyInPKCS1() throws CertificateDecryptionException { + static OldCertificateModel createOldCertificateModelWithPrivateKeyInPkcs1() throws CertificateDecryptionException { return createOldCertificateModel(TEST_ENCODED_OLD_CERT, TEST_ENCODED_PRIVATE_KEY_IN_PKCS1); } - static final OldCertificateModel createOldCertificateModelWithPrivateKeyInPKCS8() throws CertificateDecryptionException { + static OldCertificateModel createOldCertificateModelWithPrivateKeyInPkcs8() throws CertificateDecryptionException { return createOldCertificateModel(TEST_ENCODED_OLD_CERT, TEST_ENCODED_PRIVATE_KEY_IN_PKCS8); } - private static final OldCertificateModel createOldCertificateModel(String certificate, String privateKey) throws CertificateDecryptionException { + private static OldCertificateModel createOldCertificateModel(String certificate, String privateKey) throws CertificateDecryptionException { StringBase64 base64EncodedCertificate = new StringBase64(certificate); return factory.createCertificateModel(base64EncodedCertificate, privateKey); } diff --git a/certService/src/test/java/org/onap/oom/certservice/cmpv2client/Cmpv2ClientTest.java b/certService/src/test/java/org/onap/oom/certservice/cmpv2client/Cmpv2ClientTest.java index 93dcbb77..23964ea3 100644 --- a/certService/src/test/java/org/onap/oom/certservice/cmpv2client/Cmpv2ClientTest.java +++ b/certService/src/test/java/org/onap/oom/certservice/cmpv2client/Cmpv2ClientTest.java @@ -26,8 +26,8 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; -import static org.onap.oom.certservice.cmpv2client.ClientTestData.createOldCertificateModelWithPrivateKeyInPKCS1; -import static org.onap.oom.certservice.cmpv2client.ClientTestData.createOldCertificateModelWithPrivateKeyInPKCS8; +import static org.onap.oom.certservice.cmpv2client.ClientTestData.createOldCertificateModelWithPrivateKeyInPkcs1; +import static org.onap.oom.certservice.cmpv2client.ClientTestData.createOldCertificateModelWithPrivateKeyInPkcs8; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; @@ -115,7 +115,7 @@ class Cmpv2ClientTest { private static KeyPair keyPair; - private final static Decoder BASE64_DECODER = Base64.getDecoder(); + private static final Decoder BASE64_DECODER = Base64.getDecoder(); @BeforeEach void setUp() @@ -233,7 +233,7 @@ class Cmpv2ClientTest { @Test - void shouldThrowCMPClientExceptionWhenCannotParseOldCertificate() { + void shouldThrowCmpClientExceptionWhenCannotParseOldCertificate() { setCsrModelAndServerTestDefaultValues(); CmpClientImpl cmpClient = new CmpClientImpl(httpClient); @@ -375,7 +375,7 @@ class Cmpv2ClientTest { try ( BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream( - preparePKIMessageWithoutProtectionAlgorithm().getEncoded() + preparePkiMessageWithoutProtectionAlgorithm().getEncoded() ))) { byte[] ba = IOUtils.toByteArray(bis); @@ -473,7 +473,7 @@ class Cmpv2ClientTest { server.setIssuerDN(dn); } - private PKIMessage preparePKIMessageWithoutProtectionAlgorithm() { + private PKIMessage preparePkiMessageWithoutProtectionAlgorithm() { CertTemplateBuilder certTemplateBuilder = new CertTemplateBuilder(); X500Name issuerDN = getTestIssuerDN(); @@ -504,8 +504,8 @@ class Cmpv2ClientTest { private static Stream<Arguments> getTestUpdateModelWithSupportedPrivateKeys() throws CertificateDecryptionException { return Stream.of( - Arguments.of(createOldCertificateModelWithPrivateKeyInPKCS1()), - Arguments.of(createOldCertificateModelWithPrivateKeyInPKCS8()) + Arguments.of(createOldCertificateModelWithPrivateKeyInPkcs1()), + Arguments.of(createOldCertificateModelWithPrivateKeyInPkcs8()) ); } |