|
|
@ -71,7 +71,31 @@ class ServiceConnectionContextCustomizerFactoryTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void createContextCustomizerWhenClassHasNonStaticServiceConnectionFailsWithHepfulException() {
|
|
|
|
void createContextCustomizerWhenInterfaceHasServiceConnectionsReturnsCustomizer() {
|
|
|
|
|
|
|
|
ServiceConnectionContextCustomizer customizer = (ServiceConnectionContextCustomizer) this.factory
|
|
|
|
|
|
|
|
.createContextCustomizer(ServiceConnectionsInterface.class, null);
|
|
|
|
|
|
|
|
assertThat(customizer).isNotNull();
|
|
|
|
|
|
|
|
assertThat(customizer.getSources()).hasSize(2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void createContextCustomizerWhenSuperclassHasServiceConnectionsReturnsCustomizer() {
|
|
|
|
|
|
|
|
ServiceConnectionContextCustomizer customizer = (ServiceConnectionContextCustomizer) this.factory
|
|
|
|
|
|
|
|
.createContextCustomizer(ServiceConnectionsSubclass.class, null);
|
|
|
|
|
|
|
|
assertThat(customizer).isNotNull();
|
|
|
|
|
|
|
|
assertThat(customizer.getSources()).hasSize(2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void createContextCustomizerWhenImplementedInterfaceHasServiceConnectionsReturnsCustomizer() {
|
|
|
|
|
|
|
|
ServiceConnectionContextCustomizer customizer = (ServiceConnectionContextCustomizer) this.factory
|
|
|
|
|
|
|
|
.createContextCustomizer(ServiceConnectionsImpl.class, null);
|
|
|
|
|
|
|
|
assertThat(customizer).isNotNull();
|
|
|
|
|
|
|
|
assertThat(customizer.getSources()).hasSize(2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void createContextCustomizerWhenClassHasNonStaticServiceConnectionFailsWithHelpfulException() {
|
|
|
|
assertThatIllegalStateException()
|
|
|
|
assertThatIllegalStateException()
|
|
|
|
.isThrownBy(() -> this.factory.createContextCustomizer(NonStaticServiceConnection.class, null))
|
|
|
|
.isThrownBy(() -> this.factory.createContextCustomizer(NonStaticServiceConnection.class, null))
|
|
|
|
.withMessage("@ServiceConnection field 'service' must be static");
|
|
|
|
.withMessage("@ServiceConnection field 'service' must be static");
|
|
|
@ -79,7 +103,7 @@ class ServiceConnectionContextCustomizerFactoryTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void createContextCustomizerWhenClassHasAnnotationOnNonConnectionFieldFailsWithHepfulException() {
|
|
|
|
void createContextCustomizerWhenClassHasAnnotationOnNonConnectionFieldFailsWithHelpfulException() {
|
|
|
|
assertThatIllegalStateException()
|
|
|
|
assertThatIllegalStateException()
|
|
|
|
.isThrownBy(() -> this.factory.createContextCustomizer(ServiceConnectionOnWrongFieldType.class, null))
|
|
|
|
.isThrownBy(() -> this.factory.createContextCustomizer(ServiceConnectionOnWrongFieldType.class, null))
|
|
|
|
.withMessage("Field 'service2' in " + ServiceConnectionOnWrongFieldType.class.getName()
|
|
|
|
.withMessage("Field 'service2' in " + ServiceConnectionOnWrongFieldType.class.getName()
|
|
|
@ -141,6 +165,27 @@ class ServiceConnectionContextCustomizerFactoryTests {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface ServiceConnectionsInterface {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ServiceConnection
|
|
|
|
|
|
|
|
Container<?> service1 = new MockContainer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ServiceConnection
|
|
|
|
|
|
|
|
Container<?> service2 = new MockContainer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default void dummy() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class ServiceConnectionsSubclass extends ServiceConnections {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static class ServiceConnectionsImpl implements ServiceConnectionsInterface {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static class NonStaticServiceConnection {
|
|
|
|
static class NonStaticServiceConnection {
|
|
|
|
|
|
|
|
|
|
|
|
@ServiceConnection
|
|
|
|
@ServiceConnection
|
|
|
|