36
36
import org .springframework .core .env .ConfigurableEnvironment ;
37
37
import org .springframework .core .env .EnumerablePropertySource ;
38
38
import org .springframework .core .env .Environment ;
39
+ import org .springframework .core .env .MapPropertySource ;
39
40
import org .springframework .core .env .PropertySource ;
40
41
import org .springframework .test .context .DynamicPropertyRegistry ;
41
42
import org .springframework .util .Assert ;
42
- import org .springframework .util .StringUtils ;
43
+ import org .springframework .util .function . SupplierUtils ;
43
44
44
45
/**
45
46
* {@link EnumerablePropertySource} backed by a map with values supplied from one or more
48
49
* @author Phillip Webb
49
50
* @since 3.1.0
50
51
*/
51
- public class TestcontainersPropertySource extends EnumerablePropertySource < Map < String , Supplier < Object >>> {
52
+ public class TestcontainersPropertySource extends MapPropertySource {
52
53
53
54
static final String NAME = "testcontainersPropertySource" ;
54
55
@@ -75,24 +76,14 @@ private void addEventPublisher(ApplicationEventPublisher eventPublisher) {
75
76
76
77
@ Override
77
78
public Object getProperty (String name ) {
78
- Supplier < Object > valueSupplier = this .source .get (name );
79
+ Object valueSupplier = this .source .get (name );
79
80
return (valueSupplier != null ) ? getProperty (name , valueSupplier ) : null ;
80
81
}
81
82
82
- private Object getProperty (String name , Supplier < Object > valueSupplier ) {
83
+ private Object getProperty (String name , Object valueSupplier ) {
83
84
BeforeTestcontainersPropertySuppliedEvent event = new BeforeTestcontainersPropertySuppliedEvent (this , name );
84
85
this .eventPublishers .forEach ((eventPublisher ) -> eventPublisher .publishEvent (event ));
85
- return valueSupplier .get ();
86
- }
87
-
88
- @ Override
89
- public boolean containsProperty (String name ) {
90
- return this .source .containsKey (name );
91
- }
92
-
93
- @ Override
94
- public String [] getPropertyNames () {
95
- return StringUtils .toStringArray (this .source .keySet ());
86
+ return SupplierUtils .resolve (valueSupplier );
96
87
}
97
88
98
89
public static DynamicPropertyRegistry attach (Environment environment ) {
0 commit comments