X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=certServicePostProcessor%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Foom%2Fcertservice%2Fpostprocessor%2Fconfiguration%2Fpath%2FDelimitedPathsSplitterTest.java;h=c546604ce89a39d195f6c1ef65267ae3fe151f61;hb=e3283b7f953eca13ae68933b6d7b8cceb237acc4;hp=be1bc394c26d53afa0b3d3c3f0b4e572f012d438;hpb=74b84fad712d2225c31ce0a3347233d968db4981;p=oom%2Fplatform%2Fcert-service.git diff --git a/certServicePostProcessor/src/test/java/org/onap/oom/certservice/postprocessor/configuration/path/DelimitedPathsSplitterTest.java b/certServicePostProcessor/src/test/java/org/onap/oom/certservice/postprocessor/configuration/path/DelimitedPathsSplitterTest.java index be1bc394..c546604c 100644 --- a/certServicePostProcessor/src/test/java/org/onap/oom/certservice/postprocessor/configuration/path/DelimitedPathsSplitterTest.java +++ b/certServicePostProcessor/src/test/java/org/onap/oom/certservice/postprocessor/configuration/path/DelimitedPathsSplitterTest.java @@ -1,7 +1,7 @@ /*============LICENSE_START======================================================= * oom-truststore-merger * ================================================================================ - * Copyright (C) 2020 Nokia. All rights reserved. + * Copyright (C) 2020-2021 Nokia. 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. @@ -30,6 +30,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; import org.onap.oom.certservice.postprocessor.configuration.exception.CertificatesPathsValidationException; +import org.onap.oom.certservice.postprocessor.configuration.model.EnvVariable; @ExtendWith(MockitoExtension.class) class DelimitedPathsSplitterTest { @@ -58,16 +59,13 @@ class DelimitedPathsSplitterTest { @Test void shouldThrowExceptionWhenTruststoresPathsEnvIsEmpty() { // when, then - assertThatExceptionOfType(CertificatesPathsValidationException.class) - .isThrownBy(() -> delimitedPathsSplitter.getValidatedPaths(TRUSTSTORES_PATHS, Optional.of(""))); + assertCorrectExceptionIsThrownFor(TRUSTSTORES_PATHS, ""); } @Test void shouldThrowExceptionWhenOneOfTruststoresPathsInvalid() { // when, then - assertThatExceptionOfType(CertificatesPathsValidationException.class) - .isThrownBy(() -> delimitedPathsSplitter - .getValidatedPaths(TRUSTSTORES_PATHS, Optional.of(INVALID_TRUSTSTORES))); + assertCorrectExceptionIsThrownFor(TRUSTSTORES_PATHS, INVALID_TRUSTSTORES); } @Test @@ -92,16 +90,19 @@ class DelimitedPathsSplitterTest { @Test void shouldThrowExceptionWhenTruststoresPasswordsPathEnvIsEmpty() { // when, then - assertThatExceptionOfType(CertificatesPathsValidationException.class) - .isThrownBy( - () -> delimitedPathsSplitter.getValidatedPaths(TRUSTSTORES_PASSWORDS_PATHS, Optional.of(""))); + assertCorrectExceptionIsThrownFor(TRUSTSTORES_PASSWORDS_PATHS, ""); } @Test void shouldThrowExceptionWhenOneOfTruststorePasswordPathsInvalid() { // when, then + assertCorrectExceptionIsThrownFor(TRUSTSTORES_PASSWORDS_PATHS, INVALID_TRUSTSTORES_PASSWORDS); + } + + private void assertCorrectExceptionIsThrownFor(EnvVariable envVariable, String envValue) { + final Optional envValueOptional = Optional.of(envValue); assertThatExceptionOfType(CertificatesPathsValidationException.class) .isThrownBy(() -> delimitedPathsSplitter - .getValidatedPaths(TRUSTSTORES_PASSWORDS_PATHS, Optional.of(INVALID_TRUSTSTORES_PASSWORDS))); + .getValidatedPaths(envVariable, envValueOptional)); } }