Merge branch '2.7.x'

This commit is contained in:
Stephane Nicoll
2022-02-01 11:15:49 +01:00
195 changed files with 1267 additions and 1293 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ import org.springframework.context.support.StaticApplicationContext;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Tests for {@link ApplicationContextAssertProvider} and
@@ -102,7 +102,7 @@ class ApplicationContextAssertProviderTests {
ApplicationContextAssertProvider<ApplicationContext> context = get(this.mockContextSupplier);
assertThat((Object) context).isNotNull();
context.getBean("foo");
verify(this.mockContext).getBean("foo");
then(this.mockContext).should().getBean("foo");
}
@Test
@@ -186,7 +186,7 @@ class ApplicationContextAssertProviderTests {
void closeShouldCloseContext() {
ApplicationContextAssertProvider<ApplicationContext> context = get(this.mockContextSupplier);
context.close();
verify(this.mockContext).close();
then(this.mockContext).should().close();
}
private ApplicationContextAssertProvider<ApplicationContext> get(Supplier<ApplicationContext> contextSupplier) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,8 +28,8 @@ import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Component;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
/**
* Tests for nested test configuration when the configuration is inherited from the
@@ -50,14 +50,14 @@ class InheritedNestedTestConfigurationTests {
@Test
void mockWasInvokedOnce() {
this.performer.run();
verify(this.action, times(1)).perform();
then(this.action).should().perform();
}
@Test
void mockWasInvokedTwice() {
this.performer.run();
this.performer.run();
verify(this.action, times(2)).perform();
then(this.action).should(times(2)).perform();
}
@Nested
@@ -66,14 +66,14 @@ class InheritedNestedTestConfigurationTests {
@Test
void mockWasInvokedOnce() {
InheritedNestedTestConfigurationTests.this.performer.run();
verify(InheritedNestedTestConfigurationTests.this.action, times(1)).perform();
then(InheritedNestedTestConfigurationTests.this.action).should().perform();
}
@Test
void mockWasInvokedTwice() {
InheritedNestedTestConfigurationTests.this.performer.run();
InheritedNestedTestConfigurationTests.this.performer.run();
verify(InheritedNestedTestConfigurationTests.this.action, times(2)).perform();
then(InheritedNestedTestConfigurationTests.this.action).should(times(2)).perform();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,10 +27,9 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
/**
* Tests for {@link ContextConsumer}.
@@ -62,8 +61,8 @@ class ContextConsumerTests {
ContextConsumer<ApplicationContext> secondConsumer = (context) -> assertThat(predicate.test(24)).isFalse();
assertThatThrownBy(() -> firstConsumer.andThen(secondConsumer).accept(mock(ApplicationContext.class)))
.isInstanceOf(AssertionError.class);
verify(predicate).test(42);
verifyNoMoreInteractions(predicate);
then(predicate).should().test(42);
then(predicate).shouldHaveNoMoreInteractions();
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Test {@link MockBean @MockBean} on a test class field can be used to replace existing
@@ -56,7 +56,7 @@ class MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests {
@Test
void testMocking() {
this.caller.sayGreeting();
verify(this.service).greeting();
then(this.service).should().greeting();
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,8 +37,8 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
/**
* Test {@link MockBean @MockBean} when mixed with Spring AOP.
@@ -60,9 +60,9 @@ class MockBeanWithAopProxyTests {
given(this.dateService.getDate(false)).willReturn(2L);
Long d2 = this.dateService.getDate(false);
assertThat(d2).isEqualTo(2L);
verify(this.dateService, times(2)).getDate(false);
verify(this.dateService, times(2)).getDate(eq(false));
verify(this.dateService, times(2)).getDate(anyBoolean());
then(this.dateService).should(times(2)).getDate(false);
then(this.dateService).should(times(2)).getDate(eq(false));
then(this.dateService).should(times(2)).getDate(anyBoolean());
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,9 +34,8 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
/**
* Tests for {@link MockitoTestExecutionListener}.
@@ -72,14 +71,14 @@ class MockitoTestExecutionListenerTests {
TestContext testContext = mockTestContext(instance);
given(testContext.getApplicationContext()).willReturn(this.applicationContext);
this.listener.prepareTestInstance(testContext);
verify(this.postProcessor).inject(this.fieldCaptor.capture(), eq(instance), any(MockDefinition.class));
then(this.postProcessor).should().inject(this.fieldCaptor.capture(), eq(instance), any(MockDefinition.class));
assertThat(this.fieldCaptor.getValue().getName()).isEqualTo("mockBean");
}
@Test
void beforeTestMethodShouldDoNothingWhenDirtiesContextAttributeIsNotSet() throws Exception {
this.listener.beforeTestMethod(mock(TestContext.class));
verifyNoMoreInteractions(this.postProcessor);
then(this.postProcessor).shouldHaveNoMoreInteractions();
}
@Test
@@ -91,7 +90,7 @@ class MockitoTestExecutionListenerTests {
given(mockTestContext.getAttribute(DependencyInjectionTestExecutionListener.REINJECT_DEPENDENCIES_ATTRIBUTE))
.willReturn(Boolean.TRUE);
this.listener.beforeTestMethod(mockTestContext);
verify(this.postProcessor).inject(this.fieldCaptor.capture(), eq(instance), any(MockDefinition.class));
then(this.postProcessor).should().inject(this.fieldCaptor.capture(), eq(instance), any(MockDefinition.class));
assertThat(this.fieldCaptor.getValue().getName()).isEqualTo("mockBean");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ import org.springframework.util.ReflectionUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Tests for {@link QualifierDefinition}.
@@ -81,7 +81,7 @@ class QualifierDefinitionTests {
Field field = ReflectionUtils.findField(ConfigA.class, "directQualifier");
QualifierDefinition qualifierDefinition = QualifierDefinition.forElement(field);
qualifierDefinition.matches(this.beanFactory, "bean");
verify(this.beanFactory).isAutowireCandidate(eq("bean"), this.descriptorCaptor.capture());
then(this.beanFactory).should().isAutowireCandidate(eq("bean"), this.descriptorCaptor.capture());
assertThat(this.descriptorCaptor.getValue().getAnnotatedElement()).isEqualTo(field);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Test {@link SpyBean @SpyBean} on a configuration class can be used to spy existing
@@ -44,7 +44,7 @@ class SpyBeanOnConfigurationClassForExistingBeanIntegrationTests {
@Test
void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.caller.getService()).greeting();
then(this.caller.getService()).should().greeting();
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Test {@link SpyBean @SpyBean} on a configuration class can be used to inject new spy
@@ -44,7 +44,7 @@ class SpyBeanOnConfigurationClassForNewBeanIntegrationTests {
@Test
void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.caller.getService()).greeting();
then(this.caller.getService()).should().greeting();
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Test {@link SpyBean @SpyBean} on a field on a {@code @Configuration} class can be used
@@ -48,7 +48,7 @@ class SpyBeanOnConfigurationFieldForExistingBeanIntegrationTests {
@Test
void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.config.exampleService).greeting();
then(this.config.exampleService).should().greeting();
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Test {@link SpyBean @SpyBean} on a field on a {@code @Configuration} class can be used
@@ -47,7 +47,7 @@ class SpyBeanOnConfigurationFieldForNewBeanIntegrationTests {
@Test
void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.config.exampleService).greeting();
then(this.config.exampleService).should().greeting();
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Test {@link SpyBean @SpyBean} on a test class can be used to replace existing beans.
@@ -44,7 +44,7 @@ class SpyBeanOnTestClassForExistingBeanIntegrationTests {
@Test
void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.caller.getService()).greeting();
then(this.caller.getService()).should().greeting();
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Test {@link SpyBean @SpyBean} on a test class can be used to inject new spy instances.
@@ -44,7 +44,7 @@ class SpyBeanOnTestClassForNewBeanIntegrationTests {
@Test
void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.caller.getService()).greeting();
then(this.caller.getService()).should().greeting();
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Test {@link SpyBean @SpyBean} on a test class field can be used to replace existing
@@ -50,7 +50,7 @@ class SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests {
@Test
void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.caller.getService()).greeting();
then(this.caller.getService()).should().greeting();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Test {@link SpyBean @SpyBean} on a test class field can be used to replace existing
@@ -48,7 +48,7 @@ class SpyBeanOnTestFieldForExistingBeanIntegrationTests {
@Test
void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.caller.getService()).greeting();
then(this.caller.getService()).should().greeting();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Test {@link SpyBean @SpyBean} on a test class field can be used to replace existing
@@ -55,7 +55,7 @@ class SpyBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests {
@Test
void testMocking() throws Exception {
this.caller.sayGreeting();
verify(this.service).greeting();
then(this.service).should().greeting();
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Test {@link SpyBean @SpyBean} on a test class field can be used to replace existing
@@ -53,7 +53,7 @@ class SpyBeanOnTestFieldForExistingGenericBeanIntegrationTests {
@Test
void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say 123 simple");
verify(this.exampleService).greeting();
then(this.exampleService).should().greeting();
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import org.springframework.context.annotation.Primary;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Test {@link SpyBean @SpyBean} on a test class field can be used to inject a spy
@@ -52,7 +52,7 @@ class SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegrationTests {
assertThat(this.caller.sayGreeting()).isEqualTo("I say two");
assertThat(Mockito.mockingDetails(this.spy).getMockCreationSettings().getMockName().toString())
.isEqualTo("two");
verify(this.spy).greeting();
then(this.spy).should().greeting();
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Test {@link SpyBean @SpyBean} on a test class field can be used to inject new spy
@@ -47,7 +47,7 @@ class SpyBeanOnTestFieldForNewBeanIntegrationTests {
@Test
void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.caller.getService()).greeting();
then(this.caller.getService()).should().greeting();
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,9 +35,8 @@ import org.springframework.stereotype.Service;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
/**
* Test {@link SpyBean @SpyBean} when mixed with Spring AOP.
@@ -54,7 +53,7 @@ class SpyBeanWithAopProxyAndNotProxyTargetAwareTests {
@Test
void verifyShouldUseProxyTarget() {
this.dateService.getDate(false);
verify(this.dateService, times(1)).getDate(false);
then(this.dateService).should().getDate(false);
assertThatExceptionOfType(UnfinishedVerificationException.class).isThrownBy(() -> reset(this.dateService));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,8 +36,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Test {@link SpyBean @SpyBean} when mixed with Spring AOP.
@@ -57,9 +56,9 @@ class SpyBeanWithAopProxyTests {
Thread.sleep(200);
Long d2 = this.dateService.getDate(false);
assertThat(d1).isEqualTo(d2);
verify(this.dateService, times(1)).getDate(false);
verify(this.dateService, times(1)).getDate(eq(false));
verify(this.dateService, times(1)).getDate(anyBoolean());
then(this.dateService).should().getDate(false);
then(this.dateService).should().getDate(eq(false));
then(this.dateService).should().getDate(anyBoolean());
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Integration tests for using {@link SpyBean @SpyBean} with
@@ -49,7 +49,7 @@ class SpyBeanWithDirtiesContextClassModeBeforeMethodIntegrationTests {
@Test
void testSpying() throws Exception {
this.caller.sayGreeting();
verify(this.exampleService).greeting();
then(this.exampleService).should().greeting();
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.BDDMockito.then;
/**
* Tests for {@link SpyBean @SpyBean} with a JDK proxy.
@@ -50,7 +50,7 @@ class SpyBeanWithJdkProxyTests {
void jdkProxyCanBeSpied() throws Exception {
Example example = this.service.find("id");
assertThat(example.id).isEqualTo("id");
verify(this.repository).find("id");
then(this.repository).should().find("id");
}
@Configuration(proxyBeanMethods = false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,8 +22,8 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link ApplicationContextTestUtils}.
@@ -50,10 +50,10 @@ class ApplicationContextTestUtilsTests {
given(mock.getParent()).willReturn(parent);
given(parent.getParent()).willReturn(null);
ApplicationContextTestUtils.closeAll(mock);
verify(mock).getParent();
verify(mock).close();
verify(parent).getParent();
verify(parent).close();
then(mock).should().getParent();
then(mock).should().close();
then(parent).should().getParent();
then(parent).should().close();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,8 +28,8 @@ import org.springframework.web.util.UriTemplateHandler;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link LocalHostUriTemplateHandler}.
@@ -99,7 +99,7 @@ class LocalHostUriTemplateHandlerTests {
given(uriTemplateHandler.expand("https://localhost:8080/", uriVariables)).willReturn(uri);
LocalHostUriTemplateHandler handler = new LocalHostUriTemplateHandler(environment, "https", uriTemplateHandler);
assertThat(handler.expand("/", uriVariables)).isEqualTo(uri);
verify(uriTemplateHandler).expand("https://localhost:8080/", uriVariables);
then(uriTemplateHandler).should().expand("https://localhost:8080/", uriVariables);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,8 +40,8 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
@@ -85,7 +85,7 @@ class RootUriRequestExpectationManagerTests {
ExpectedCount count = ExpectedCount.once();
RequestMatcher requestMatcher = mock(RequestMatcher.class);
this.manager.expectRequest(count, requestMatcher);
verify(this.delegate).expectRequest(count, requestMatcher);
then(this.delegate).should().expectRequest(count, requestMatcher);
}
@Test
@@ -93,7 +93,7 @@ class RootUriRequestExpectationManagerTests {
ClientHttpRequest request = mock(ClientHttpRequest.class);
given(request.getURI()).willReturn(new URI("https://spring.io/test"));
this.manager.validateRequest(request);
verify(this.delegate).validateRequest(request);
then(this.delegate).should().validateRequest(request);
}
@Test
@@ -101,7 +101,7 @@ class RootUriRequestExpectationManagerTests {
ClientHttpRequest request = mock(ClientHttpRequest.class);
given(request.getURI()).willReturn(new URI(this.uri + "/hello"));
this.manager.validateRequest(request);
verify(this.delegate).validateRequest(this.requestCaptor.capture());
then(this.delegate).should().validateRequest(this.requestCaptor.capture());
HttpRequestWrapper actual = (HttpRequestWrapper) this.requestCaptor.getValue();
assertThat(actual.getRequest()).isSameAs(request);
assertThat(actual.getURI()).isEqualTo(new URI("/hello"));
@@ -120,7 +120,7 @@ class RootUriRequestExpectationManagerTests {
@Test
void resetRequestShouldDelegateToExpectationManager() {
this.manager.reset();
verify(this.delegate).reset();
then(this.delegate).should().reset();
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,8 +56,8 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link TestRestTemplate}.
@@ -246,7 +246,7 @@ class TestRestTemplateTests {
LocalHostUriTemplateHandler uriTemplateHandler = new LocalHostUriTemplateHandler(new MockEnvironment());
template.setUriTemplateHandler(uriTemplateHandler);
template.exchange(entity, String.class);
verify(requestFactory).createRequest(eq(absoluteUri), eq(HttpMethod.GET));
then(requestFactory).should().createRequest(eq(absoluteUri), eq(HttpMethod.GET));
}
@Test
@@ -260,7 +260,7 @@ class TestRestTemplateTests {
given(requestFactory.createRequest(eq(absoluteUri), eq(HttpMethod.GET))).willReturn(request);
template.getRestTemplate().setRequestFactory(requestFactory);
template.exchange(entity, String.class);
verify(requestFactory).createRequest(eq(absoluteUri), eq(HttpMethod.GET));
then(requestFactory).should().createRequest(eq(absoluteUri), eq(HttpMethod.GET));
}
@Test
@@ -362,7 +362,7 @@ class TestRestTemplateTests {
LocalHostUriTemplateHandler uriTemplateHandler = new LocalHostUriTemplateHandler(new MockEnvironment());
template.setUriTemplateHandler(uriTemplateHandler);
callback.doWithTestRestTemplate(template, URI.create("/a/b/c.txt?param=%7Bsomething%7D"));
verify(requestFactory).createRequest(eq(absoluteUri), any(HttpMethod.class));
then(requestFactory).should().createRequest(eq(absoluteUri), any(HttpMethod.class));
}
private void assertBasicAuthorizationCredentials(TestRestTemplate testRestTemplate, String username,

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,8 +36,8 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link LocalHostWebClient}.
@@ -64,7 +64,7 @@ class LocalHostWebClientTests {
WebConnection connection = mockConnection();
client.setWebConnection(connection);
client.getPage("/test");
verify(connection).getResponse(this.requestCaptor.capture());
then(connection).should().getResponse(this.requestCaptor.capture());
assertThat(this.requestCaptor.getValue().getUrl()).isEqualTo(new URL("http://localhost:8080/test"));
}
@@ -76,7 +76,7 @@ class LocalHostWebClientTests {
WebConnection connection = mockConnection();
client.setWebConnection(connection);
client.getPage("/test");
verify(connection).getResponse(this.requestCaptor.capture());
then(connection).should().getResponse(this.requestCaptor.capture());
assertThat(this.requestCaptor.getValue().getUrl()).isEqualTo(new URL("http://localhost:8181/test"));
}

View File

@@ -38,8 +38,8 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Tests for {@link LocalHostWebConnectionHtmlUnitDriver}.
@@ -94,7 +94,8 @@ class LocalHostWebConnectionHtmlUnitDriverTests {
MockEnvironment environment = new MockEnvironment();
LocalHostWebConnectionHtmlUnitDriver driver = new TestLocalHostWebConnectionHtmlUnitDriver(environment);
driver.get("/test");
verify(this.webClient).getPage(isNull(), requestToUrl(new URL("http://localhost:8080/test")));
then(this.webClient).should().getPage(isNull(),
requestToUrl(new URL("http://localhost:8080/test")));
}
@Test
@@ -103,7 +104,8 @@ class LocalHostWebConnectionHtmlUnitDriverTests {
environment.setProperty("local.server.port", "8181");
LocalHostWebConnectionHtmlUnitDriver driver = new TestLocalHostWebConnectionHtmlUnitDriver(environment);
driver.get("/test");
verify(this.webClient).getPage(isNull(), requestToUrl(new URL("http://localhost:8181/test")));
then(this.webClient).should().getPage(isNull(),
requestToUrl(new URL("http://localhost:8181/test")));
}
private WebRequest requestToUrl(URL url) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,8 +36,8 @@ import org.springframework.test.web.reactive.server.WebTestClient;
import org.springframework.test.web.reactive.server.WebTestClient.Builder;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
/**
* Integration test for {@link WebTestClientContextCustomizer}.
@@ -56,7 +56,7 @@ class WebTestClientContextCustomizerIntegrationTests {
@Test
void test() {
verify(this.clientBuilderCustomizer).customize(any(Builder.class));
then(this.clientBuilderCustomizer).should().customize(any(Builder.class));
this.webTestClient.get().uri("/").exchange().expectBody(String.class).isEqualTo("hello");
}