diff options
Diffstat (limited to 'certService/src/test/java/org/onap/aaf/certservice/certification/PemObjectFactoryTest.java')
-rw-r--r-- | certService/src/test/java/org/onap/aaf/certservice/certification/PemObjectFactoryTest.java | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/PemObjectFactoryTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/PemObjectFactoryTest.java index 479c375b..0b70475c 100644 --- a/certService/src/test/java/org/onap/aaf/certservice/certification/PemObjectFactoryTest.java +++ b/certService/src/test/java/org/onap/aaf/certservice/certification/PemObjectFactoryTest.java @@ -23,8 +23,8 @@ package org.onap.aaf.certservice.certification; import org.bouncycastle.util.io.pem.PemObject; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.aaf.certservice.certification.exceptions.CsrDecryptionException; -import org.onap.aaf.certservice.certification.exceptions.PemDecryptionException; +import org.onap.aaf.certservice.certification.exceptions.DecryptionException; +import org.onap.aaf.certservice.certification.exceptions.KeyDecryptionException; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -45,9 +45,11 @@ class PemObjectFactoryTest { } @Test - void shouldTransformStringInToPemObjectAndBackToString() throws PemDecryptionException { + void shouldTransformStringInToPemObjectAndBackToString() throws DecryptionException { // when - PemObject pemObject = pemObjectFactory.createPemObject(TEST_PEM); + PemObject pemObject = pemObjectFactory.createPemObject(TEST_PEM).orElseThrow( + () -> new DecryptionException("Pem decryption failed") + ); String parsedPemObject = pemObjectToString(pemObject); // then @@ -56,12 +58,16 @@ class PemObjectFactoryTest { @Test void shouldThrowExceptionWhenParsingPemFailed() { + // given + String expectedMessage = "Unable to create PEM"; + // when Exception exception = assertThrows( - PemDecryptionException.class, () -> pemObjectFactory.createPemObject(TEST_WRONG_PEM) + DecryptionException.class, () -> pemObjectFactory.createPemObject(TEST_WRONG_PEM).orElseThrow( + () -> new DecryptionException(expectedMessage) + ) ); - String expectedMessage = "Unable to create PEM"; String actualMessage = exception.getMessage(); // then |