diff --git a/calm-hub/src/test/java/org/finos/calm/resources/TestArchitectureResourceShould.java b/calm-hub/src/test/java/org/finos/calm/resources/TestArchitectureResourceShould.java index 4e13e65a..b2428482 100644 --- a/calm-hub/src/test/java/org/finos/calm/resources/TestArchitectureResourceShould.java +++ b/calm-hub/src/test/java/org/finos/calm/resources/TestArchitectureResourceShould.java @@ -34,7 +34,7 @@ public class TestArchitectureResourceShould { @Test void return_a_404_when_an_invalid_namespace_is_provided_on_get_architectures() throws NamespaceNotFoundException { - when(mockArchitectureStore.getArchitecturesForNamespace(anyString())).thenThrow(NamespaceNotFoundException.class); + when(mockArchitectureStore.getArchitecturesForNamespace(anyString())).thenThrow(new NamespaceNotFoundException()); given() .when() @@ -62,7 +62,7 @@ void return_list_of_architecture_ids_when_valid_namespace_provided_on_get_archit @Test void return_a_404_when_invalid_namespace_is_provided_on_create_architecture() throws NamespaceNotFoundException { when(mockArchitectureStore.createArchitectureForNamespace(any(Architecture.class))) - .thenThrow(NamespaceNotFoundException.class); + .thenThrow(new NamespaceNotFoundException()); String architecture = "{ \"test\": \"json\" }"; @@ -127,15 +127,15 @@ private void verifyExpectedArchitectureForVersions(String namespace) throws Name static Stream provideParametersForArchitectureVersionTests() { return Stream.of( - Arguments.of("invalid", NamespaceNotFoundException.class, 404), - Arguments.of("valid", ArchitectureNotFoundException.class, 404), + Arguments.of("invalid", new NamespaceNotFoundException(), 404), + Arguments.of("valid", new ArchitectureNotFoundException(), 404), Arguments.of("valid", null, 200) ); } @ParameterizedTest @MethodSource("provideParametersForArchitectureVersionTests") - void respond_correctly_to_get_architecture_versions_query(String namespace, Class exceptionToThrow, int expectedStatusCode) throws ArchitectureNotFoundException, NamespaceNotFoundException { + void respond_correctly_to_get_architecture_versions_query(String namespace, Throwable exceptionToThrow, int expectedStatusCode) throws ArchitectureNotFoundException, NamespaceNotFoundException { var versions = List.of("1.0.0", "1.0.1"); if (exceptionToThrow != null) { when(mockArchitectureStore.getArchitectureVersions(any(Architecture.class))).thenThrow(exceptionToThrow); @@ -174,16 +174,16 @@ private void verifyExpectedGetArchitecture(String namespace) throws Architecture static Stream provideParametersForGetArchitectureTests() { return Stream.of( - Arguments.of("invalid", NamespaceNotFoundException.class, 404), - Arguments.of("valid", ArchitectureNotFoundException.class, 404), - Arguments.of("valid", ArchitectureVersionNotFoundException.class, 404), + Arguments.of("invalid", new NamespaceNotFoundException(), 404), + Arguments.of("valid", new ArchitectureNotFoundException(), 404), + Arguments.of("valid", new ArchitectureVersionNotFoundException(), 404), Arguments.of("valid", null, 200) ); } @ParameterizedTest @MethodSource("provideParametersForGetArchitectureTests") - void respond_correctly_to_get_architecture_for_a_specific_version_correctly(String namespace, Class exceptionToThrow, int expectedStatusCode) throws ArchitectureVersionNotFoundException, ArchitectureNotFoundException, NamespaceNotFoundException { + void respond_correctly_to_get_architecture_for_a_specific_version_correctly(String namespace, Throwable exceptionToThrow, int expectedStatusCode) throws ArchitectureVersionNotFoundException, ArchitectureNotFoundException, NamespaceNotFoundException { if (exceptionToThrow != null) { when(mockArchitectureStore.getArchitectureForVersion(any(Architecture.class))).thenThrow(exceptionToThrow); } else { @@ -211,16 +211,16 @@ void respond_correctly_to_get_architecture_for_a_specific_version_correctly(Stri static Stream provideParametersForCreateArchitectureTests() { return Stream.of( - Arguments.of( NamespaceNotFoundException.class, 404), - Arguments.of( ArchitectureNotFoundException.class, 404), - Arguments.of(ArchitectureVersionExistsException.class, 409), + Arguments.of( new NamespaceNotFoundException(), 404), + Arguments.of( new ArchitectureNotFoundException(), 404), + Arguments.of(new ArchitectureVersionExistsException(), 409), Arguments.of(null, 201) ); } @ParameterizedTest @MethodSource("provideParametersForCreateArchitectureTests") - void respond_correctly_to_create_architecture(Class exceptionToThrow, int expectedStatusCode) throws ArchitectureNotFoundException, ArchitectureVersionExistsException, NamespaceNotFoundException { + void respond_correctly_to_create_architecture(Throwable exceptionToThrow, int expectedStatusCode) throws ArchitectureNotFoundException, ArchitectureVersionExistsException, NamespaceNotFoundException { Architecture expectedArchitecture = new Architecture.ArchitectureBuilder() .setNamespace("test") .setVersion("1.0.1") diff --git a/calm-hub/src/test/java/org/finos/calm/resources/TestPatternResourcePutEnabledShould.java b/calm-hub/src/test/java/org/finos/calm/resources/TestPatternResourcePutEnabledShould.java index 1881e405..494a2a01 100644 --- a/calm-hub/src/test/java/org/finos/calm/resources/TestPatternResourcePutEnabledShould.java +++ b/calm-hub/src/test/java/org/finos/calm/resources/TestPatternResourcePutEnabledShould.java @@ -23,7 +23,6 @@ @QuarkusTest @ExtendWith(MockitoExtension.class) @TestProfile(AllowPutProfile.class) -@Disabled("This test fails due to a multiple injection problem with a conflicting mock in TestPatternResourceShould, will need to find a fix. (the tests do pass)") public class TestPatternResourcePutEnabledShould { @InjectMock @@ -31,15 +30,15 @@ public class TestPatternResourcePutEnabledShould { static Stream provideParametersForPutPatternTests() { return Stream.of( - Arguments.of( NamespaceNotFoundException.class, 404), - Arguments.of( PatternNotFoundException.class, 404), + Arguments.of( new NamespaceNotFoundException(), 404), + Arguments.of( new PatternNotFoundException(), 404), Arguments.of(null, 201) ); } @ParameterizedTest @MethodSource("provideParametersForPutPatternTests") - void respond_correctly_to_put_pattern_correctly(Class exceptionToThrow, int expectedStatusCode) throws PatternNotFoundException, NamespaceNotFoundException { + void respond_correctly_to_put_pattern_correctly(Throwable exceptionToThrow, int expectedStatusCode) throws PatternNotFoundException, NamespaceNotFoundException { Pattern expectedPattern = new Pattern.PatternBuilder() .setNamespace("test") diff --git a/calm-hub/src/test/java/org/finos/calm/resources/TestPatternResourceShould.java b/calm-hub/src/test/java/org/finos/calm/resources/TestPatternResourceShould.java index 190343dd..4cfa0527 100644 --- a/calm-hub/src/test/java/org/finos/calm/resources/TestPatternResourceShould.java +++ b/calm-hub/src/test/java/org/finos/calm/resources/TestPatternResourceShould.java @@ -34,7 +34,7 @@ public class TestPatternResourceShould { @Test void return_a_404_when_an_invalid_namespace_is_provided_on_get_patterns() throws NamespaceNotFoundException { - when(mockPatternStore.getPatternsForNamespace(anyString())).thenThrow(NamespaceNotFoundException.class); + when(mockPatternStore.getPatternsForNamespace(anyString())).thenThrow(new NamespaceNotFoundException()); given() .when() @@ -62,7 +62,7 @@ void return_list_of_pattern_ids_when_valid_namespace_provided_on_get_patterns() @Test void return_a_404_when_invalid_namespace_is_provided_on_create_pattern() throws NamespaceNotFoundException { when(mockPatternStore.createPatternForNamespace(any(Pattern.class))) - .thenThrow(NamespaceNotFoundException.class); + .thenThrow(new NamespaceNotFoundException()); String pattern = "{ \"test\": \"json\" }"; @@ -127,15 +127,15 @@ private void verifyExpectedPatternForVersions(String namespace) throws PatternNo static Stream provideParametersForPatternVersionTests() { return Stream.of( - Arguments.of("invalid", NamespaceNotFoundException.class, 404), - Arguments.of("valid", PatternNotFoundException.class, 404), + Arguments.of("invalid", new NamespaceNotFoundException(), 404), + Arguments.of("valid", new PatternNotFoundException(), 404), Arguments.of("valid", null, 200) ); } @ParameterizedTest @MethodSource("provideParametersForPatternVersionTests") - void respond_correctly_to_get_pattern_versions_query(String namespace, Class exceptionToThrow, int expectedStatusCode) throws PatternNotFoundException, NamespaceNotFoundException { + void respond_correctly_to_get_pattern_versions_query(String namespace, Throwable exceptionToThrow, int expectedStatusCode) throws PatternNotFoundException, NamespaceNotFoundException { var versions = List.of("1.0.0", "1.0.1"); if (exceptionToThrow != null) { when(mockPatternStore.getPatternVersions(any(Pattern.class))).thenThrow(exceptionToThrow); @@ -174,16 +174,16 @@ private void verifyExpectedGetPattern(String namespace) throws PatternNotFoundEx static Stream provideParametersForGetPatternTests() { return Stream.of( - Arguments.of("invalid", NamespaceNotFoundException.class, 404), - Arguments.of("valid", PatternNotFoundException.class, 404), - Arguments.of("valid", PatternVersionNotFoundException.class, 404), + Arguments.of("invalid", new NamespaceNotFoundException(), 404), + Arguments.of("valid", new PatternNotFoundException(), 404), + Arguments.of("valid", new PatternVersionNotFoundException(), 404), Arguments.of("valid", null, 200) ); } @ParameterizedTest @MethodSource("provideParametersForGetPatternTests") - void respond_correct_to_get_pattern_for_a_specific_version_correctly(String namespace, Class exceptionToThrow, int expectedStatusCode) throws PatternNotFoundException, NamespaceNotFoundException, PatternVersionNotFoundException { + void respond_correct_to_get_pattern_for_a_specific_version_correctly(String namespace, Throwable exceptionToThrow, int expectedStatusCode) throws PatternNotFoundException, NamespaceNotFoundException, PatternVersionNotFoundException { if (exceptionToThrow != null) { when(mockPatternStore.getPatternForVersion(any(Pattern.class))).thenThrow(exceptionToThrow); } else { @@ -211,16 +211,16 @@ void respond_correct_to_get_pattern_for_a_specific_version_correctly(String name static Stream provideParametersForCreatePatternTests() { return Stream.of( - Arguments.of( NamespaceNotFoundException.class, 404), - Arguments.of( PatternNotFoundException.class, 404), - Arguments.of(PatternVersionExistsException.class, 409), + Arguments.of( new NamespaceNotFoundException(), 404), + Arguments.of( new PatternNotFoundException(), 404), + Arguments.of(new PatternVersionExistsException(), 409), Arguments.of(null, 201) ); } @ParameterizedTest @MethodSource("provideParametersForCreatePatternTests") - void respond_correctly_to_create_pattern_correctly(Class exceptionToThrow, int expectedStatusCode) throws PatternNotFoundException, PatternVersionExistsException, NamespaceNotFoundException { + void respond_correctly_to_create_pattern_correctly(Throwable exceptionToThrow, int expectedStatusCode) throws PatternNotFoundException, PatternVersionExistsException, NamespaceNotFoundException { Pattern expectedPattern = new Pattern.PatternBuilder() .setNamespace("test") .setVersion("1.0.1")