Skip to content

Commit 441ed30

Browse files
committed
Polish "Replace Mockito argument captors with assertArg"
Co-authored-by: Andy Wilkinson <wilkinsona@vmware.com> See gh-35015
1 parent 80ca379 commit 441ed30

File tree

7 files changed

+149
-153
lines changed

7 files changed

+149
-153
lines changed

Diff for: spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/readiness/ServiceReadinessChecksTests.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import org.junit.jupiter.api.BeforeEach;
2727
import org.junit.jupiter.api.Test;
28-
import org.mockito.ArgumentCaptor;
28+
import org.mockito.ArgumentMatchers;
2929

3030
import org.springframework.boot.context.properties.bind.Binder;
3131
import org.springframework.boot.docker.compose.core.RunningService;
@@ -85,12 +85,12 @@ void setup() {
8585
void loadCanResolveArguments() {
8686
this.loader = spy(MockSpringFactoriesLoader.class);
8787
createChecks();
88-
ArgumentCaptor<ArgumentResolver> captor = ArgumentCaptor.forClass(ArgumentResolver.class);
89-
then(this.loader).should().load(eq(ServiceReadinessCheck.class), captor.capture());
90-
ArgumentResolver argumentResolver = captor.getValue();
91-
assertThat(argumentResolver.resolve(ClassLoader.class)).isEqualTo(this.classLoader);
92-
assertThat(argumentResolver.resolve(Environment.class)).isEqualTo(this.environment);
93-
assertThat(argumentResolver.resolve(Binder.class)).isEqualTo(this.binder);
88+
then(this.loader).should()
89+
.load(eq(ServiceReadinessCheck.class), ArgumentMatchers.<ArgumentResolver>assertArg((argumentResolver) -> {
90+
assertThat(argumentResolver.resolve(ClassLoader.class)).isEqualTo(this.classLoader);
91+
assertThat(argumentResolver.resolve(Environment.class)).isEqualTo(this.environment);
92+
assertThat(argumentResolver.resolve(Binder.class)).isEqualTo(this.binder);
93+
}));
9494
}
9595

9696
@Test

Diff for: spring-boot-project/spring-boot-testcontainers/src/test/java/org/springframework/boot/testcontainers/service/connection/ServiceConnectionContextCustomizerTests.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121

2222
import org.junit.jupiter.api.BeforeEach;
2323
import org.junit.jupiter.api.Test;
24-
import org.mockito.ArgumentCaptor;
24+
import org.mockito.ArgumentMatchers;
2525
import org.testcontainers.containers.PostgreSQLContainer;
2626

27-
import org.springframework.beans.factory.config.BeanDefinition;
2827
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
2928
import org.springframework.beans.factory.support.RootBeanDefinition;
3029
import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails;
@@ -83,12 +82,12 @@ void customizeContextRegistersServiceConnections() {
8382
given(this.factories.getConnectionDetails(this.source, true))
8483
.willReturn(Map.of(JdbcConnectionDetails.class, connectionDetails));
8584
customizer.customizeContext(context, mergedConfig);
86-
ArgumentCaptor<BeanDefinition> beanDefinitionCaptor = ArgumentCaptor.forClass(BeanDefinition.class);
8785
then(beanFactory).should()
88-
.registerBeanDefinition(eq("testJdbcConnectionDetailsForTest"), beanDefinitionCaptor.capture());
89-
RootBeanDefinition beanDefinition = (RootBeanDefinition) beanDefinitionCaptor.getValue();
90-
assertThat(beanDefinition.getInstanceSupplier().get()).isSameAs(connectionDetails);
91-
assertThat(beanDefinition.getBeanClass()).isEqualTo(TestJdbcConnectionDetails.class);
86+
.registerBeanDefinition(eq("testJdbcConnectionDetailsForTest"),
87+
ArgumentMatchers.<RootBeanDefinition>assertArg((beanDefinition) -> {
88+
assertThat(beanDefinition.getInstanceSupplier().get()).isSameAs(connectionDetails);
89+
assertThat(beanDefinition.getBeanClass()).isEqualTo(TestJdbcConnectionDetails.class);
90+
}));
9291
}
9392

9493
@Test

Diff for: spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/transport/HttpClientTransportTests.java

+84-80
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@
3333
import org.apache.hc.core5.http.HttpEntity;
3434
import org.apache.hc.core5.http.HttpHeaders;
3535
import org.apache.hc.core5.http.HttpHost;
36+
import org.assertj.core.api.ThrowingConsumer;
3637
import org.junit.jupiter.api.BeforeEach;
3738
import org.junit.jupiter.api.Test;
3839
import org.junit.jupiter.api.extension.ExtendWith;
39-
import org.mockito.ArgumentCaptor;
40-
import org.mockito.Captor;
4140
import org.mockito.Mock;
4241
import org.mockito.junit.jupiter.MockitoExtension;
4342

@@ -78,9 +77,6 @@ class HttpClientTransportTests {
7877
@Mock
7978
private InputStream content;
8079

81-
@Captor
82-
private ArgumentCaptor<HttpUriRequest> requestCaptor;
83-
8480
private HttpClientTransport http;
8581

8682
private URI uri;
@@ -117,13 +113,14 @@ void postShouldExecuteHttpPost() throws Exception {
117113
given(this.entity.getContent()).willReturn(this.content);
118114
given(this.response.getCode()).willReturn(200);
119115
Response response = this.http.post(this.uri);
120-
then(this.client).should().executeOpen(any(HttpHost.class), this.requestCaptor.capture(), isNull());
121-
HttpUriRequest request = this.requestCaptor.getValue();
122-
assertThat(request).isInstanceOf(HttpPost.class);
123-
assertThat(request.getUri()).isEqualTo(this.uri);
124-
assertThat(request.getFirstHeader(HttpHeaders.CONTENT_TYPE)).isNull();
125-
assertThat(request.getFirstHeader(HttpClientTransport.REGISTRY_AUTH_HEADER)).isNull();
126-
assertThat(response.getContent()).isSameAs(this.content);
116+
then(this.client).should()
117+
.executeOpen(any(HttpHost.class), assertArg((ThrowingConsumer<HttpPost>) (request) -> {
118+
assertThat(request).isInstanceOf(HttpPost.class);
119+
assertThat(request.getUri()).isEqualTo(this.uri);
120+
assertThat(request.getFirstHeader(HttpHeaders.CONTENT_TYPE)).isNull();
121+
assertThat(request.getFirstHeader(HttpClientTransport.REGISTRY_AUTH_HEADER)).isNull();
122+
assertThat(response.getContent()).isSameAs(this.content);
123+
}), isNull());
127124
}
128125

129126
@Test
@@ -132,13 +129,15 @@ void postWithRegistryAuthShouldExecuteHttpPostWithHeader() throws Exception {
132129
given(this.entity.getContent()).willReturn(this.content);
133130
given(this.response.getCode()).willReturn(200);
134131
Response response = this.http.post(this.uri, "auth token");
135-
then(this.client).should().executeOpen(any(HttpHost.class), this.requestCaptor.capture(), isNull());
136-
HttpUriRequest request = this.requestCaptor.getValue();
137-
assertThat(request).isInstanceOf(HttpPost.class);
138-
assertThat(request.getUri()).isEqualTo(this.uri);
139-
assertThat(request.getFirstHeader(HttpHeaders.CONTENT_TYPE)).isNull();
140-
assertThat(request.getFirstHeader(HttpClientTransport.REGISTRY_AUTH_HEADER).getValue()).isEqualTo("auth token");
141-
assertThat(response.getContent()).isSameAs(this.content);
132+
then(this.client).should()
133+
.executeOpen(any(HttpHost.class), assertArg((ThrowingConsumer<HttpPost>) (request) -> {
134+
assertThat(request).isInstanceOf(HttpPost.class);
135+
assertThat(request.getUri()).isEqualTo(this.uri);
136+
assertThat(request.getFirstHeader(HttpHeaders.CONTENT_TYPE)).isNull();
137+
assertThat(request.getFirstHeader(HttpClientTransport.REGISTRY_AUTH_HEADER).getValue())
138+
.isEqualTo("auth token");
139+
assertThat(response.getContent()).isSameAs(this.content);
140+
}), isNull());
142141
}
143142

144143
@Test
@@ -147,13 +146,14 @@ void postWithEmptyRegistryAuthShouldExecuteHttpPostWithoutHeader() throws Except
147146
given(this.entity.getContent()).willReturn(this.content);
148147
given(this.response.getCode()).willReturn(200);
149148
Response response = this.http.post(this.uri, "");
150-
then(this.client).should().executeOpen(any(HttpHost.class), this.requestCaptor.capture(), isNull());
151-
HttpUriRequest request = this.requestCaptor.getValue();
152-
assertThat(request).isInstanceOf(HttpPost.class);
153-
assertThat(request.getUri()).isEqualTo(this.uri);
154-
assertThat(request.getFirstHeader(HttpHeaders.CONTENT_TYPE)).isNull();
155-
assertThat(request.getFirstHeader(HttpClientTransport.REGISTRY_AUTH_HEADER)).isNull();
156-
assertThat(response.getContent()).isSameAs(this.content);
149+
then(this.client).should()
150+
.executeOpen(any(HttpHost.class), assertArg((ThrowingConsumer<HttpPost>) (request) -> {
151+
assertThat(request).isInstanceOf(HttpPost.class);
152+
assertThat(request.getUri()).isEqualTo(this.uri);
153+
assertThat(request.getFirstHeader(HttpHeaders.CONTENT_TYPE)).isNull();
154+
assertThat(request.getFirstHeader(HttpClientTransport.REGISTRY_AUTH_HEADER)).isNull();
155+
assertThat(response.getContent()).isSameAs(this.content);
156+
}), isNull());
157157
}
158158

159159
@Test
@@ -164,18 +164,19 @@ void postWithJsonContentShouldExecuteHttpPost() throws Exception {
164164
given(this.response.getCode()).willReturn(200);
165165
Response response = this.http.post(this.uri, APPLICATION_JSON,
166166
(out) -> StreamUtils.copy(content, StandardCharsets.UTF_8, out));
167-
then(this.client).should().executeOpen(any(HttpHost.class), this.requestCaptor.capture(), isNull());
168-
HttpUriRequest request = this.requestCaptor.getValue();
169-
HttpEntity entity = request.getEntity();
170-
assertThat(request).isInstanceOf(HttpPost.class);
171-
assertThat(request.getUri()).isEqualTo(this.uri);
172-
assertThat(entity.isRepeatable()).isFalse();
173-
assertThat(entity.getContentLength()).isEqualTo(content.length());
174-
assertThat(entity.getContentType()).isEqualTo(APPLICATION_JSON);
175-
assertThat(entity.isStreaming()).isTrue();
176-
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(entity::getContent);
177-
assertThat(writeToString(entity)).isEqualTo(content);
178-
assertThat(response.getContent()).isSameAs(this.content);
167+
then(this.client).should()
168+
.executeOpen(any(HttpHost.class), assertArg((ThrowingConsumer<HttpPost>) (request) -> {
169+
HttpEntity entity = request.getEntity();
170+
assertThat(request).isInstanceOf(HttpPost.class);
171+
assertThat(request.getUri()).isEqualTo(this.uri);
172+
assertThat(entity.isRepeatable()).isFalse();
173+
assertThat(entity.getContentLength()).isEqualTo(content.length());
174+
assertThat(entity.getContentType()).isEqualTo(APPLICATION_JSON);
175+
assertThat(entity.isStreaming()).isTrue();
176+
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(entity::getContent);
177+
assertThat(writeToString(entity)).isEqualTo(content);
178+
assertThat(response.getContent()).isSameAs(this.content);
179+
}), isNull());
179180
}
180181

181182
@Test
@@ -186,18 +187,19 @@ void postWithArchiveContentShouldExecuteHttpPost() throws Exception {
186187
given(this.response.getCode()).willReturn(200);
187188
Response response = this.http.post(this.uri, APPLICATION_X_TAR,
188189
(out) -> StreamUtils.copy(content, StandardCharsets.UTF_8, out));
189-
then(this.client).should().executeOpen(any(HttpHost.class), this.requestCaptor.capture(), isNull());
190-
HttpUriRequest request = this.requestCaptor.getValue();
191-
HttpEntity entity = request.getEntity();
192-
assertThat(request).isInstanceOf(HttpPost.class);
193-
assertThat(request.getUri()).isEqualTo(this.uri);
194-
assertThat(entity.isRepeatable()).isFalse();
195-
assertThat(entity.getContentLength()).isEqualTo(-1);
196-
assertThat(entity.getContentType()).isEqualTo(APPLICATION_X_TAR);
197-
assertThat(entity.isStreaming()).isTrue();
198-
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(entity::getContent);
199-
assertThat(writeToString(entity)).isEqualTo(content);
200-
assertThat(response.getContent()).isSameAs(this.content);
190+
then(this.client).should()
191+
.executeOpen(any(HttpHost.class), assertArg((ThrowingConsumer<HttpPost>) (request) -> {
192+
HttpEntity entity = request.getEntity();
193+
assertThat(request).isInstanceOf(HttpPost.class);
194+
assertThat(request.getUri()).isEqualTo(this.uri);
195+
assertThat(entity.isRepeatable()).isFalse();
196+
assertThat(entity.getContentLength()).isEqualTo(-1);
197+
assertThat(entity.getContentType()).isEqualTo(APPLICATION_X_TAR);
198+
assertThat(entity.isStreaming()).isTrue();
199+
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(entity::getContent);
200+
assertThat(writeToString(entity)).isEqualTo(content);
201+
assertThat(response.getContent()).isSameAs(this.content);
202+
}), isNull());
201203
}
202204

203205
@Test
@@ -208,18 +210,18 @@ void putWithJsonContentShouldExecuteHttpPut() throws Exception {
208210
given(this.response.getCode()).willReturn(200);
209211
Response response = this.http.put(this.uri, APPLICATION_JSON,
210212
(out) -> StreamUtils.copy(content, StandardCharsets.UTF_8, out));
211-
then(this.client).should().executeOpen(any(HttpHost.class), this.requestCaptor.capture(), isNull());
212-
HttpUriRequest request = this.requestCaptor.getValue();
213-
HttpEntity entity = request.getEntity();
214-
assertThat(request).isInstanceOf(HttpPut.class);
215-
assertThat(request.getUri()).isEqualTo(this.uri);
216-
assertThat(entity.isRepeatable()).isFalse();
217-
assertThat(entity.getContentLength()).isEqualTo(content.length());
218-
assertThat(entity.getContentType()).isEqualTo(APPLICATION_JSON);
219-
assertThat(entity.isStreaming()).isTrue();
220-
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(entity::getContent);
221-
assertThat(writeToString(entity)).isEqualTo(content);
222-
assertThat(response.getContent()).isSameAs(this.content);
213+
then(this.client).should().executeOpen(any(HttpHost.class), assertArg((ThrowingConsumer<HttpPut>) (request) -> {
214+
HttpEntity entity = request.getEntity();
215+
assertThat(request).isInstanceOf(HttpPut.class);
216+
assertThat(request.getUri()).isEqualTo(this.uri);
217+
assertThat(entity.isRepeatable()).isFalse();
218+
assertThat(entity.getContentLength()).isEqualTo(content.length());
219+
assertThat(entity.getContentType()).isEqualTo(APPLICATION_JSON);
220+
assertThat(entity.isStreaming()).isTrue();
221+
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(entity::getContent);
222+
assertThat(writeToString(entity)).isEqualTo(content);
223+
assertThat(response.getContent()).isSameAs(this.content);
224+
}), isNull());
223225
}
224226

225227
@Test
@@ -230,18 +232,18 @@ void putWithArchiveContentShouldExecuteHttpPut() throws Exception {
230232
given(this.response.getCode()).willReturn(200);
231233
Response response = this.http.put(this.uri, APPLICATION_X_TAR,
232234
(out) -> StreamUtils.copy(content, StandardCharsets.UTF_8, out));
233-
then(this.client).should().executeOpen(any(HttpHost.class), this.requestCaptor.capture(), isNull());
234-
HttpUriRequest request = this.requestCaptor.getValue();
235-
HttpEntity entity = request.getEntity();
236-
assertThat(request).isInstanceOf(HttpPut.class);
237-
assertThat(request.getUri()).isEqualTo(this.uri);
238-
assertThat(entity.isRepeatable()).isFalse();
239-
assertThat(entity.getContentLength()).isEqualTo(-1);
240-
assertThat(entity.getContentType()).isEqualTo(APPLICATION_X_TAR);
241-
assertThat(entity.isStreaming()).isTrue();
242-
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(entity::getContent);
243-
assertThat(writeToString(entity)).isEqualTo(content);
244-
assertThat(response.getContent()).isSameAs(this.content);
235+
then(this.client).should().executeOpen(any(HttpHost.class), assertArg((ThrowingConsumer<HttpPut>) (request) -> {
236+
HttpEntity entity = request.getEntity();
237+
assertThat(request).isInstanceOf(HttpPut.class);
238+
assertThat(request.getUri()).isEqualTo(this.uri);
239+
assertThat(entity.isRepeatable()).isFalse();
240+
assertThat(entity.getContentLength()).isEqualTo(-1);
241+
assertThat(entity.getContentType()).isEqualTo(APPLICATION_X_TAR);
242+
assertThat(entity.isStreaming()).isTrue();
243+
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(entity::getContent);
244+
assertThat(writeToString(entity)).isEqualTo(content);
245+
assertThat(response.getContent()).isSameAs(this.content);
246+
}), isNull());
245247
}
246248

247249
@Test
@@ -250,12 +252,14 @@ void deleteShouldExecuteHttpDelete() throws Exception {
250252
given(this.entity.getContent()).willReturn(this.content);
251253
given(this.response.getCode()).willReturn(200);
252254
Response response = this.http.delete(this.uri);
253-
then(this.client).should().executeOpen(any(HttpHost.class), this.requestCaptor.capture(), isNull());
254-
HttpUriRequest request = this.requestCaptor.getValue();
255-
assertThat(request).isInstanceOf(HttpDelete.class);
256-
assertThat(request.getUri()).isEqualTo(this.uri);
257-
assertThat(request.getFirstHeader(HttpHeaders.CONTENT_TYPE)).isNull();
258-
assertThat(response.getContent()).isSameAs(this.content);
255+
256+
then(this.client).should()
257+
.executeOpen(any(HttpHost.class), assertArg((ThrowingConsumer<HttpDelete>) (request) -> {
258+
assertThat(request).isInstanceOf(HttpDelete.class);
259+
assertThat(request.getUri()).isEqualTo(this.uri);
260+
assertThat(request.getFirstHeader(HttpHeaders.CONTENT_TYPE)).isNull();
261+
assertThat(response.getContent()).isSameAs(this.content);
262+
}), isNull());
259263
}
260264

261265
@Test

Diff for: spring-boot-project/spring-boot-tools/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommandTests.java

+13-16
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import org.junit.jupiter.api.BeforeEach;
2121
import org.junit.jupiter.api.Test;
2222
import org.junit.jupiter.api.extension.ExtendWith;
23-
import org.mockito.ArgumentCaptor;
24-
import org.mockito.Captor;
2523
import org.mockito.junit.jupiter.MockitoExtension;
2624

2725
import org.springframework.boot.cli.command.status.ExitStatus;
@@ -31,6 +29,7 @@
3129
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
3230

3331
import static org.assertj.core.api.Assertions.assertThat;
32+
import static org.mockito.ArgumentMatchers.assertArg;
3433
import static org.mockito.BDDMockito.then;
3534

3635
/**
@@ -43,9 +42,6 @@ class EncodePasswordCommandTests {
4342

4443
private MockLog log;
4544

46-
@Captor
47-
private ArgumentCaptor<String> message;
48-
4945
@BeforeEach
5046
void setup() {
5147
this.log = MockLog.attach();
@@ -60,31 +56,32 @@ void cleanup() {
6056
void encodeWithNoAlgorithmShouldUseBcrypt() throws Exception {
6157
EncodePasswordCommand command = new EncodePasswordCommand();
6258
ExitStatus status = command.run("boot");
63-
then(this.log).should().info(this.message.capture());
64-
assertThat(this.message.getValue()).startsWith("{bcrypt}");
65-
assertThat(PasswordEncoderFactories.createDelegatingPasswordEncoder().matches("boot", this.message.getValue()))
66-
.isTrue();
59+
then(this.log).should().info(assertArg((message) -> {
60+
assertThat(message).startsWith("{bcrypt}");
61+
assertThat(PasswordEncoderFactories.createDelegatingPasswordEncoder().matches("boot", message)).isTrue();
62+
}));
6763
assertThat(status).isEqualTo(ExitStatus.OK);
6864
}
6965

7066
@Test
7167
void encodeWithBCryptShouldUseBCrypt() throws Exception {
7268
EncodePasswordCommand command = new EncodePasswordCommand();
7369
ExitStatus status = command.run("-a", "bcrypt", "boot");
74-
then(this.log).should().info(this.message.capture());
75-
assertThat(this.message.getValue()).doesNotStartWith("{");
76-
assertThat(new BCryptPasswordEncoder().matches("boot", this.message.getValue())).isTrue();
70+
then(this.log).should().info(assertArg((message) -> {
71+
assertThat(message).doesNotStartWith("{");
72+
assertThat(new BCryptPasswordEncoder().matches("boot", message)).isTrue();
73+
}));
7774
assertThat(status).isEqualTo(ExitStatus.OK);
7875
}
7976

8077
@Test
8178
void encodeWithPbkdf2ShouldUsePbkdf2() throws Exception {
8279
EncodePasswordCommand command = new EncodePasswordCommand();
8380
ExitStatus status = command.run("-a", "pbkdf2", "boot");
84-
then(this.log).should().info(this.message.capture());
85-
assertThat(this.message.getValue()).doesNotStartWith("{");
86-
assertThat(Pbkdf2PasswordEncoder.defaultsForSpringSecurity_v5_8().matches("boot", this.message.getValue()))
87-
.isTrue();
81+
then(this.log).should().info(assertArg((message) -> {
82+
assertThat(message).doesNotStartWith("{");
83+
assertThat(Pbkdf2PasswordEncoder.defaultsForSpringSecurity_v5_8().matches("boot", message)).isTrue();
84+
}));
8885
assertThat(status).isEqualTo(ExitStatus.OK);
8986
}
9087

Diff for: spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributorsTests.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.junit.jupiter.api.Test;
2929
import org.junit.jupiter.api.extension.ExtendWith;
3030
import org.mockito.ArgumentCaptor;
31-
import org.mockito.Captor;
3231
import org.mockito.junit.jupiter.MockitoExtension;
3332

3433
import org.springframework.boot.DefaultBootstrapContext;
@@ -77,9 +76,6 @@ class ConfigDataEnvironmentContributorsTests {
7776

7877
private ConfigDataActivationContext activationContext;
7978

80-
@Captor
81-
private ArgumentCaptor<ConfigDataLocationResolverContext> locationResolverContext;
82-
8379
@BeforeEach
8480
void setup() {
8581
this.environment = new MockEnvironment();
@@ -213,10 +209,12 @@ void withProcessedImportsProvidesLocationResolverContextWithAccessToParent() {
213209
ConfigDataEnvironmentContributor contributor = ConfigDataEnvironmentContributor.ofInitialImport(LOCATION_1);
214210
ConfigDataEnvironmentContributors contributors = new ConfigDataEnvironmentContributors(this.logFactory,
215211
this.bootstrapContext, Arrays.asList(contributor));
212+
ArgumentCaptor<ConfigDataLocationResolverContext> locationResolverContext = ArgumentCaptor
213+
.forClass(ConfigDataLocationResolverContext.class);
216214
contributors.withProcessedImports(this.importer, this.activationContext);
217215
then(this.importer).should()
218-
.resolveAndLoad(any(), this.locationResolverContext.capture(), any(), eq(secondLocations));
219-
ConfigDataLocationResolverContext context = this.locationResolverContext.getValue();
216+
.resolveAndLoad(any(), locationResolverContext.capture(), any(), eq(secondLocations));
217+
ConfigDataLocationResolverContext context = locationResolverContext.getValue();
220218
assertThat(context.getParent()).hasToString("a");
221219
}
222220

0 commit comments

Comments
 (0)