From 3e1e809c3fe6cf334ece0e645496a281c3d505f9 Mon Sep 17 00:00:00 2001 From: Scott Leberknight <174812+sleberknight@users.noreply.github.com> Date: Fri, 20 Oct 2023 20:01:31 +0000 Subject: [PATCH] Add more tests for ErrorContextBuilder --- .../error/ErrorContextBuilderTest.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/test/java/org/kiwiproject/dropwizard/error/ErrorContextBuilderTest.java b/src/test/java/org/kiwiproject/dropwizard/error/ErrorContextBuilderTest.java index 577a143..560aa63 100644 --- a/src/test/java/org/kiwiproject/dropwizard/error/ErrorContextBuilderTest.java +++ b/src/test/java/org/kiwiproject/dropwizard/error/ErrorContextBuilderTest.java @@ -201,6 +201,42 @@ void shouldAllowSkippingCleanupJobRegistration() { } } + @Nested + class Resources { + + @Test + void shouldRegisterResourcesByDefault() { + var builder = ErrorContextBuilder.newInstance() + .environment(environment) + .serviceDetails(serviceDetails) + .dataStoreType(DataStoreType.NOT_SHARED); + + builder.buildWithConcurrentMapDao(); + + var jersey = environment.jersey(); + verify(jersey).register(isA(ApplicationErrorResource.class)); + verify(jersey).register(isA(GotErrorsResource.class)); + verifyNoMoreInteractions(jersey); + } + + @Test + void shouldAllowSkippingResourceRegistration() { + var builder = ErrorContextBuilder.newInstance() + .environment(environment) + .serviceDetails(serviceDetails) + .dataStoreType(DataStoreType.NOT_SHARED) + .skipErrorsResource() + .skipGotErrorsResource(); + + builder.buildWithConcurrentMapDao(); + + var jersey = environment.jersey(); + verify(jersey, never()).register(isA(ApplicationErrorResource.class)); + verify(jersey, never()).register(isA(GotErrorsResource.class)); + verifyNoMoreInteractions(jersey); + } + } + @Nested class RecentApplicationErrorsHealthCheck {