GH-1062 - ApplicationModuleExporter now exposes ApplicationModuleInitializer beans.

This commit is contained in:
Oliver Drotbohm
2025-02-21 22:49:28 +01:00
parent 8fb7f07b4a
commit 19db2339bd
6 changed files with 58 additions and 1 deletions

View File

@@ -16,13 +16,14 @@
package com.acme.myproject.moduleA;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.modulith.ApplicationModuleInitializer;
import org.springframework.stereotype.Component;
/**
* @author Oliver Drotbohm
*/
@Component
public class ServiceComponentA {
public class ServiceComponentA implements ApplicationModuleInitializer {
private final ApplicationEventPublisher publisher;
@@ -33,4 +34,7 @@ public class ServiceComponentA {
public void fireEvent() {
publisher.publishEvent(new SomeEventA("Message"));
}
@Override
public void initialize() {}
}

View File

@@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.modulith.core.ApplicationModules;
import com.acme.myproject.Application;
import com.acme.myproject.moduleA.ServiceComponentA;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.JsonPath;
@@ -61,4 +62,13 @@ class ApplicationModulesExporterUnitTests {
new ObjectMapper().readTree(EXPORTER.toJson());
});
}
@Test // GH-1062
void fullRenderingListsInitializers() {
var exported = EXPORTER.toFullJson();
assertThat((List<String>) JsonPath.compile("$..initializers[*]").read(exported))
.containsExactly(ServiceComponentA.class.getName());
}
}