66import org .junit .jupiter .api .Test ;
77import org .mockito .Mockito ;
88import org .springframework .boot .autoconfigure .AutoConfigurations ;
9+ import org .springframework .boot .restclient .autoconfigure .RestClientSsl ;
910import org .springframework .boot .test .context .assertj .AssertableApplicationContext ;
1011import org .springframework .boot .test .context .assertj .AssertableWebApplicationContext ;
1112import org .springframework .boot .test .context .runner .ApplicationContextRunner ;
@@ -33,23 +34,27 @@ class JerseyAutoConfigurationTest {
3334 * This class provides mock versions of beans that would normally be provided by Spring Boot in a real application. We
3435 * only need to mock out the RestClient.Builder and RestClientSsl beans because those are the only Spring Boot provided
3536 * beans that our AutoConfigurations depend on.
37+ *
38+ * In theory, we should not need to provide these however spring-boot-starter-jersey brings in spring-boot-restclient
39+ * on to the test classpath which, in turn, triggers the inclusion of the fluent-forms springRestClientFactory which
40+ * requires the mocks.
3641 */
3742 private static class SpringBootMocks {
3843 @ Bean RestClient .Builder mockRestClientBuilder () { return Mockito .mock (RestClient .Builder .class , Mockito .RETURNS_DEEP_STUBS ); }
39- // @Bean private RestClientSsl mockRestClientSsl() { return Mockito.mock(RestClientSsl.class); }
44+ @ Bean private RestClientSsl mockRestClientSsl () { return Mockito .mock (RestClientSsl .class ); }
4045 }
4146
42- private static final AutoConfigurations AUTO_CONFIG = AutoConfigurations .of (FluentFormsJerseyAutoConfiguration .class , AemProxyJerseyAutoConfiguration .class , FluentFormsAutoConfiguration .class , AemProxyAutoConfiguration . class , SpringBootMocks .class );
47+ private static final AutoConfigurations AUTO_CONFIG = AutoConfigurations .of (FluentFormsJerseyAutoConfiguration .class , AemProxyJerseyAutoConfiguration .class , FluentFormsAutoConfiguration .class , SpringBootMocks .class );
4348
44- private static final AutoConfigurations LOCAL_SUBMIT_CONFIG = AutoConfigurations .of (FluentFormsJerseyAutoConfiguration .class , AemProxyJerseyAutoConfiguration .class , FluentFormsAutoConfiguration .class , AemProxyAutoConfiguration . class , DummyLocalSubmitHandler .class , SpringBootMocks .class );
49+ private static final AutoConfigurations LOCAL_SUBMIT_CONFIG = AutoConfigurations .of (FluentFormsJerseyAutoConfiguration .class , AemProxyJerseyAutoConfiguration .class , FluentFormsAutoConfiguration .class , DummyLocalSubmitHandler .class , SpringBootMocks .class );
4550
46- private static final AutoConfigurations ALTERNATE_PROXY_CONFIG = AutoConfigurations .of (DummyProxyImplementation .class , FluentFormsJerseyAutoConfiguration .class , AemProxyJerseyAutoConfiguration .class , FluentFormsAutoConfiguration .class , AemProxyAutoConfiguration . class , SpringBootMocks .class );
51+ private static final AutoConfigurations ALTERNATE_PROXY_CONFIG = AutoConfigurations .of (DummyProxyImplementation .class , FluentFormsJerseyAutoConfiguration .class , AemProxyJerseyAutoConfiguration .class , FluentFormsAutoConfiguration .class , SpringBootMocks .class );
4752
4853 // Tests to make sure that only the FluentFormsLibraries are loaded in a non-web application.
4954 private static final ContextConsumer <? super AssertableApplicationContext > FF_LIBRARIES_ONLY = (context ) -> {
5055 assertAll (
51- ()->assertThat (context ).hasSingleBean (FluentFormsAutoConfiguration .class ),
52- ()->assertThat (context ).getBean (FluentFormsAutoConfiguration .class .getName ()).isSameAs (context .getBean (FluentFormsAutoConfiguration .class )),
56+ ()->assertThat (context ).hasSingleBean (FluentFormsJerseyAutoConfiguration .class ),
57+ ()->assertThat (context ).getBean (FluentFormsJerseyAutoConfiguration .class .getName ()).isSameAs (context .getBean (FluentFormsJerseyAutoConfiguration .class )),
5358 ()->assertThat (context ).hasSingleBean (OutputService .class ),
5459 ()->assertThat (context ).getBean ("outputService" ).isNotNull (),
5560 ()->assertThat (context ).doesNotHaveBean (AemProxyAutoConfiguration .class ),
@@ -63,8 +68,8 @@ private static class SpringBootMocks {
6368 // Tests to make sure that only the FluentFormsLibraries are loaded in a web application.
6469 private static final ContextConsumer <? super AssertableWebApplicationContext > WEB_FF_LIBRARIES_ONLY = (context ) -> {
6570 assertAll (
66- ()->assertThat (context ).hasSingleBean (FluentFormsAutoConfiguration .class ),
67- ()->assertThat (context ).getBean (FluentFormsAutoConfiguration .class .getName ()).isSameAs (context .getBean (FluentFormsAutoConfiguration .class )),
71+ ()->assertThat (context ).hasSingleBean (FluentFormsJerseyAutoConfiguration .class ),
72+ ()->assertThat (context ).getBean (FluentFormsJerseyAutoConfiguration .class .getName ()).isSameAs (context .getBean (FluentFormsJerseyAutoConfiguration .class )),
6873 ()->assertThat (context ).hasSingleBean (OutputService .class ),
6974 ()->assertThat (context ).getBean ("outputService" ).isNotNull (),
7075 ()->assertThat (context ).doesNotHaveBean (AemProxyAutoConfiguration .class ),
@@ -78,8 +83,8 @@ private static class SpringBootMocks {
7883 // Tests to make sure that all beans are loaded by default in a web application.
7984 private static final ContextConsumer <? super AssertableWebApplicationContext > WEB_ALL_DEFAULT_SERVICES = (context ) -> {
8085 assertAll (
81- ()->assertThat (context ).hasSingleBean (FluentFormsAutoConfiguration .class ),
82- ()->assertThat (context ).getBean (FluentFormsAutoConfiguration .class .getName ()).isSameAs (context .getBean (FluentFormsAutoConfiguration .class )),
86+ ()->assertThat (context ).hasSingleBean (FluentFormsJerseyAutoConfiguration .class ),
87+ ()->assertThat (context ).getBean (FluentFormsJerseyAutoConfiguration .class .getName ()).isSameAs (context .getBean (FluentFormsJerseyAutoConfiguration .class )),
8388 ()->assertThat (context ).hasSingleBean (OutputService .class ),
8489 ()->assertThat (context ).getBean ("outputService" ).isNotNull (),
8590 ()->assertThat (context ).hasSingleBean (AemProxyJerseyAutoConfiguration .class ),
@@ -91,27 +96,27 @@ private static class SpringBootMocks {
9196 };
9297
9398 // Tests to make sure that all beans are loaded by default in a web application.
94- private static final ContextConsumer <? super AssertableWebApplicationContext > WEB_ALL_SPRINGMVC_SERVICES = (context ) -> {
95- assertAll (
96- ()->assertThat (context ).hasSingleBean (FluentFormsAutoConfiguration .class ),
97- ()->assertThat (context ).getBean (FluentFormsAutoConfiguration .class .getName ()).isSameAs (context .getBean (FluentFormsAutoConfiguration .class )),
98- ()->assertThat (context ).hasSingleBean (OutputService .class ),
99- ()->assertThat (context ).getBean ("outputService" ).isNotNull (),
100- ()->assertThat (context ).hasSingleBean (AemProxyAutoConfiguration .class ),
101- ()->assertThat (context ).getBean (AemProxyAutoConfiguration .class .getName ()).isSameAs (context .getBean (AemProxyAutoConfiguration .class )),
102- ()->assertThat (context ).hasSingleBean (SpringAfSubmitProcessor .class ),
103- ()->assertThat (context ).getBean (SpringAfSubmitProcessor .class ).isSameAs (context .getBean (AemProxyAfSubmission .AfSubmitAemProxyProcessor .class )),
104- ()->assertThat (context ).doesNotHaveBean (AfSubmissionHandler .class ),
105- ()->assertThat (context ).doesNotHaveBean (AemProxyJerseyAutoConfiguration .class ),
106- ()->assertThat (context ).doesNotHaveBean (JerseyAfSubmitProcessor .class )
107- );
108- };
99+ // private static final ContextConsumer<? super AssertableWebApplicationContext> WEB_ALL_SPRINGMVC_SERVICES = (context) -> {
100+ // assertAll(
101+ // ()->assertThat(context).hasSingleBean(FluentFormsJerseyAutoConfiguration .class),
102+ // ()->assertThat(context).getBean(FluentFormsJerseyAutoConfiguration .class.getName()).isSameAs(context.getBean(FluentFormsJerseyAutoConfiguration .class)),
103+ // ()->assertThat(context).hasSingleBean(OutputService.class),
104+ // ()->assertThat(context).getBean("outputService").isNotNull(),
105+ // ()->assertThat(context).hasSingleBean(AemProxyAutoConfiguration.class),
106+ // ()->assertThat(context).getBean(AemProxyAutoConfiguration.class.getName()).isSameAs(context.getBean(AemProxyAutoConfiguration.class)),
107+ // ()->assertThat(context).hasSingleBean(SpringAfSubmitProcessor.class),
108+ // ()->assertThat(context).getBean(SpringAfSubmitProcessor.class).isSameAs(context.getBean(AemProxyAfSubmission.AfSubmitAemProxyProcessor.class)),
109+ // ()->assertThat(context).doesNotHaveBean(AfSubmissionHandler.class),
110+ // ()->assertThat(context).doesNotHaveBean(AemProxyJerseyAutoConfiguration.class),
111+ // ()->assertThat(context).doesNotHaveBean(JerseyAfSubmitProcessor.class)
112+ // );
113+ // };
109114
110115 // Tests to make sure that all beans are loaded in a web application that contains a local submit handler.
111116 private static final ContextConsumer <? super AssertableWebApplicationContext > WEB_LOCAL_SUBMIT_SERVICES = (context ) -> {
112117 assertAll (
113- ()->assertThat (context ).hasSingleBean (FluentFormsAutoConfiguration .class ),
114- ()->assertThat (context ).getBean (FluentFormsAutoConfiguration .class .getName ()).isSameAs (context .getBean (FluentFormsAutoConfiguration .class )),
118+ ()->assertThat (context ).hasSingleBean (FluentFormsJerseyAutoConfiguration .class ),
119+ ()->assertThat (context ).getBean (FluentFormsJerseyAutoConfiguration .class .getName ()).isSameAs (context .getBean (FluentFormsJerseyAutoConfiguration .class )),
115120 ()->assertThat (context ).hasSingleBean (OutputService .class ),
116121 ()->assertThat (context ).getBean ("outputService" ).isNotNull (),
117122 ()->assertThat (context ).hasSingleBean (AemProxyJerseyAutoConfiguration .class ),
0 commit comments