This commit is contained in:
Stephane Nicoll
2017-12-12 11:57:24 +01:00
parent 97c91eee94
commit 23218add90
615 changed files with 2832 additions and 3224 deletions

View File

@@ -84,7 +84,7 @@ public abstract class AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests
}
@Test
public void annotationAttributesOverridePropertiesFile() throws Exception {
public void annotationAttributesOverridePropertiesFile() {
assertThat(this.value).isEqualTo(123);
}

View File

@@ -82,7 +82,7 @@ public abstract class AbstractSpringBootTestWebServerWebEnvironmentTests {
}
@Test
public void annotationAttributesOverridePropertiesFile() throws Exception {
public void annotationAttributesOverridePropertiesFile() {
assertThat(this.value).isEqualTo(123);
}

View File

@@ -46,12 +46,12 @@ public class ImportsContextCustomizerFactoryIntegrationTests {
private ImportedBean bean;
@Test
public void beanWasImported() throws Exception {
public void beanWasImported() {
assertThat(this.bean).isNotNull();
}
@Test(expected = NoSuchBeanDefinitionException.class)
public void testItselfIsNotABean() throws Exception {
public void testItselfIsNotABean() {
this.context.getBean(getClass());
}

View File

@@ -68,7 +68,7 @@ public class ImportsContextCustomizerFactoryTests {
}
@Test
public void contextCustomizerEqualsAndHashCode() throws Exception {
public void contextCustomizerEqualsAndHashCode() {
ContextCustomizer customizer1 = this.factory
.createContextCustomizer(TestWithImport.class, null);
ContextCustomizer customizer2 = this.factory
@@ -85,15 +85,14 @@ public class ImportsContextCustomizerFactoryTests {
}
@Test
public void getContextCustomizerWhenClassHasBeanMethodsShouldThrowException()
throws Exception {
public void getContextCustomizerWhenClassHasBeanMethodsShouldThrowException() {
this.thrown.expect(IllegalStateException.class);
this.thrown.expectMessage("Test classes cannot include @Bean methods");
this.factory.createContextCustomizer(TestWithImportAndBeanMethod.class, null);
}
@Test
public void contextCustomizerImportsBeans() throws Exception {
public void contextCustomizerImportsBeans() {
ContextCustomizer customizer = this.factory
.createContextCustomizer(TestWithImport.class, null);
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();

View File

@@ -43,14 +43,14 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ImportsContextCustomizerTests {
@Test
public void importSelectorsCouldUseAnyAnnotations() throws Exception {
public void importSelectorsCouldUseAnyAnnotations() {
assertThat(new ImportsContextCustomizer(FirstImportSelectorAnnotatedClass.class))
.isNotEqualTo(new ImportsContextCustomizer(
SecondImportSelectorAnnotatedClass.class));
}
@Test
public void determinableImportSelector() throws Exception {
public void determinableImportSelector() {
assertThat(new ImportsContextCustomizer(
FirstDeterminableImportSelectorAnnotatedClass.class))
.isEqualTo(new ImportsContextCustomizer(

View File

@@ -38,14 +38,14 @@ public class SpringBootConfigurationFinderTests {
private SpringBootConfigurationFinder finder = new SpringBootConfigurationFinder();
@Test
public void findFromClassWhenSourceIsNullShouldThrowException() throws Exception {
public void findFromClassWhenSourceIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Source must not be null");
this.finder.findFromClass((Class<?>) null);
}
@Test
public void findFromPackageWhenSourceIsNullShouldThrowException() throws Exception {
public void findFromPackageWhenSourceIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Source must not be null");
this.finder.findFromPackage((String) null);

View File

@@ -89,8 +89,7 @@ public class SpringBootContextLoaderTests {
assertKey(config, "variables", "foo=FOO\n bar=BAR");
}
private Map<String, Object> getEnvironmentProperties(Class<?> testClass)
throws Exception {
private Map<String, Object> getEnvironmentProperties(Class<?> testClass) {
TestContext context = new ExposedTestContextManager(testClass)
.getExposedTestContext();
MergedContextConfiguration config = (MergedContextConfiguration) ReflectionTestUtils

View File

@@ -43,7 +43,7 @@ public class SpringBootTestActiveProfileTests {
private ApplicationContext context;
@Test
public void profiles() throws Exception {
public void profiles() {
assertThat(this.context.getEnvironment().getActiveProfiles())
.containsExactly("override");
}

View File

@@ -44,7 +44,7 @@ public class SpringBootTestReactiveWebEnvironmentUserDefinedTestRestTemplateTest
extends AbstractSpringBootTestEmbeddedReactiveWebEnvironmentTests {
@Test
public void restTemplateIsUserDefined() throws Exception {
public void restTemplateIsUserDefined() {
assertThat(getContext().getBean("testRestTemplate"))
.isInstanceOf(RestTemplate.class);
}

View File

@@ -44,7 +44,7 @@ public class SpringBootTestUserDefinedTestRestTemplateTests
extends AbstractSpringBootTestWebServerWebEnvironmentTests {
@Test
public void restTemplateIsUserDefined() throws Exception {
public void restTemplateIsUserDefined() {
assertThat(getContext().getBean("testRestTemplate"))
.isInstanceOf(RestTemplate.class);
}

View File

@@ -54,7 +54,7 @@ public class SpringBootTestWebEnvironmentContextHierarchyTests {
private ApplicationContext context;
@Test
public void testShouldOnlyStartSingleServer() throws Exception {
public void testShouldOnlyStartSingleServer() {
ApplicationContext parent = this.context.getParent();
assertThat(this.context).isInstanceOf(WebApplicationContext.class);
assertThat(parent).isNotInstanceOf(WebApplicationContext.class);

View File

@@ -59,7 +59,7 @@ public class SpringBootTestWebEnvironmentMockTests {
private ServletContext servletContext;
@Test
public void annotationAttributesOverridePropertiesFile() throws Exception {
public void annotationAttributesOverridePropertiesFile() {
assertThat(this.value).isEqualTo(123);
}
@@ -71,13 +71,13 @@ public class SpringBootTestWebEnvironmentMockTests {
}
@Test
public void setsRequestContextHolder() throws Exception {
public void setsRequestContextHolder() {
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
assertThat(attributes).isNotNull();
}
@Test
public void resourcePath() throws Exception {
public void resourcePath() {
assertThat(ReflectionTestUtils.getField(this.servletContext, "resourceBasePath"))
.isEqualTo("src/main/webapp");
}

View File

@@ -50,7 +50,7 @@ public class SpringBootTestWebEnvironmentMockWithWebAppConfigurationTests {
private ServletContext servletContext;
@Test
public void resourcePath() throws Exception {
public void resourcePath() {
assertThat(ReflectionTestUtils.getField(this.servletContext, "resourceBasePath"))
.isEqualTo("src/mymain/mywebapp");
}

View File

@@ -44,7 +44,7 @@ public class SpringBootTestWebEnvironmentRandomPortTests
extends AbstractSpringBootTestWebServerWebEnvironmentTests {
@Test
public void testRestTemplateShouldUseBuilder() throws Exception {
public void testRestTemplateShouldUseBuilder() {
assertThat(getRestTemplate().getRestTemplate().getMessageConverters())
.hasAtLeastOneElementOfType(MyConverter.class);
}

View File

@@ -47,7 +47,7 @@ public class SpringBootTestWithClassesIntegrationTests {
private ApplicationContext context;
@Test
public void injectsOnlyConfig() throws Exception {
public void injectsOnlyConfig() {
assertThat(this.context.getBean(Config.class)).isNotNull();
this.thrown.expect(NoSuchBeanDefinitionException.class);
this.context.getBean(AdditionalConfig.class);

View File

@@ -49,7 +49,7 @@ public class SpringBootTestWithContextConfigurationIntegrationTests {
private ApplicationContext context;
@Test
public void injectsOnlyConfig() throws Exception {
public void injectsOnlyConfig() {
assertThat(this.context.getBean(Config.class)).isNotNull();
this.thrown.expect(NoSuchBeanDefinitionException.class);
this.context.getBean(AdditionalConfig.class);

View File

@@ -64,7 +64,7 @@ public class ApplicationContextAssertProviderTests {
}
@Test
public void getWhenTypeIsNullShouldThrowException() throws Exception {
public void getWhenTypeIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Type must not be null");
ApplicationContextAssertProvider.get(null, ApplicationContext.class,
@@ -72,7 +72,7 @@ public class ApplicationContextAssertProviderTests {
}
@Test
public void getWhenTypeIsClassShouldThrowException() throws Exception {
public void getWhenTypeIsClassShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Type must not be null");
ApplicationContextAssertProvider.get(null, ApplicationContext.class,
@@ -80,7 +80,7 @@ public class ApplicationContextAssertProviderTests {
}
@Test
public void getWhenContextTypeIsNullShouldThrowException() throws Exception {
public void getWhenContextTypeIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Type must be an interface");
ApplicationContextAssertProvider.get(
@@ -89,7 +89,7 @@ public class ApplicationContextAssertProviderTests {
}
@Test
public void getWhenContextTypeIsClassShouldThrowException() throws Exception {
public void getWhenContextTypeIsClassShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("ContextType must not be null");
ApplicationContextAssertProvider.get(TestAssertProviderApplicationContext.class,
@@ -97,7 +97,7 @@ public class ApplicationContextAssertProviderTests {
}
@Test
public void getWhenSupplierIsNullShouldThrowException() throws Exception {
public void getWhenSupplierIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("ContextType must be an interface");
ApplicationContextAssertProvider.get(TestAssertProviderApplicationContext.class,
@@ -105,8 +105,7 @@ public class ApplicationContextAssertProviderTests {
}
@Test
public void getWhenContextStartsShouldReturnProxyThatCallsRealMethods()
throws Exception {
public void getWhenContextStartsShouldReturnProxyThatCallsRealMethods() {
ApplicationContextAssertProvider<ApplicationContext> context = get(
this.mockContextSupplier);
assertThat((Object) context).isNotNull();
@@ -115,8 +114,7 @@ public class ApplicationContextAssertProviderTests {
}
@Test
public void getWhenContextFailsShouldReturnProxyThatThrowsExceptions()
throws Exception {
public void getWhenContextFailsShouldReturnProxyThatThrowsExceptions() {
ApplicationContextAssertProvider<ApplicationContext> context = get(
this.startupFailureSupplier);
assertThat((Object) context).isNotNull();
@@ -125,15 +123,14 @@ public class ApplicationContextAssertProviderTests {
}
@Test
public void getSourceContextWhenContextStartsShouldReturnSourceContext()
throws Exception {
public void getSourceContextWhenContextStartsShouldReturnSourceContext() {
ApplicationContextAssertProvider<ApplicationContext> context = get(
this.mockContextSupplier);
assertThat(context.getSourceApplicationContext()).isSameAs(this.mockContext);
}
@Test
public void getSourceContextWhenContextFailsShouldThrowException() throws Exception {
public void getSourceContextWhenContextFailsShouldThrowException() {
ApplicationContextAssertProvider<ApplicationContext> context = get(
this.startupFailureSupplier);
expectStartupFailure();
@@ -141,8 +138,7 @@ public class ApplicationContextAssertProviderTests {
}
@Test
public void getSourceContextOfTypeWhenContextStartsShouldReturnSourceContext()
throws Exception {
public void getSourceContextOfTypeWhenContextStartsShouldReturnSourceContext() {
ApplicationContextAssertProvider<ApplicationContext> context = get(
this.mockContextSupplier);
assertThat(context.getSourceApplicationContext(ApplicationContext.class))
@@ -150,8 +146,7 @@ public class ApplicationContextAssertProviderTests {
}
@Test
public void getSourceContextOfTypeWhenContextFailsToStartShouldThrowException()
throws Exception {
public void getSourceContextOfTypeWhenContextFailsToStartShouldThrowException() {
ApplicationContextAssertProvider<ApplicationContext> context = get(
this.startupFailureSupplier);
expectStartupFailure();
@@ -159,22 +154,21 @@ public class ApplicationContextAssertProviderTests {
}
@Test
public void getStartupFailureWhenContextStartsShouldReturnNull() throws Exception {
public void getStartupFailureWhenContextStartsShouldReturnNull() {
ApplicationContextAssertProvider<ApplicationContext> context = get(
this.mockContextSupplier);
assertThat(context.getStartupFailure()).isNull();
}
@Test
public void getStartupFailureWhenContextFailsToStartShouldReturnException()
throws Exception {
public void getStartupFailureWhenContextFailsToStartShouldReturnException() {
ApplicationContextAssertProvider<ApplicationContext> context = get(
this.startupFailureSupplier);
assertThat(context.getStartupFailure()).isEqualTo(this.startupFailure);
}
@Test
public void assertThatWhenContextStartsShouldReturnAssertions() throws Exception {
public void assertThatWhenContextStartsShouldReturnAssertions() {
ApplicationContextAssertProvider<ApplicationContext> context = get(
this.mockContextSupplier);
ApplicationContextAssert<ApplicationContext> contextAssert = assertThat(context);
@@ -183,7 +177,7 @@ public class ApplicationContextAssertProviderTests {
}
@Test
public void assertThatWhenContextFailsShouldReturnAssertions() throws Exception {
public void assertThatWhenContextFailsShouldReturnAssertions() {
ApplicationContextAssertProvider<ApplicationContext> context = get(
this.startupFailureSupplier);
ApplicationContextAssert<ApplicationContext> contextAssert = assertThat(context);
@@ -192,7 +186,7 @@ public class ApplicationContextAssertProviderTests {
}
@Test
public void toStringWhenContextStartsShouldReturnSimpleString() throws Exception {
public void toStringWhenContextStartsShouldReturnSimpleString() {
ApplicationContextAssertProvider<ApplicationContext> context = get(
this.mockContextSupplier);
assertThat(context.toString())
@@ -202,8 +196,7 @@ public class ApplicationContextAssertProviderTests {
}
@Test
public void toStringWhenContextFailsToStartShouldReturnSimpleString()
throws Exception {
public void toStringWhenContextFailsToStartShouldReturnSimpleString() {
ApplicationContextAssertProvider<ApplicationContext> context = get(
this.startupFailureSupplier);
assertThat(context.toString()).isEqualTo("Unstarted application context "
@@ -212,7 +205,7 @@ public class ApplicationContextAssertProviderTests {
}
@Test
public void closeShouldCloseContext() throws Exception {
public void closeShouldCloseContext() {
ApplicationContextAssertProvider<ApplicationContext> context = get(
this.mockContextSupplier);
context.close();

View File

@@ -48,23 +48,22 @@ public class SpringBootTestContextBootstrapperIntegrationTests {
boolean defaultTestExecutionListenersPostProcessorCalled = false;
@Test
public void findConfigAutomatically() throws Exception {
public void findConfigAutomatically() {
assertThat(this.config).isNotNull();
}
@Test
public void contextWasCreatedViaSpringApplication() throws Exception {
public void contextWasCreatedViaSpringApplication() {
assertThat(this.context.getId()).startsWith("application:");
}
@Test
public void testConfigurationWasApplied() throws Exception {
public void testConfigurationWasApplied() {
assertThat(this.context.getBean(ExampleBean.class)).isNotNull();
}
@Test
public void defaultTestExecutionListenersPostProcessorShouldBeCalled()
throws Exception {
public void defaultTestExecutionListenersPostProcessorShouldBeCalled() {
assertThat(this.defaultTestExecutionListenersPostProcessorCalled).isTrue();
}

View File

@@ -46,12 +46,12 @@ public class SpringBootTestContextBootstrapperWithContextConfigurationTests {
private SpringBootTestContextBootstrapperExampleConfig config;
@Test
public void findConfigAutomatically() throws Exception {
public void findConfigAutomatically() {
assertThat(this.config).isNotNull();
}
@Test
public void contextWasCreatedViaSpringApplication() throws Exception {
public void contextWasCreatedViaSpringApplication() {
assertThat(this.context.getId()).startsWith("application:");
}

View File

@@ -46,7 +46,7 @@ public class SpringBootTestContextBootstrapperWithInitializersTests {
private ApplicationContext context;
@Test
public void foundConfiguration() throws Exception {
public void foundConfiguration() {
Object bean = this.context
.getBean(SpringBootTestContextBootstrapperExampleConfig.class);
assertThat(bean).isNotNull();

View File

@@ -61,8 +61,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
}
@Test
public void runWithSystemPropertiesWhenContextFailsShouldRemoveProperties()
throws Exception {
public void runWithSystemPropertiesWhenContextFailsShouldRemoveProperties() {
String key = "test." + UUID.randomUUID();
assertThat(System.getProperties().containsKey(key)).isFalse();
get().withSystemProperties(key + "=value")
@@ -72,8 +71,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
}
@Test
public void runWithSystemPropertiesShouldRestoreOriginalProperties()
throws Exception {
public void runWithSystemPropertiesShouldRestoreOriginalProperties() {
String key = "test." + UUID.randomUUID();
System.setProperty(key, "value");
try {
@@ -89,8 +87,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
}
@Test
public void runWithSystemPropertiesWhenValueIsNullShouldRemoveProperty()
throws Exception {
public void runWithSystemPropertiesWhenValueIsNullShouldRemoveProperty() {
String key = "test." + UUID.randomUUID();
System.setProperty(key, "value");
try {
@@ -106,7 +103,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
}
@Test
public void runWithMultiplePropertyValuesShouldAllAllValues() throws Exception {
public void runWithMultiplePropertyValuesShouldAllAllValues() {
get().withPropertyValues("test.foo=1").withPropertyValues("test.bar=2")
.run((context) -> {
Environment environment = context.getEnvironment();
@@ -116,8 +113,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
}
@Test
public void runWithPropertyValuesWhenHasExistingShouldReplaceValue()
throws Exception {
public void runWithPropertyValuesWhenHasExistingShouldReplaceValue() {
get().withPropertyValues("test.foo=1").withPropertyValues("test.foo=2")
.run((context) -> {
Environment environment = context.getEnvironment();
@@ -126,28 +122,26 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
}
@Test
public void runWithConfigurationsShouldRegisterConfigurations() throws Exception {
public void runWithConfigurationsShouldRegisterConfigurations() {
get().withUserConfiguration(FooConfig.class)
.run((context) -> assertThat(context).hasBean("foo"));
}
@Test
public void runWithMultipleConfigurationsShouldRegisterAllConfigurations()
throws Exception {
public void runWithMultipleConfigurationsShouldRegisterAllConfigurations() {
get().withUserConfiguration(FooConfig.class)
.withConfiguration(UserConfigurations.of(BarConfig.class))
.run((context) -> assertThat(context).hasBean("foo").hasBean("bar"));
}
@Test
public void runWithFailedContextShouldReturnFailedAssertableContext()
throws Exception {
public void runWithFailedContextShouldReturnFailedAssertableContext() {
get().withUserConfiguration(FailingConfig.class)
.run((context) -> assertThat(context).hasFailed());
}
@Test
public void runWithClassLoaderShouldSetClassLoader() throws Exception {
public void runWithClassLoaderShouldSetClassLoader() {
get().withClassLoader(new FilteredClassLoader(Gson.class.getPackage().getName()))
.run((context) -> {
try {

View File

@@ -34,7 +34,7 @@ public class WebApplicationContextRunnerTests extends
AbstractApplicationContextRunnerTests<WebApplicationContextRunner, ConfigurableWebApplicationContext, AssertableWebApplicationContext> {
@Test
public void contextShouldHaveMockServletContext() throws Exception {
public void contextShouldHaveMockServletContext() {
get().run((context) -> assertThat(context.getServletContext())
.isInstanceOf(MockServletContext.class));
}

View File

@@ -96,14 +96,14 @@ public abstract class AbstractJsonMarshalTesterTests {
}
@Test
public void createWhenResourceLoadClassIsNullShouldThrowException() throws Exception {
public void createWhenResourceLoadClassIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("ResourceLoadClass must not be null");
createTester(null, ResolvableType.forClass(ExampleObject.class));
}
@Test
public void createWhenTypeIsNullShouldThrowException() throws Exception {
public void createWhenTypeIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Type must not be null");
createTester(getClass(), null);

View File

@@ -49,29 +49,29 @@ public class BasicJsonTesterTests {
private BasicJsonTester json = new BasicJsonTester(getClass());
@Test
public void createWhenResourceLoadClassIsNullShouldThrowException() throws Exception {
public void createWhenResourceLoadClassIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("ResourceLoadClass must not be null");
new BasicJsonTester(null);
}
@Test
public void fromJsonStringShouldReturnJsonContent() throws Exception {
public void fromJsonStringShouldReturnJsonContent() {
assertThat(this.json.from(JSON)).isEqualToJson("source.json");
}
@Test
public void fromResourceStringShouldReturnJsonContent() throws Exception {
public void fromResourceStringShouldReturnJsonContent() {
assertThat(this.json.from("source.json")).isEqualToJson(JSON);
}
@Test
public void fromResourceStringWithClassShouldReturnJsonContent() throws Exception {
public void fromResourceStringWithClassShouldReturnJsonContent() {
assertThat(this.json.from("source.json", getClass())).isEqualToJson(JSON);
}
@Test
public void fromByteArrayShouldReturnJsonContent() throws Exception {
public void fromByteArrayShouldReturnJsonContent() {
assertThat(this.json.from(JSON.getBytes())).isEqualToJson("source.json");
}
@@ -83,13 +83,13 @@ public class BasicJsonTesterTests {
}
@Test
public void fromInputStreamShouldReturnJsonContent() throws Exception {
public void fromInputStreamShouldReturnJsonContent() {
InputStream inputStream = new ByteArrayInputStream(JSON.getBytes());
assertThat(this.json.from(inputStream)).isEqualToJson("source.json");
}
@Test
public void fromResourceShouldReturnJsonContent() throws Exception {
public void fromResourceShouldReturnJsonContent() {
Resource resource = new ByteArrayResource(JSON.getBytes());
assertThat(this.json.from(resource)).isEqualToJson("source.json");
}

View File

@@ -67,37 +67,37 @@ public class JsonContentAssertTests {
public TemporaryFolder tempFolder = new TemporaryFolder();
@Test
public void isEqualToWhenStringIsMatchingShouldPass() throws Exception {
public void isEqualToWhenStringIsMatchingShouldPass() {
assertThat(forJson(SOURCE)).isEqualTo(LENIENT_SAME);
}
@Test(expected = AssertionError.class)
public void isEqualToWhenNullActualShouldFail() throws Exception {
public void isEqualToWhenNullActualShouldFail() {
assertThat(forJson(null)).isEqualTo(SOURCE);
}
@Test(expected = AssertionError.class)
public void isEqualToWhenStringIsNotMatchingShouldFail() throws Exception {
public void isEqualToWhenStringIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualTo(DIFFERENT);
}
@Test
public void isEqualToWhenResourcePathIsMatchingShouldPass() throws Exception {
public void isEqualToWhenResourcePathIsMatchingShouldPass() {
assertThat(forJson(SOURCE)).isEqualTo("lenient-same.json");
}
@Test(expected = AssertionError.class)
public void isEqualToWhenResourcePathIsNotMatchingShouldFail() throws Exception {
public void isEqualToWhenResourcePathIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualTo("different.json");
}
@Test
public void isEqualToWhenBytesAreMatchingShouldPass() throws Exception {
public void isEqualToWhenBytesAreMatchingShouldPass() {
assertThat(forJson(SOURCE)).isEqualTo(LENIENT_SAME.getBytes());
}
@Test(expected = AssertionError.class)
public void isEqualToWhenBytesAreNotMatchingShouldFail() throws Exception {
public void isEqualToWhenBytesAreNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualTo(DIFFERENT.getBytes());
}
@@ -132,49 +132,47 @@ public class JsonContentAssertTests {
}
@Test
public void isEqualToJsonWhenStringIsMatchingShouldPass() throws Exception {
public void isEqualToJsonWhenStringIsMatchingShouldPass() {
assertThat(forJson(SOURCE)).isEqualToJson(LENIENT_SAME);
}
@Test(expected = AssertionError.class)
public void isEqualToJsonWhenNullActualShouldFail() throws Exception {
public void isEqualToJsonWhenNullActualShouldFail() {
assertThat(forJson(null)).isEqualToJson(SOURCE);
}
@Test(expected = AssertionError.class)
public void isEqualToJsonWhenStringIsNotMatchingShouldFail() throws Exception {
public void isEqualToJsonWhenStringIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT);
}
@Test
public void isEqualToJsonWhenResourcePathIsMatchingShouldPass() throws Exception {
public void isEqualToJsonWhenResourcePathIsMatchingShouldPass() {
assertThat(forJson(SOURCE)).isEqualToJson("lenient-same.json");
}
@Test(expected = AssertionError.class)
public void isEqualToJsonWhenResourcePathIsNotMatchingShouldFail() throws Exception {
public void isEqualToJsonWhenResourcePathIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson("different.json");
}
@Test
public void isEqualToJsonWhenResourcePathAndClassIsMatchingShouldPass()
throws Exception {
public void isEqualToJsonWhenResourcePathAndClassIsMatchingShouldPass() {
assertThat(forJson(SOURCE)).isEqualToJson("lenient-same.json", getClass());
}
@Test(expected = AssertionError.class)
public void isEqualToJsonWhenResourcePathAndClassIsNotMatchingShouldFail()
throws Exception {
public void isEqualToJsonWhenResourcePathAndClassIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass());
}
@Test
public void isEqualToJsonWhenBytesAreMatchingShouldPass() throws Exception {
public void isEqualToJsonWhenBytesAreMatchingShouldPass() {
assertThat(forJson(SOURCE)).isEqualToJson(LENIENT_SAME.getBytes());
}
@Test(expected = AssertionError.class)
public void isEqualToJsonWhenBytesAreNotMatchingShouldFail() throws Exception {
public void isEqualToJsonWhenBytesAreNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes());
}
@@ -209,49 +207,43 @@ public class JsonContentAssertTests {
}
@Test
public void isStrictlyEqualToJsonWhenStringIsMatchingShouldPass() throws Exception {
public void isStrictlyEqualToJsonWhenStringIsMatchingShouldPass() {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson(SOURCE);
}
@Test(expected = AssertionError.class)
public void isStrictlyEqualToJsonWhenStringIsNotMatchingShouldFail()
throws Exception {
public void isStrictlyEqualToJsonWhenStringIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson(LENIENT_SAME);
}
@Test
public void isStrictlyEqualToJsonWhenResourcePathIsMatchingShouldPass()
throws Exception {
public void isStrictlyEqualToJsonWhenResourcePathIsMatchingShouldPass() {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson("source.json");
}
@Test(expected = AssertionError.class)
public void isStrictlyEqualToJsonWhenResourcePathIsNotMatchingShouldFail()
throws Exception {
public void isStrictlyEqualToJsonWhenResourcePathIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson("lenient-same.json");
}
@Test
public void isStrictlyEqualToJsonWhenResourcePathAndClassIsMatchingShouldPass()
throws Exception {
public void isStrictlyEqualToJsonWhenResourcePathAndClassIsMatchingShouldPass() {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson("source.json", getClass());
}
@Test(expected = AssertionError.class)
public void isStrictlyEqualToJsonWhenResourcePathAndClassIsNotMatchingShouldFail()
throws Exception {
public void isStrictlyEqualToJsonWhenResourcePathAndClassIsNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson("lenient-same.json",
getClass());
}
@Test
public void isStrictlyEqualToJsonWhenBytesAreMatchingShouldPass() throws Exception {
public void isStrictlyEqualToJsonWhenBytesAreMatchingShouldPass() {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson(SOURCE.getBytes());
}
@Test(expected = AssertionError.class)
public void isStrictlyEqualToJsonWhenBytesAreNotMatchingShouldFail()
throws Exception {
public void isStrictlyEqualToJsonWhenBytesAreNotMatchingShouldFail() {
assertThat(forJson(SOURCE)).isStrictlyEqualToJson(LENIENT_SAME.getBytes());
}
@@ -290,53 +282,47 @@ public class JsonContentAssertTests {
}
@Test
public void isEqualToJsonWhenStringIsMatchingAndLenientShouldPass() throws Exception {
public void isEqualToJsonWhenStringIsMatchingAndLenientShouldPass() {
assertThat(forJson(SOURCE)).isEqualToJson(LENIENT_SAME, JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
public void isEqualToJsonWhenStringIsNotMatchingAndLenientShouldFail()
throws Exception {
public void isEqualToJsonWhenStringIsNotMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT, JSONCompareMode.LENIENT);
}
@Test
public void isEqualToJsonWhenResourcePathIsMatchingAndLenientShouldPass()
throws Exception {
public void isEqualToJsonWhenResourcePathIsMatchingAndLenientShouldPass() {
assertThat(forJson(SOURCE)).isEqualToJson("lenient-same.json",
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
public void isEqualToJsonWhenResourcePathIsNotMatchingAndLenientShouldFail()
throws Exception {
public void isEqualToJsonWhenResourcePathIsNotMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson("different.json",
JSONCompareMode.LENIENT);
}
@Test
public void isEqualToJsonWhenResourcePathAndClassIsMatchingAndLenientShouldPass()
throws Exception {
public void isEqualToJsonWhenResourcePathAndClassIsMatchingAndLenientShouldPass() {
assertThat(forJson(SOURCE)).isEqualToJson("lenient-same.json", getClass(),
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
public void isEqualToJsonWhenResourcePathAndClassIsNotMatchingAndLenientShouldFail()
throws Exception {
public void isEqualToJsonWhenResourcePathAndClassIsNotMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass(),
JSONCompareMode.LENIENT);
}
@Test
public void isEqualToJsonWhenBytesAreMatchingAndLenientShouldPass() throws Exception {
public void isEqualToJsonWhenBytesAreMatchingAndLenientShouldPass() {
assertThat(forJson(SOURCE)).isEqualToJson(LENIENT_SAME.getBytes(),
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
public void isEqualToJsonWhenBytesAreNotMatchingAndLenientShouldFail()
throws Exception {
public void isEqualToJsonWhenBytesAreNotMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes(),
JSONCompareMode.LENIENT);
}
@@ -383,52 +369,44 @@ public class JsonContentAssertTests {
}
@Test
public void isEqualToJsonWhenStringIsMatchingAndComparatorShouldPass()
throws Exception {
public void isEqualToJsonWhenStringIsMatchingAndComparatorShouldPass() {
assertThat(forJson(SOURCE)).isEqualToJson(LENIENT_SAME, COMPARATOR);
}
@Test(expected = AssertionError.class)
public void isEqualToJsonWhenStringIsNotMatchingAndComparatorShouldFail()
throws Exception {
public void isEqualToJsonWhenStringIsNotMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT, COMPARATOR);
}
@Test
public void isEqualToJsonWhenResourcePathIsMatchingAndComparatorShouldPass()
throws Exception {
public void isEqualToJsonWhenResourcePathIsMatchingAndComparatorShouldPass() {
assertThat(forJson(SOURCE)).isEqualToJson("lenient-same.json", COMPARATOR);
}
@Test(expected = AssertionError.class)
public void isEqualToJsonWhenResourcePathIsNotMatchingAndComparatorShouldFail()
throws Exception {
public void isEqualToJsonWhenResourcePathIsNotMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson("different.json", COMPARATOR);
}
@Test
public void isEqualToJsonWhenResourcePathAndClassAreMatchingAndComparatorShouldPass()
throws Exception {
public void isEqualToJsonWhenResourcePathAndClassAreMatchingAndComparatorShouldPass() {
assertThat(forJson(SOURCE)).isEqualToJson("lenient-same.json", getClass(),
COMPARATOR);
}
@Test(expected = AssertionError.class)
public void isEqualToJsonWhenResourcePathAndClassAreNotMatchingAndComparatorShouldFail()
throws Exception {
public void isEqualToJsonWhenResourcePathAndClassAreNotMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass(),
COMPARATOR);
}
@Test
public void isEqualToJsonWhenBytesAreMatchingAndComparatorShouldPass()
throws Exception {
public void isEqualToJsonWhenBytesAreMatchingAndComparatorShouldPass() {
assertThat(forJson(SOURCE)).isEqualToJson(LENIENT_SAME.getBytes(), COMPARATOR);
}
@Test(expected = AssertionError.class)
public void isEqualToJsonWhenBytesAreNotMatchingAndComparatorShouldFail()
throws Exception {
public void isEqualToJsonWhenBytesAreNotMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes(), COMPARATOR);
}
@@ -472,37 +450,37 @@ public class JsonContentAssertTests {
}
@Test(expected = AssertionError.class)
public void isNotEqualToWhenStringIsMatchingShouldFail() throws Exception {
public void isNotEqualToWhenStringIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME);
}
@Test
public void isNotEqualToWhenNullActualShouldPass() throws Exception {
public void isNotEqualToWhenNullActualShouldPass() {
assertThat(forJson(null)).isNotEqualTo(SOURCE);
}
@Test
public void isNotEqualToWhenStringIsNotMatchingShouldPass() throws Exception {
public void isNotEqualToWhenStringIsNotMatchingShouldPass() {
assertThat(forJson(SOURCE)).isNotEqualTo(DIFFERENT);
}
@Test(expected = AssertionError.class)
public void isNotEqualToWhenResourcePathIsMatchingShouldFail() throws Exception {
public void isNotEqualToWhenResourcePathIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualTo("lenient-same.json");
}
@Test
public void isNotEqualToWhenResourcePathIsNotMatchingShouldPass() throws Exception {
public void isNotEqualToWhenResourcePathIsNotMatchingShouldPass() {
assertThat(forJson(SOURCE)).isNotEqualTo("different.json");
}
@Test(expected = AssertionError.class)
public void isNotEqualToWhenBytesAreMatchingShouldFail() throws Exception {
public void isNotEqualToWhenBytesAreMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME.getBytes());
}
@Test
public void isNotEqualToWhenBytesAreNotMatchingShouldPass() throws Exception {
public void isNotEqualToWhenBytesAreNotMatchingShouldPass() {
assertThat(forJson(SOURCE)).isNotEqualTo(DIFFERENT.getBytes());
}
@@ -537,50 +515,47 @@ public class JsonContentAssertTests {
}
@Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenStringIsMatchingShouldFail() throws Exception {
public void isNotEqualToJsonWhenStringIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME);
}
@Test
public void isNotEqualToJsonWhenNullActualShouldPass() throws Exception {
public void isNotEqualToJsonWhenNullActualShouldPass() {
assertThat(forJson(null)).isNotEqualToJson(SOURCE);
}
@Test
public void isNotEqualToJsonWhenStringIsNotMatchingShouldPass() throws Exception {
public void isNotEqualToJsonWhenStringIsNotMatchingShouldPass() {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT);
}
@Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenResourcePathIsMatchingShouldFail() throws Exception {
public void isNotEqualToJsonWhenResourcePathIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json");
}
@Test
public void isNotEqualToJsonWhenResourcePathIsNotMatchingShouldPass()
throws Exception {
public void isNotEqualToJsonWhenResourcePathIsNotMatchingShouldPass() {
assertThat(forJson(SOURCE)).isNotEqualToJson("different.json");
}
@Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenResourcePathAndClassAreMatchingShouldFail()
throws Exception {
public void isNotEqualToJsonWhenResourcePathAndClassAreMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass());
}
@Test
public void isNotEqualToJsonWhenResourcePathAndClassAreNotMatchingShouldPass()
throws Exception {
public void isNotEqualToJsonWhenResourcePathAndClassAreNotMatchingShouldPass() {
assertThat(forJson(SOURCE)).isNotEqualToJson("different.json", getClass());
}
@Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenBytesAreMatchingShouldFail() throws Exception {
public void isNotEqualToJsonWhenBytesAreMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes());
}
@Test
public void isNotEqualToJsonWhenBytesAreNotMatchingShouldPass() throws Exception {
public void isNotEqualToJsonWhenBytesAreNotMatchingShouldPass() {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT.getBytes());
}
@@ -616,51 +591,43 @@ public class JsonContentAssertTests {
}
@Test(expected = AssertionError.class)
public void isNotStrictlyEqualToJsonWhenStringIsMatchingShouldFail()
throws Exception {
public void isNotStrictlyEqualToJsonWhenStringIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE);
}
@Test
public void isNotStrictlyEqualToJsonWhenStringIsNotMatchingShouldPass()
throws Exception {
public void isNotStrictlyEqualToJsonWhenStringIsNotMatchingShouldPass() {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(LENIENT_SAME);
}
@Test(expected = AssertionError.class)
public void isNotStrictlyEqualToJsonWhenResourcePathIsMatchingShouldFail()
throws Exception {
public void isNotStrictlyEqualToJsonWhenResourcePathIsMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json");
}
@Test
public void isNotStrictlyEqualToJsonWhenResourcePathIsNotMatchingShouldPass()
throws Exception {
public void isNotStrictlyEqualToJsonWhenResourcePathIsNotMatchingShouldPass() {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("lenient-same.json");
}
@Test(expected = AssertionError.class)
public void isNotStrictlyEqualToJsonWhenResourcePathAndClassAreMatchingShouldFail()
throws Exception {
public void isNotStrictlyEqualToJsonWhenResourcePathAndClassAreMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json", getClass());
}
@Test
public void isNotStrictlyEqualToJsonWhenResourcePathAndClassAreNotMatchingShouldPass()
throws Exception {
public void isNotStrictlyEqualToJsonWhenResourcePathAndClassAreNotMatchingShouldPass() {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("lenient-same.json",
getClass());
}
@Test(expected = AssertionError.class)
public void isNotStrictlyEqualToJsonWhenBytesAreMatchingShouldFail()
throws Exception {
public void isNotStrictlyEqualToJsonWhenBytesAreMatchingShouldFail() {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE.getBytes());
}
@Test
public void isNotStrictlyEqualToJsonWhenBytesAreNotMatchingShouldPass()
throws Exception {
public void isNotStrictlyEqualToJsonWhenBytesAreNotMatchingShouldPass() {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(LENIENT_SAME.getBytes());
}
@@ -702,56 +669,48 @@ public class JsonContentAssertTests {
}
@Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenStringIsMatchingAndLenientShouldFail()
throws Exception {
public void isNotEqualToJsonWhenStringIsMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME,
JSONCompareMode.LENIENT);
}
@Test
public void isNotEqualToJsonWhenStringIsNotMatchingAndLenientShouldPass()
throws Exception {
public void isNotEqualToJsonWhenStringIsNotMatchingAndLenientShouldPass() {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT, JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenResourcePathIsMatchingAndLenientShouldFail()
throws Exception {
public void isNotEqualToJsonWhenResourcePathIsMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json",
JSONCompareMode.LENIENT);
}
@Test
public void isNotEqualToJsonWhenResourcePathIsNotMatchingAndLenientShouldPass()
throws Exception {
public void isNotEqualToJsonWhenResourcePathIsNotMatchingAndLenientShouldPass() {
assertThat(forJson(SOURCE)).isNotEqualToJson("different.json",
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenResourcePathAndClassAreMatchingAndLenientShouldFail()
throws Exception {
public void isNotEqualToJsonWhenResourcePathAndClassAreMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass(),
JSONCompareMode.LENIENT);
}
@Test
public void isNotEqualToJsonWhenResourcePathAndClassAreNotMatchingAndLenientShouldPass()
throws Exception {
public void isNotEqualToJsonWhenResourcePathAndClassAreNotMatchingAndLenientShouldPass() {
assertThat(forJson(SOURCE)).isNotEqualToJson("different.json", getClass(),
JSONCompareMode.LENIENT);
}
@Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenBytesAreMatchingAndLenientShouldFail()
throws Exception {
public void isNotEqualToJsonWhenBytesAreMatchingAndLenientShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes(),
JSONCompareMode.LENIENT);
}
@Test
public void isNotEqualToJsonWhenBytesAreNotMatchingAndLenientShouldPass()
throws Exception {
public void isNotEqualToJsonWhenBytesAreNotMatchingAndLenientShouldPass() {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT.getBytes(),
JSONCompareMode.LENIENT);
}
@@ -799,52 +758,44 @@ public class JsonContentAssertTests {
}
@Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenStringIsMatchingAndComparatorShouldFail()
throws Exception {
public void isNotEqualToJsonWhenStringIsMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME, COMPARATOR);
}
@Test
public void isNotEqualToJsonWhenStringIsNotMatchingAndComparatorShouldPass()
throws Exception {
public void isNotEqualToJsonWhenStringIsNotMatchingAndComparatorShouldPass() {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT, COMPARATOR);
}
@Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenResourcePathIsMatchingAndComparatorShouldFail()
throws Exception {
public void isNotEqualToJsonWhenResourcePathIsMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", COMPARATOR);
}
@Test
public void isNotEqualToJsonWhenResourcePathIsNotMatchingAndComparatorShouldPass()
throws Exception {
public void isNotEqualToJsonWhenResourcePathIsNotMatchingAndComparatorShouldPass() {
assertThat(forJson(SOURCE)).isNotEqualToJson("different.json", COMPARATOR);
}
@Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenResourcePathAndClassAreMatchingAndComparatorShouldFail()
throws Exception {
public void isNotEqualToJsonWhenResourcePathAndClassAreMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass(),
COMPARATOR);
}
@Test
public void isNotEqualToJsonWhenResourcePathAndClassAreNotMatchingAndComparatorShouldPass()
throws Exception {
public void isNotEqualToJsonWhenResourcePathAndClassAreNotMatchingAndComparatorShouldPass() {
assertThat(forJson(SOURCE)).isNotEqualToJson("different.json", getClass(),
COMPARATOR);
}
@Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenBytesAreMatchingAndComparatorShouldFail()
throws Exception {
public void isNotEqualToJsonWhenBytesAreMatchingAndComparatorShouldFail() {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes(), COMPARATOR);
}
@Test
public void isNotEqualToJsonWhenBytesAreNotMatchingAndComparatorShouldPass()
throws Exception {
public void isNotEqualToJsonWhenBytesAreNotMatchingAndComparatorShouldPass() {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT.getBytes(), COMPARATOR);
}
@@ -890,28 +841,28 @@ public class JsonContentAssertTests {
}
@Test
public void hasJsonPathValue() throws Exception {
public void hasJsonPathValue() {
assertThat(forJson(TYPES)).hasJsonPathValue("$.str");
}
@Test
public void hasJsonPathValueForAnEmptyArray() throws Exception {
public void hasJsonPathValueForAnEmptyArray() {
assertThat(forJson(TYPES)).hasJsonPathValue("$.emptyArray");
}
@Test
public void hasJsonPathValueForAnEmptyMap() throws Exception {
public void hasJsonPathValueForAnEmptyMap() {
assertThat(forJson(TYPES)).hasJsonPathValue("$.emptyMap");
}
@Test
public void hasJsonPathValueForIndefinitePathWithResults() throws Exception {
public void hasJsonPathValueForIndefinitePathWithResults() {
assertThat(forJson(SIMPSONS))
.hasJsonPathValue("$.familyMembers[?(@.name == 'Bart')]");
}
@Test
public void hasJsonPathValueForIndefinitePathWithEmptyResults() throws Exception {
public void hasJsonPathValueForIndefinitePathWithEmptyResults() {
String expression = "$.familyMembers[?(@.name == 'Dilbert')]";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage("No value at JSON path \"" + expression + "\"");
@@ -919,12 +870,12 @@ public class JsonContentAssertTests {
}
@Test
public void doesNotHaveJsonPathValue() throws Exception {
public void doesNotHaveJsonPathValue() {
assertThat(forJson(TYPES)).doesNotHaveJsonPathValue("$.bogus");
}
@Test
public void doesNotHaveJsonPathValueForAnEmptyArray() throws Exception {
public void doesNotHaveJsonPathValueForAnEmptyArray() {
String expression = "$.emptyArray";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage(
@@ -933,7 +884,7 @@ public class JsonContentAssertTests {
}
@Test
public void doesNotHaveJsonPathValueForAnEmptyMap() throws Exception {
public void doesNotHaveJsonPathValueForAnEmptyMap() {
String expression = "$.emptyMap";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage(
@@ -942,7 +893,7 @@ public class JsonContentAssertTests {
}
@Test
public void doesNotHaveJsonPathValueForIndefinitePathWithResults() throws Exception {
public void doesNotHaveJsonPathValueForIndefinitePathWithResults() {
String expression = "$.familyMembers[?(@.name == 'Bart')]";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage("Expected no value at JSON path \"" + expression
@@ -951,36 +902,34 @@ public class JsonContentAssertTests {
}
@Test
public void doesNotHaveJsonPathValueForIndefinitePathWithEmptyResults()
throws Exception {
public void doesNotHaveJsonPathValueForIndefinitePathWithEmptyResults() {
assertThat(forJson(SIMPSONS))
.doesNotHaveJsonPathValue("$.familyMembers[?(@.name == 'Dilbert')]");
}
@Test
public void hasEmptyJsonPathValueForAnEmptyString() throws Exception {
public void hasEmptyJsonPathValueForAnEmptyString() {
assertThat(forJson(TYPES)).hasEmptyJsonPathValue("$.emptyString");
}
@Test
public void hasEmptyJsonPathValueForAnEmptyArray() throws Exception {
public void hasEmptyJsonPathValueForAnEmptyArray() {
assertThat(forJson(TYPES)).hasEmptyJsonPathValue("$.emptyArray");
}
@Test
public void hasEmptyJsonPathValueForAnEmptyMap() throws Exception {
public void hasEmptyJsonPathValueForAnEmptyMap() {
assertThat(forJson(TYPES)).hasEmptyJsonPathValue("$.emptyMap");
}
@Test
public void hasEmptyJsonPathValueForIndefinitePathWithEmptyResults()
throws Exception {
public void hasEmptyJsonPathValueForIndefinitePathWithEmptyResults() {
assertThat(forJson(SIMPSONS))
.hasEmptyJsonPathValue("$.familyMembers[?(@.name == 'Dilbert')]");
}
@Test
public void hasEmptyJsonPathValueForIndefinitePathWithResults() throws Exception {
public void hasEmptyJsonPathValueForIndefinitePathWithResults() {
String expression = "$.familyMembers[?(@.name == 'Bart')]";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage("Expected an empty value at JSON path \"" + expression
@@ -989,7 +938,7 @@ public class JsonContentAssertTests {
}
@Test
public void hasEmptyJsonPathValueForWhitespace() throws Exception {
public void hasEmptyJsonPathValueForWhitespace() {
String expression = "$.whitespace";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage("Expected an empty value at JSON path \"" + expression
@@ -998,40 +947,38 @@ public class JsonContentAssertTests {
}
@Test
public void doesNotHaveEmptyJsonPathValueForString() throws Exception {
public void doesNotHaveEmptyJsonPathValueForString() {
assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue("$.str");
}
@Test
public void doesNotHaveEmptyJsonPathValueForNumber() throws Exception {
public void doesNotHaveEmptyJsonPathValueForNumber() {
assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue("$.num");
}
@Test
public void doesNotHaveEmptyJsonPathValueForBoolean() throws Exception {
public void doesNotHaveEmptyJsonPathValueForBoolean() {
assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue("$.bool");
}
@Test
public void doesNotHaveEmptyJsonPathValueForArray() throws Exception {
public void doesNotHaveEmptyJsonPathValueForArray() {
assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue("$.arr");
}
@Test
public void doesNotHaveEmptyJsonPathValueForMap() throws Exception {
public void doesNotHaveEmptyJsonPathValueForMap() {
assertThat(forJson(TYPES)).doesNotHaveEmptyJsonPathValue("$.colorMap");
}
@Test
public void doesNotHaveEmptyJsonPathValueForIndefinitePathWithResults()
throws Exception {
public void doesNotHaveEmptyJsonPathValueForIndefinitePathWithResults() {
assertThat(forJson(SIMPSONS))
.doesNotHaveEmptyJsonPathValue("$.familyMembers[?(@.name == 'Bart')]");
}
@Test
public void doesNotHaveEmptyJsonPathValueForIndefinitePathWithEmptyResults()
throws Exception {
public void doesNotHaveEmptyJsonPathValueForIndefinitePathWithEmptyResults() {
String expression = "$.familyMembers[?(@.name == 'Dilbert')]";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage("Expected a non-empty value at JSON path \""
@@ -1040,7 +987,7 @@ public class JsonContentAssertTests {
}
@Test
public void doesNotHaveEmptyJsonPathValueForAnEmptyString() throws Exception {
public void doesNotHaveEmptyJsonPathValueForAnEmptyString() {
String expression = "$.emptyString";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage("Expected a non-empty value at JSON path \""
@@ -1049,7 +996,7 @@ public class JsonContentAssertTests {
}
@Test
public void doesNotHaveEmptyJsonPathValueForForAnEmptyArray() throws Exception {
public void doesNotHaveEmptyJsonPathValueForForAnEmptyArray() {
String expression = "$.emptyArray";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage("Expected a non-empty value at JSON path \""
@@ -1058,7 +1005,7 @@ public class JsonContentAssertTests {
}
@Test
public void doesNotHaveEmptyJsonPathValueForAnEmptyMap() throws Exception {
public void doesNotHaveEmptyJsonPathValueForAnEmptyMap() {
String expression = "$.emptyMap";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage("Expected a non-empty value at JSON path \""
@@ -1067,17 +1014,17 @@ public class JsonContentAssertTests {
}
@Test
public void hasJsonPathStringValue() throws Exception {
public void hasJsonPathStringValue() {
assertThat(forJson(TYPES)).hasJsonPathStringValue("$.str");
}
@Test
public void hasJsonPathStringValueForAnEmptyString() throws Exception {
public void hasJsonPathStringValueForAnEmptyString() {
assertThat(forJson(TYPES)).hasJsonPathStringValue("$.emptyString");
}
@Test
public void hasJsonPathStringValueForNonString() throws Exception {
public void hasJsonPathStringValueForNonString() {
String expression = "$.bool";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage(
@@ -1086,12 +1033,12 @@ public class JsonContentAssertTests {
}
@Test
public void hasJsonPathNumberValue() throws Exception {
public void hasJsonPathNumberValue() {
assertThat(forJson(TYPES)).hasJsonPathNumberValue("$.num");
}
@Test
public void hasJsonPathNumberValueForNonNumber() throws Exception {
public void hasJsonPathNumberValueForNonNumber() {
String expression = "$.bool";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage(
@@ -1100,12 +1047,12 @@ public class JsonContentAssertTests {
}
@Test
public void hasJsonPathBooleanValue() throws Exception {
public void hasJsonPathBooleanValue() {
assertThat(forJson(TYPES)).hasJsonPathBooleanValue("$.bool");
}
@Test
public void hasJsonPathBooleanValueForNonBoolean() throws Exception {
public void hasJsonPathBooleanValueForNonBoolean() {
String expression = "$.num";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage(
@@ -1114,17 +1061,17 @@ public class JsonContentAssertTests {
}
@Test
public void hasJsonPathArrayValue() throws Exception {
public void hasJsonPathArrayValue() {
assertThat(forJson(TYPES)).hasJsonPathArrayValue("$.arr");
}
@Test
public void hasJsonPathArrayValueForAnEmptyArray() throws Exception {
public void hasJsonPathArrayValueForAnEmptyArray() {
assertThat(forJson(TYPES)).hasJsonPathArrayValue("$.emptyArray");
}
@Test
public void hasJsonPathArrayValueForNonArray() throws Exception {
public void hasJsonPathArrayValueForNonArray() {
String expression = "$.str";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage(
@@ -1133,17 +1080,17 @@ public class JsonContentAssertTests {
}
@Test
public void hasJsonPathMapValue() throws Exception {
public void hasJsonPathMapValue() {
assertThat(forJson(TYPES)).hasJsonPathMapValue("$.colorMap");
}
@Test
public void hasJsonPathMapValueForAnEmptyMap() throws Exception {
public void hasJsonPathMapValueForAnEmptyMap() {
assertThat(forJson(TYPES)).hasJsonPathMapValue("$.emptyMap");
}
@Test
public void hasJsonPathMapValueForNonMap() throws Exception {
public void hasJsonPathMapValueForNonMap() {
String expression = "$.str";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage(
@@ -1152,34 +1099,34 @@ public class JsonContentAssertTests {
}
@Test
public void extractingJsonPathValue() throws Exception {
public void extractingJsonPathValue() {
assertThat(forJson(TYPES)).extractingJsonPathValue("@.str").isEqualTo("foo");
}
@Test
public void extractingJsonPathValueForMissing() throws Exception {
public void extractingJsonPathValueForMissing() {
assertThat(forJson(TYPES)).extractingJsonPathValue("@.bogus").isNull();
}
@Test
public void extractingJsonPathStringValue() throws Exception {
public void extractingJsonPathStringValue() {
assertThat(forJson(TYPES)).extractingJsonPathStringValue("@.str")
.isEqualTo("foo");
}
@Test
public void extractingJsonPathStringValueForMissing() throws Exception {
public void extractingJsonPathStringValueForMissing() {
assertThat(forJson(TYPES)).extractingJsonPathStringValue("@.bogus").isNull();
}
@Test
public void extractingJsonPathStringValueForEmptyString() throws Exception {
public void extractingJsonPathStringValueForEmptyString() {
assertThat(forJson(TYPES)).extractingJsonPathStringValue("@.emptyString")
.isEmpty();
}
@Test
public void extractingJsonPathStringValueForWrongType() throws Exception {
public void extractingJsonPathStringValueForWrongType() {
String expression = "$.num";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage(
@@ -1188,17 +1135,17 @@ public class JsonContentAssertTests {
}
@Test
public void extractingJsonPathNumberValue() throws Exception {
public void extractingJsonPathNumberValue() {
assertThat(forJson(TYPES)).extractingJsonPathNumberValue("@.num").isEqualTo(5);
}
@Test
public void extractingJsonPathNumberValueForMissing() throws Exception {
public void extractingJsonPathNumberValueForMissing() {
assertThat(forJson(TYPES)).extractingJsonPathNumberValue("@.bogus").isNull();
}
@Test
public void extractingJsonPathNumberValueForWrongType() throws Exception {
public void extractingJsonPathNumberValueForWrongType() {
String expression = "$.str";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage(
@@ -1207,17 +1154,17 @@ public class JsonContentAssertTests {
}
@Test
public void extractingJsonPathBooleanValue() throws Exception {
public void extractingJsonPathBooleanValue() {
assertThat(forJson(TYPES)).extractingJsonPathBooleanValue("@.bool").isTrue();
}
@Test
public void extractingJsonPathBooleanValueForMissing() throws Exception {
public void extractingJsonPathBooleanValueForMissing() {
assertThat(forJson(TYPES)).extractingJsonPathBooleanValue("@.bogus").isNull();
}
@Test
public void extractingJsonPathBooleanValueForWrongType() throws Exception {
public void extractingJsonPathBooleanValueForWrongType() {
String expression = "$.str";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage("Expected a boolean at JSON path \"" + expression
@@ -1226,23 +1173,23 @@ public class JsonContentAssertTests {
}
@Test
public void extractingJsonPathArrayValue() throws Exception {
public void extractingJsonPathArrayValue() {
assertThat(forJson(TYPES)).extractingJsonPathArrayValue("@.arr")
.containsExactly(42);
}
@Test
public void extractingJsonPathArrayValueForMissing() throws Exception {
public void extractingJsonPathArrayValueForMissing() {
assertThat(forJson(TYPES)).extractingJsonPathArrayValue("@.bogus").isNull();
}
@Test
public void extractingJsonPathArrayValueForEmpty() throws Exception {
public void extractingJsonPathArrayValueForEmpty() {
assertThat(forJson(TYPES)).extractingJsonPathArrayValue("@.emptyArray").isEmpty();
}
@Test
public void extractingJsonPathArrayValueForWrongType() throws Exception {
public void extractingJsonPathArrayValueForWrongType() {
String expression = "$.str";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage(
@@ -1251,23 +1198,23 @@ public class JsonContentAssertTests {
}
@Test
public void extractingJsonPathMapValue() throws Exception {
public void extractingJsonPathMapValue() {
assertThat(forJson(TYPES)).extractingJsonPathMapValue("@.colorMap")
.contains(entry("red", "rojo"));
}
@Test
public void extractingJsonPathMapValueForMissing() throws Exception {
public void extractingJsonPathMapValueForMissing() {
assertThat(forJson(TYPES)).extractingJsonPathMapValue("@.bogus").isNull();
}
@Test
public void extractingJsonPathMapValueForEmpty() throws Exception {
public void extractingJsonPathMapValueForEmpty() {
assertThat(forJson(TYPES)).extractingJsonPathMapValue("@.emptyMap").isEmpty();
}
@Test
public void extractingJsonPathMapValueForWrongType() throws Exception {
public void extractingJsonPathMapValueForWrongType() {
String expression = "$.str";
this.thrown.expect(AssertionError.class);
this.thrown.expectMessage(
@@ -1276,7 +1223,7 @@ public class JsonContentAssertTests {
}
@Test
public void isNullWhenActualIsNullShouldPass() throws Exception {
public void isNullWhenActualIsNullShouldPass() {
assertThat(forJson(null)).isNull();
}
@@ -1286,11 +1233,11 @@ public class JsonContentAssertTests {
return file;
}
private InputStream createInputStream(String content) throws IOException {
private InputStream createInputStream(String content) {
return new ByteArrayInputStream(content.getBytes());
}
private Resource createResource(String content) throws IOException {
private Resource createResource(String content) {
return new ByteArrayResource(content.getBytes());
}

View File

@@ -40,48 +40,48 @@ public class JsonContentTests {
public ExpectedException thrown = ExpectedException.none();
@Test
public void createWhenResourceLoadClassIsNullShouldThrowException() throws Exception {
public void createWhenResourceLoadClassIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("ResourceLoadClass must not be null");
new JsonContent<ExampleObject>(null, TYPE, JSON);
}
@Test
public void createWhenJsonIsNullShouldThrowException() throws Exception {
public void createWhenJsonIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("JSON must not be null");
new JsonContent<ExampleObject>(getClass(), TYPE, null);
}
@Test
public void createWhenTypeIsNullShouldCreateContent() throws Exception {
public void createWhenTypeIsNullShouldCreateContent() {
JsonContent<ExampleObject> content = new JsonContent<>(getClass(), null, JSON);
assertThat(content).isNotNull();
}
@Test
@SuppressWarnings("deprecation")
public void assertThatShouldReturnJsonContentAssert() throws Exception {
public void assertThatShouldReturnJsonContentAssert() {
JsonContent<ExampleObject> content = new JsonContent<>(getClass(), TYPE, JSON);
assertThat(content.assertThat()).isInstanceOf(JsonContentAssert.class);
}
@Test
public void getJsonShouldReturnJson() throws Exception {
public void getJsonShouldReturnJson() {
JsonContent<ExampleObject> content = new JsonContent<>(getClass(), TYPE, JSON);
assertThat(content.getJson()).isEqualTo(JSON);
}
@Test
public void toStringWhenHasTypeShouldReturnString() throws Exception {
public void toStringWhenHasTypeShouldReturnString() {
JsonContent<ExampleObject> content = new JsonContent<>(getClass(), TYPE, JSON);
assertThat(content.toString())
.isEqualTo("JsonContent " + JSON + " created from " + TYPE);
}
@Test
public void toStringWhenHasNoTypeShouldReturnString() throws Exception {
public void toStringWhenHasNoTypeShouldReturnString() {
JsonContent<ExampleObject> content = new JsonContent<>(getClass(), null, JSON);
assertThat(content.toString()).isEqualTo("JsonContent " + JSON);
}

View File

@@ -41,34 +41,34 @@ public class ObjectContentAssertTests {
}
@Test
public void isEqualToWhenObjectsAreEqualShouldPass() throws Exception {
public void isEqualToWhenObjectsAreEqualShouldPass() {
assertThat(forObject(SOURCE)).isEqualTo(SOURCE);
}
@Test(expected = AssertionError.class)
public void isEqualToWhenObjectsAreDifferentShouldFail() throws Exception {
public void isEqualToWhenObjectsAreDifferentShouldFail() {
assertThat(forObject(SOURCE)).isEqualTo(DIFFERENT);
}
@Test
public void asArrayForArrayShouldReturnObjectArrayAssert() throws Exception {
public void asArrayForArrayShouldReturnObjectArrayAssert() {
ExampleObject[] source = new ExampleObject[] { SOURCE };
assertThat(forObject(source)).asArray().containsExactly(SOURCE);
}
@Test(expected = AssertionError.class)
public void asArrayForNonArrayShouldFail() throws Exception {
public void asArrayForNonArrayShouldFail() {
assertThat(forObject(SOURCE)).asArray();
}
@Test
public void asMapForMapShouldReturnMapAssert() throws Exception {
public void asMapForMapShouldReturnMapAssert() {
Map<String, ExampleObject> source = Collections.singletonMap("a", SOURCE);
assertThat(forObject(source)).asMap().containsEntry("a", SOURCE);
}
@Test(expected = AssertionError.class)
public void asMapForNonMapShouldFail() throws Exception {
public void asMapForNonMapShouldFail() {
assertThat(forObject(SOURCE)).asMap();
}

View File

@@ -40,39 +40,39 @@ public class ObjectContentTests {
public ExpectedException thrown = ExpectedException.none();
@Test
public void createWhenObjectIsNullShouldThrowException() throws Exception {
public void createWhenObjectIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Object must not be null");
new ObjectContent<ExampleObject>(TYPE, null);
}
@Test
public void createWhenTypeIsNullShouldCreateContent() throws Exception {
public void createWhenTypeIsNullShouldCreateContent() {
ObjectContent<ExampleObject> content = new ObjectContent<>(null, OBJECT);
assertThat(content).isNotNull();
}
@Test
public void assertThatShouldReturnObjectContentAssert() throws Exception {
public void assertThatShouldReturnObjectContentAssert() {
ObjectContent<ExampleObject> content = new ObjectContent<>(TYPE, OBJECT);
assertThat(content.assertThat()).isInstanceOf(ObjectContentAssert.class);
}
@Test
public void getObjectShouldReturnObject() throws Exception {
public void getObjectShouldReturnObject() {
ObjectContent<ExampleObject> content = new ObjectContent<>(TYPE, OBJECT);
assertThat(content.getObject()).isEqualTo(OBJECT);
}
@Test
public void toStringWhenHasTypeShouldReturnString() throws Exception {
public void toStringWhenHasTypeShouldReturnString() {
ObjectContent<ExampleObject> content = new ObjectContent<>(TYPE, OBJECT);
assertThat(content.toString())
.isEqualTo("ObjectContent " + OBJECT + " created from " + TYPE);
}
@Test
public void toStringWhenHasNoTypeShouldReturnString() throws Exception {
public void toStringWhenHasNoTypeShouldReturnString() {
ObjectContent<ExampleObject> content = new ObjectContent<>(null, OBJECT);
assertThat(content.toString()).isEqualTo("ObjectContent " + OBJECT);
}

View File

@@ -64,7 +64,7 @@ public class DefinitionsParserTests {
}
@Test
public void parseMockBeanAttributes() throws Exception {
public void parseMockBeanAttributes() {
this.parser.parse(MockBeanAttributes.class);
assertThat(getDefinitions()).hasSize(1);
MockDefinition definition = getMockDefinition(0);
@@ -79,7 +79,7 @@ public class DefinitionsParserTests {
}
@Test
public void parseMockBeanOnClassAndField() throws Exception {
public void parseMockBeanOnClassAndField() {
this.parser.parse(MockBeanOnClassAndField.class);
assertThat(getDefinitions()).hasSize(2);
MockDefinition classDefinition = getMockDefinition(0);
@@ -95,7 +95,7 @@ public class DefinitionsParserTests {
}
@Test
public void parseMockBeanInferClassToMock() throws Exception {
public void parseMockBeanInferClassToMock() {
this.parser.parse(MockBeanInferClassToMock.class);
assertThat(getDefinitions()).hasSize(1);
assertThat(getMockDefinition(0).getTypeToMock().resolve())
@@ -103,14 +103,14 @@ public class DefinitionsParserTests {
}
@Test
public void parseMockBeanMissingClassToMock() throws Exception {
public void parseMockBeanMissingClassToMock() {
this.thrown.expect(IllegalStateException.class);
this.thrown.expectMessage("Unable to deduce type to mock");
this.parser.parse(MockBeanMissingClassToMock.class);
}
@Test
public void parseMockBeanMultipleClasses() throws Exception {
public void parseMockBeanMultipleClasses() {
this.parser.parse(MockBeanMultipleClasses.class);
assertThat(getDefinitions()).hasSize(2);
assertThat(getMockDefinition(0).getTypeToMock().resolve())
@@ -120,7 +120,7 @@ public class DefinitionsParserTests {
}
@Test
public void parseMockBeanMultipleClassesWithName() throws Exception {
public void parseMockBeanMultipleClassesWithName() {
this.thrown.expect(IllegalStateException.class);
this.thrown.expectMessage(
"The name attribute can only be used when mocking a single class");
@@ -146,7 +146,7 @@ public class DefinitionsParserTests {
}
@Test
public void parseSpyBeanAttributes() throws Exception {
public void parseSpyBeanAttributes() {
this.parser.parse(SpyBeanAttributes.class);
assertThat(getDefinitions()).hasSize(1);
SpyDefinition definition = getSpyDefinition(0);
@@ -158,7 +158,7 @@ public class DefinitionsParserTests {
}
@Test
public void parseSpyBeanOnClassAndField() throws Exception {
public void parseSpyBeanOnClassAndField() {
this.parser.parse(SpyBeanOnClassAndField.class);
assertThat(getDefinitions()).hasSize(2);
SpyDefinition classDefinition = getSpyDefinition(0);
@@ -174,7 +174,7 @@ public class DefinitionsParserTests {
}
@Test
public void parseSpyBeanInferClassToMock() throws Exception {
public void parseSpyBeanInferClassToMock() {
this.parser.parse(SpyBeanInferClassToMock.class);
assertThat(getDefinitions()).hasSize(1);
assertThat(getSpyDefinition(0).getTypeToSpy().resolve())
@@ -182,14 +182,14 @@ public class DefinitionsParserTests {
}
@Test
public void parseSpyBeanMissingClassToMock() throws Exception {
public void parseSpyBeanMissingClassToMock() {
this.thrown.expect(IllegalStateException.class);
this.thrown.expectMessage("Unable to deduce type to spy");
this.parser.parse(SpyBeanMissingClassToMock.class);
}
@Test
public void parseSpyBeanMultipleClasses() throws Exception {
public void parseSpyBeanMultipleClasses() {
this.parser.parse(SpyBeanMultipleClasses.class);
assertThat(getDefinitions()).hasSize(2);
assertThat(getSpyDefinition(0).getTypeToSpy().resolve())
@@ -199,7 +199,7 @@ public class DefinitionsParserTests {
}
@Test
public void parseSpyBeanMultipleClassesWithName() throws Exception {
public void parseSpyBeanMultipleClassesWithName() {
this.thrown.expect(IllegalStateException.class);
this.thrown.expectMessage(
"The name attribute can only be used when spying a single class");

View File

@@ -70,7 +70,7 @@ public class MockBeanForBeanFactoryIntegrationTests {
static class TestFactoryBean implements FactoryBean<TestBean> {
@Override
public TestBean getObject() throws Exception {
public TestBean getObject() {
return () -> "normal";
}

View File

@@ -42,7 +42,7 @@ public class MockBeanOnConfigurationClassForExistingBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testMocking() throws Exception {
public void testMocking() {
given(this.caller.getService().greeting()).willReturn("Boot");
assertThat(this.caller.sayGreeting()).isEqualTo("I say Boot");
}

View File

@@ -42,7 +42,7 @@ public class MockBeanOnConfigurationClassForNewBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testMocking() throws Exception {
public void testMocking() {
given(this.caller.getService().greeting()).willReturn("Boot");
assertThat(this.caller.sayGreeting()).isEqualTo("I say Boot");
}

View File

@@ -46,7 +46,7 @@ public class MockBeanOnConfigurationFieldForExistingBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testMocking() throws Exception {
public void testMocking() {
given(this.config.exampleService.greeting()).willReturn("Boot");
assertThat(this.caller.sayGreeting()).isEqualTo("I say Boot");
}

View File

@@ -45,7 +45,7 @@ public class MockBeanOnConfigurationFieldForNewBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testMocking() throws Exception {
public void testMocking() {
given(this.config.exampleService.greeting()).willReturn("Boot");
assertThat(this.caller.sayGreeting()).isEqualTo("I say Boot");
}

View File

@@ -48,7 +48,7 @@ public class MockBeanOnContextHierarchyIntegrationTests {
private ChildConfig childConfig;
@Test
public void testMocking() throws Exception {
public void testMocking() {
ApplicationContext context = this.childConfig.getContext();
ApplicationContext parentContext = context.getParent();
assertThat(parentContext.getBeanNamesForType(ExampleService.class)).hasSize(1);

View File

@@ -49,7 +49,7 @@ public class MockBeanOnScopedProxyTests {
private ExampleServiceCaller caller;
@Test
public void testMocking() throws Exception {
public void testMocking() {
given(this.caller.getService().greeting()).willReturn("Boot");
assertThat(this.caller.sayGreeting()).isEqualTo("I say Boot");
}

View File

@@ -43,7 +43,7 @@ public class MockBeanOnTestClassForExistingBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testMocking() throws Exception {
public void testMocking() {
given(this.caller.getService().greeting()).willReturn("Boot");
assertThat(this.caller.sayGreeting()).isEqualTo("I say Boot");
}

View File

@@ -42,7 +42,7 @@ public class MockBeanOnTestClassForNewBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testMocking() throws Exception {
public void testMocking() {
given(this.caller.getService().greeting()).willReturn("Boot");
assertThat(this.caller.sayGreeting()).isEqualTo("I say Boot");
}

View File

@@ -48,7 +48,7 @@ public class MockBeanOnTestFieldForExistingBeanCacheIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testMocking() throws Exception {
public void testMocking() {
given(this.exampleService.greeting()).willReturn("Boot");
assertThat(this.caller.sayGreeting()).isEqualTo("I say Boot");
}

View File

@@ -45,7 +45,7 @@ public class MockBeanOnTestFieldForExistingBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testMocking() throws Exception {
public void testMocking() {
given(this.exampleService.greeting()).willReturn("Boot");
assertThat(this.caller.sayGreeting()).isEqualTo("I say Boot");
}

View File

@@ -54,7 +54,7 @@ public class MockBeanOnTestFieldForExistingBeanWithQualifierIntegrationTests {
private ApplicationContext applicationContext;
@Test
public void testMocking() throws Exception {
public void testMocking() {
this.caller.sayGreeting();
verify(this.service).greeting();
}

View File

@@ -44,7 +44,7 @@ public class MockBeanOnTestFieldForNewBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testMocking() throws Exception {
public void testMocking() {
given(this.exampleService.greeting()).willReturn("Boot");
assertThat(this.caller.sayGreeting()).isEqualTo("I say Boot");
}

View File

@@ -53,7 +53,7 @@ public class MockBeanWithAopProxyTests {
private DateService dateService;
@Test
public void verifyShouldUseProxyTarget() throws Exception {
public void verifyShouldUseProxyTarget() {
given(this.dateService.getDate(false)).willReturn(1L);
Long d1 = this.dateService.getDate(false);
assertThat(d1).isEqualTo(1L);

View File

@@ -47,7 +47,7 @@ public class MockBeanWithGenericsOnTestFieldForNewBeanIntegrationTests {
private ExampleGenericServiceCaller caller;
@Test
public void testMocking() throws Exception {
public void testMocking() {
given(this.exampleIntegerService.greeting()).willReturn(200);
given(this.exampleStringService.greeting()).willReturn("Boot");
assertThat(this.caller.sayGreeting()).isEqualTo("I say 200 Boot");

View File

@@ -44,14 +44,14 @@ public class MockDefinitionTests {
public ExpectedException thrown = ExpectedException.none();
@Test
public void classToMockMustNotBeNull() throws Exception {
public void classToMockMustNotBeNull() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("TypeToMock must not be null");
new MockDefinition(null, null, null, null, false, null, null);
}
@Test
public void createWithDefaults() throws Exception {
public void createWithDefaults() {
MockDefinition definition = new MockDefinition(null, EXAMPLE_SERVICE_TYPE, null,
null, false, null, null);
assertThat(definition.getName()).isNull();
@@ -64,7 +64,7 @@ public class MockDefinitionTests {
}
@Test
public void createExplicit() throws Exception {
public void createExplicit() {
QualifierDefinition qualifier = mock(QualifierDefinition.class);
MockDefinition definition = new MockDefinition("name", EXAMPLE_SERVICE_TYPE,
new Class<?>[] { ExampleExtraInterface.class },
@@ -81,7 +81,7 @@ public class MockDefinitionTests {
}
@Test
public void createMock() throws Exception {
public void createMock() {
MockDefinition definition = new MockDefinition("name", EXAMPLE_SERVICE_TYPE,
new Class<?>[] { ExampleExtraInterface.class },
Answers.RETURNS_SMART_NULLS, true, MockReset.BEFORE, null);

View File

@@ -64,7 +64,7 @@ public class MockResetTests {
}
@Test
public void apply() throws Exception {
public void apply() {
ExampleService mock = mock(ExampleService.class,
MockReset.apply(MockReset.AFTER, withSettings()));
assertThat(MockReset.get(mock)).isEqualTo(MockReset.AFTER);

View File

@@ -39,22 +39,21 @@ public class MockitoContextCustomizerFactoryTests {
}
@Test
public void getContextCustomizerWithoutAnnotationReturnsCustomizer()
throws Exception {
public void getContextCustomizerWithoutAnnotationReturnsCustomizer() {
ContextCustomizer customizer = this.factory
.createContextCustomizer(NoMockBeanAnnotation.class, null);
assertThat(customizer).isNotNull();
}
@Test
public void getContextCustomizerWithAnnotationReturnsCustomizer() throws Exception {
public void getContextCustomizerWithAnnotationReturnsCustomizer() {
ContextCustomizer customizer = this.factory
.createContextCustomizer(WithMockBeanAnnotation.class, null);
assertThat(customizer).isNotNull();
}
@Test
public void getContextCustomizerUsesMocksAsCacheKey() throws Exception {
public void getContextCustomizerUsesMocksAsCacheKey() {
ContextCustomizer customizer = this.factory
.createContextCustomizer(WithMockBeanAnnotation.class, null);
assertThat(customizer).isNotNull();

View File

@@ -140,7 +140,7 @@ public class MockitoPostProcessorTests {
static class TestFactoryBean implements FactoryBean<Object> {
@Override
public Object getObject() throws Exception {
public Object getObject() {
return new TestBean();
}

View File

@@ -57,33 +57,31 @@ public class QualifierDefinitionTests {
}
@Test
public void forElementFieldIsNullShouldReturnNull() throws Exception {
public void forElementFieldIsNullShouldReturnNull() {
assertThat(QualifierDefinition.forElement((Field) null)).isNull();
}
@Test
public void forElementWhenElementIsNotFieldShouldReturnNull() throws Exception {
public void forElementWhenElementIsNotFieldShouldReturnNull() {
assertThat(QualifierDefinition.forElement(getClass())).isNull();
}
@Test
public void forElementWhenElementIsFieldWithNoQualifiersShouldReturnNull()
throws Exception {
public void forElementWhenElementIsFieldWithNoQualifiersShouldReturnNull() {
QualifierDefinition definition = QualifierDefinition
.forElement(ReflectionUtils.findField(ConfigA.class, "noQualifier"));
assertThat(definition).isNull();
}
@Test
public void forElementWhenElementIsFieldWithQualifierShouldReturnDefinition()
throws Exception {
public void forElementWhenElementIsFieldWithQualifierShouldReturnDefinition() {
QualifierDefinition definition = QualifierDefinition
.forElement(ReflectionUtils.findField(ConfigA.class, "directQualifier"));
assertThat(definition).isNotNull();
}
@Test
public void matchesShouldCallBeanFactory() throws Exception {
public void matchesShouldCallBeanFactory() {
Field field = ReflectionUtils.findField(ConfigA.class, "directQualifier");
QualifierDefinition qualifierDefinition = QualifierDefinition.forElement(field);
qualifierDefinition.matches(this.beanFactory, "bean");
@@ -94,7 +92,7 @@ public class QualifierDefinitionTests {
}
@Test
public void applyToShouldSetQualifierElement() throws Exception {
public void applyToShouldSetQualifierElement() {
Field field = ReflectionUtils.findField(ConfigA.class, "directQualifier");
QualifierDefinition qualifierDefinition = QualifierDefinition.forElement(field);
RootBeanDefinition definition = new RootBeanDefinition();
@@ -103,7 +101,7 @@ public class QualifierDefinitionTests {
}
@Test
public void hashCodeAndEqualsShouldWorkOnDifferentClasses() throws Exception {
public void hashCodeAndEqualsShouldWorkOnDifferentClasses() {
QualifierDefinition directQualifier1 = QualifierDefinition
.forElement(ReflectionUtils.findField(ConfigA.class, "directQualifier"));
QualifierDefinition directQualifier2 = QualifierDefinition

View File

@@ -107,7 +107,7 @@ public class ResetMocksTestExecutionListenerTests {
static class BrokenFactoryBean implements FactoryBean<String> {
@Override
public String getObject() throws Exception {
public String getObject() {
throw new IllegalStateException();
}

View File

@@ -41,7 +41,7 @@ public class SpyBeanOnConfigurationClassForExistingBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testSpying() throws Exception {
public void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.caller.getService()).greeting();
}

View File

@@ -41,7 +41,7 @@ public class SpyBeanOnConfigurationClassForNewBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testSpying() throws Exception {
public void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.caller.getService()).greeting();
}

View File

@@ -46,7 +46,7 @@ public class SpyBeanOnConfigurationFieldForExistingBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testSpying() throws Exception {
public void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.config.exampleService).greeting();
}

View File

@@ -45,7 +45,7 @@ public class SpyBeanOnConfigurationFieldForNewBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testSpying() throws Exception {
public void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.config.exampleService).greeting();
}

View File

@@ -49,7 +49,7 @@ public class SpyBeanOnContextHierarchyIntegrationTests {
private ChildConfig childConfig;
@Test
public void testSpying() throws Exception {
public void testSpying() {
ApplicationContext context = this.childConfig.getContext();
ApplicationContext parentContext = context.getParent();
assertThat(parentContext.getBeanNamesForType(ExampleService.class)).hasSize(1);

View File

@@ -42,7 +42,7 @@ public class SpyBeanOnTestClassForExistingBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testSpying() throws Exception {
public void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.caller.getService()).greeting();
}

View File

@@ -42,7 +42,7 @@ public class SpyBeanOnTestClassForNewBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testSpying() throws Exception {
public void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.caller.getService()).greeting();
}

View File

@@ -48,7 +48,7 @@ public class SpyBeanOnTestFieldForExistingBeanCacheIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testSpying() throws Exception {
public void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.caller.getService()).greeting();
}

View File

@@ -45,7 +45,7 @@ public class SpyBeanOnTestFieldForExistingBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testSpying() throws Exception {
public void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.caller.getService()).greeting();
}

View File

@@ -50,7 +50,7 @@ public class SpyBeanOnTestFieldForExistingGenericBeanIntegrationTests {
private ExampleGenericServiceCaller caller;
@Test
public void testSpying() throws Exception {
public void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say 123 simple");
verify(this.exampleService).greeting();
}

View File

@@ -48,7 +48,7 @@ public class SpyBeanOnTestFieldForMultipleExistingBeansWithOnePrimaryIntegration
private ExampleGenericStringServiceCaller caller;
@Test
public void testSpying() throws Exception {
public void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say two");
assertThat(Mockito.mockingDetails(this.spy).getMockCreationSettings()
.getMockName().toString()).isEqualTo("two");

View File

@@ -44,7 +44,7 @@ public class SpyBeanOnTestFieldForNewBeanIntegrationTests {
private ExampleServiceCaller caller;
@Test
public void testSpying() throws Exception {
public void testSpying() {
assertThat(this.caller.sayGreeting()).isEqualTo("I say simple");
verify(this.caller.getService()).greeting();
}

View File

@@ -53,7 +53,7 @@ public class SpyBeanWithAopProxyAndNotProxyTargetAwareTests {
private DateService dateService;
@Test(expected = UnfinishedVerificationException.class)
public void verifyShouldUseProxyTarget() throws Exception {
public void verifyShouldUseProxyTarget() {
this.dateService.getDate(false);
verify(this.dateService, times(1)).getDate(false);
verify(this.dateService, times(1)).getDate(eq(false));

View File

@@ -42,7 +42,7 @@ public class SpyBeanWithNameOnTestFieldForMultipleExistingBeansTests {
private SimpleExampleStringGenericService spy;
@Test
public void testSpying() throws Exception {
public void testSpying() {
MockingDetails mockingDetails = Mockito.mockingDetails(this.spy);
assertThat(mockingDetails.isSpy()).isTrue();
assertThat(mockingDetails.getMockCreationSettings().getMockName().toString())

View File

@@ -45,14 +45,14 @@ public class SpyDefinitionTests {
public ExpectedException thrown = ExpectedException.none();
@Test
public void classToSpyMustNotBeNull() throws Exception {
public void classToSpyMustNotBeNull() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("TypeToSpy must not be null");
new SpyDefinition(null, null, null, true, null);
}
@Test
public void createWithDefaults() throws Exception {
public void createWithDefaults() {
SpyDefinition definition = new SpyDefinition(null, REAL_SERVICE_TYPE, null, true,
null);
assertThat(definition.getName()).isNull();
@@ -63,7 +63,7 @@ public class SpyDefinitionTests {
}
@Test
public void createExplicit() throws Exception {
public void createExplicit() {
QualifierDefinition qualifier = mock(QualifierDefinition.class);
SpyDefinition definition = new SpyDefinition("name", REAL_SERVICE_TYPE,
MockReset.BEFORE, false, qualifier);
@@ -75,7 +75,7 @@ public class SpyDefinitionTests {
}
@Test
public void createSpy() throws Exception {
public void createSpy() {
SpyDefinition definition = new SpyDefinition("name", REAL_SERVICE_TYPE,
MockReset.BEFORE, true, null);
RealExampleService spy = definition.createSpy(new RealExampleService("hello"));
@@ -88,7 +88,7 @@ public class SpyDefinitionTests {
}
@Test
public void createSpyWhenNullInstanceShouldThrowException() throws Exception {
public void createSpyWhenNullInstanceShouldThrowException() {
SpyDefinition definition = new SpyDefinition("name", REAL_SERVICE_TYPE,
MockReset.BEFORE, true, null);
this.thrown.expect(IllegalArgumentException.class);
@@ -97,7 +97,7 @@ public class SpyDefinitionTests {
}
@Test
public void createSpyWhenWrongInstanceShouldThrowException() throws Exception {
public void createSpyWhenWrongInstanceShouldThrowException() {
SpyDefinition definition = new SpyDefinition("name", REAL_SERVICE_TYPE,
MockReset.BEFORE, true, null);
this.thrown.expect(IllegalArgumentException.class);
@@ -106,7 +106,7 @@ public class SpyDefinitionTests {
}
@Test
public void createSpyTwice() throws Exception {
public void createSpyTwice() {
SpyDefinition definition = new SpyDefinition("name", REAL_SERVICE_TYPE,
MockReset.BEFORE, true, null);
Object instance = new RealExampleService("hello");

View File

@@ -32,13 +32,13 @@ public class OutputCaptureTests {
public OutputCapture outputCapture = new OutputCapture();
@Test
public void toStringShouldReturnAllCapturedOutput() throws Exception {
public void toStringShouldReturnAllCapturedOutput() {
System.out.println("Hello World");
assertThat(this.outputCapture.toString()).contains("Hello World");
}
@Test
public void reset() throws Exception {
public void reset() {
System.out.println("Hello");
this.outputCapture.reset();
System.out.println("World");

View File

@@ -37,8 +37,7 @@ public class TestPropertyValuesTests {
private final ConfigurableEnvironment environment = new StandardEnvironment();
@Test
public void applyToEnvironmentShouldAttachConfigurationPropertySource()
throws Exception {
public void applyToEnvironmentShouldAttachConfigurationPropertySource() {
TestPropertyValues.of("foo.bar=baz").applyTo(this.environment);
PropertySource<?> source = this.environment.getPropertySources()
.get("configurationProperties");
@@ -46,14 +45,14 @@ public class TestPropertyValuesTests {
}
@Test
public void applyToDefaultPropertySource() throws Exception {
public void applyToDefaultPropertySource() {
TestPropertyValues.of("foo.bar=baz", "hello.world=hi").applyTo(this.environment);
assertThat(this.environment.getProperty("foo.bar")).isEqualTo("baz");
assertThat(this.environment.getProperty("hello.world")).isEqualTo("hi");
}
@Test
public void applyToSystemPropertySource() throws Exception {
public void applyToSystemPropertySource() {
TestPropertyValues.of("FOO_BAR=BAZ").applyTo(this.environment,
Type.SYSTEM_ENVIRONMENT);
assertThat(this.environment.getProperty("foo.bar")).isEqualTo("BAZ");
@@ -63,15 +62,14 @@ public class TestPropertyValuesTests {
}
@Test
public void applyToWithSpecificName() throws Exception {
public void applyToWithSpecificName() {
TestPropertyValues.of("foo.bar=baz").applyTo(this.environment, Type.MAP, "other");
assertThat(this.environment.getPropertySources().get("other")).isNotNull();
assertThat(this.environment.getProperty("foo.bar")).isEqualTo("baz");
}
@Test
public void applyToExistingNameAndDifferentTypeShouldOverrideExistingOne()
throws Exception {
public void applyToExistingNameAndDifferentTypeShouldOverrideExistingOne() {
TestPropertyValues.of("foo.bar=baz", "hello.world=hi").applyTo(this.environment,
Type.MAP, "other");
TestPropertyValues.of("FOO_BAR=BAZ").applyTo(this.environment,
@@ -83,7 +81,7 @@ public class TestPropertyValuesTests {
}
@Test
public void applyToExistingNameAndSameTypeShouldMerge() throws Exception {
public void applyToExistingNameAndSameTypeShouldMerge() {
TestPropertyValues.of("foo.bar=baz", "hello.world=hi").applyTo(this.environment,
Type.MAP);
TestPropertyValues.of("foo.bar=new").applyTo(this.environment, Type.MAP);
@@ -92,7 +90,7 @@ public class TestPropertyValuesTests {
}
@Test
public void andShouldChainAndAddSingleKeyValue() throws Exception {
public void andShouldChainAndAddSingleKeyValue() {
TestPropertyValues.of("foo.bar=baz").and("hello.world=hi").and("bling.blah=bing")
.applyTo(this.environment, Type.MAP);
assertThat(this.environment.getProperty("foo.bar")).isEqualTo("baz");
@@ -101,7 +99,7 @@ public class TestPropertyValuesTests {
}
@Test
public void applyToSystemPropertiesShouldSetSystemProperties() throws Exception {
public void applyToSystemPropertiesShouldSetSystemProperties() {
TestPropertyValues.of("foo=bar").applyToSystemProperties(() -> {
assertThat(System.getProperty("foo")).isEqualTo("bar");
return null;
@@ -109,7 +107,7 @@ public class TestPropertyValuesTests {
}
@Test
public void applyToSystemPropertiesShouldRestoreSystemProperties() throws Exception {
public void applyToSystemPropertiesShouldRestoreSystemProperties() {
System.setProperty("foo", "bar1");
System.clearProperty("baz");
try {
@@ -127,8 +125,7 @@ public class TestPropertyValuesTests {
}
@Test
public void applyToSystemPropertiesWhenValueIsNullShouldRemoveProperty()
throws Exception {
public void applyToSystemPropertiesWhenValueIsNullShouldRemoveProperty() {
System.setProperty("foo", "bar1");
try {
TestPropertyValues.of("foo").applyToSystemProperties(() -> {

View File

@@ -51,7 +51,7 @@ public class LocalHostUriTemplateHandlerTests {
}
@Test
public void getRootUriShouldUseLocalServerPort() throws Exception {
public void getRootUriShouldUseLocalServerPort() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("local.server.port", "1234");
LocalHostUriTemplateHandler handler = new LocalHostUriTemplateHandler(
@@ -60,7 +60,7 @@ public class LocalHostUriTemplateHandlerTests {
}
@Test
public void getRootUriWhenLocalServerPortMissingShouldUsePort8080() throws Exception {
public void getRootUriWhenLocalServerPortMissingShouldUsePort8080() {
MockEnvironment environment = new MockEnvironment();
LocalHostUriTemplateHandler handler = new LocalHostUriTemplateHandler(
environment);
@@ -76,7 +76,7 @@ public class LocalHostUriTemplateHandlerTests {
}
@Test
public void getRootUriShouldUseContextPath() throws Exception {
public void getRootUriShouldUseContextPath() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("server.servlet.context-path", "/foo");
LocalHostUriTemplateHandler handler = new LocalHostUriTemplateHandler(

View File

@@ -49,7 +49,7 @@ public class MockServerRestTemplateCustomizerTests {
}
@Test
public void createShouldUseSimpleRequestExpectationManager() throws Exception {
public void createShouldUseSimpleRequestExpectationManager() {
MockServerRestTemplateCustomizer customizer = new MockServerRestTemplateCustomizer();
customizer.customize(new RestTemplate());
assertThat(customizer.getServer()).extracting("expectationManager")
@@ -57,15 +57,14 @@ public class MockServerRestTemplateCustomizerTests {
}
@Test
public void createWhenExpectationManagerClassIsNullShouldThrowException()
throws Exception {
public void createWhenExpectationManagerClassIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("ExpectationManager must not be null");
new MockServerRestTemplateCustomizer(null);
}
@Test
public void createShouldUseExpectationManagerClass() throws Exception {
public void createShouldUseExpectationManagerClass() {
MockServerRestTemplateCustomizer customizer = new MockServerRestTemplateCustomizer(
UnorderedRequestExpectationManager.class);
customizer.customize(new RestTemplate());
@@ -74,7 +73,7 @@ public class MockServerRestTemplateCustomizerTests {
}
@Test
public void detectRootUriShouldDefaultToTrue() throws Exception {
public void detectRootUriShouldDefaultToTrue() {
MockServerRestTemplateCustomizer customizer = new MockServerRestTemplateCustomizer(
UnorderedRequestExpectationManager.class);
customizer.customize(
@@ -84,7 +83,7 @@ public class MockServerRestTemplateCustomizerTests {
}
@Test
public void setDetectRootUriShouldDisableRootUriDetection() throws Exception {
public void setDetectRootUriShouldDisableRootUriDetection() {
this.customizer.setDetectRootUri(false);
this.customizer.customize(
new RestTemplateBuilder().rootUri("http://example.com").build());
@@ -94,7 +93,7 @@ public class MockServerRestTemplateCustomizerTests {
}
@Test
public void customizeShouldBindServer() throws Exception {
public void customizeShouldBindServer() {
RestTemplate template = new RestTemplateBuilder(this.customizer).build();
this.customizer.getServer().expect(requestTo("/test")).andRespond(withSuccess());
template.getForEntity("/test", String.class);
@@ -102,7 +101,7 @@ public class MockServerRestTemplateCustomizerTests {
}
@Test
public void getServerWhenNoServersAreBoundShouldThrowException() throws Exception {
public void getServerWhenNoServersAreBoundShouldThrowException() {
this.thrown.expect(IllegalStateException.class);
this.thrown.expectMessage("Unable to return a single MockRestServiceServer since "
+ "MockServerRestTemplateCustomizer has not been bound to a RestTemplate");
@@ -110,8 +109,7 @@ public class MockServerRestTemplateCustomizerTests {
}
@Test
public void getServerWhenMultipleServersAreBoundShouldThrowException()
throws Exception {
public void getServerWhenMultipleServersAreBoundShouldThrowException() {
this.customizer.customize(new RestTemplate());
this.customizer.customize(new RestTemplate());
this.thrown.expect(IllegalStateException.class);
@@ -121,7 +119,7 @@ public class MockServerRestTemplateCustomizerTests {
}
@Test
public void getServerWhenSingleServerIsBoundShouldReturnServer() throws Exception {
public void getServerWhenSingleServerIsBoundShouldReturnServer() {
RestTemplate template = new RestTemplate();
this.customizer.customize(template);
assertThat(this.customizer.getServer())
@@ -129,7 +127,7 @@ public class MockServerRestTemplateCustomizerTests {
}
@Test
public void getServerWhenRestTemplateIsFoundShouldReturnServer() throws Exception {
public void getServerWhenRestTemplateIsFoundShouldReturnServer() {
RestTemplate template1 = new RestTemplate();
RestTemplate template2 = new RestTemplate();
this.customizer.customize(template1);
@@ -140,7 +138,7 @@ public class MockServerRestTemplateCustomizerTests {
}
@Test
public void getServerWhenRestTemplateIsNotFoundShouldReturnNull() throws Exception {
public void getServerWhenRestTemplateIsNotFoundShouldReturnNull() {
RestTemplate template1 = new RestTemplate();
RestTemplate template2 = new RestTemplate();
this.customizer.customize(template1);
@@ -149,7 +147,7 @@ public class MockServerRestTemplateCustomizerTests {
}
@Test
public void getServersShouldReturnServers() throws Exception {
public void getServersShouldReturnServers() {
RestTemplate template1 = new RestTemplate();
RestTemplate template2 = new RestTemplate();
this.customizer.customize(template1);
@@ -158,7 +156,7 @@ public class MockServerRestTemplateCustomizerTests {
}
@Test
public void getExpectationManagersShouldReturnExpectationManagers() throws Exception {
public void getExpectationManagersShouldReturnExpectationManagers() {
RestTemplate template1 = new RestTemplate();
RestTemplate template2 = new RestTemplate();
this.customizer.customize(template1);

View File

@@ -71,22 +71,21 @@ public class RootUriRequestExpectationManagerTests {
}
@Test
public void createWhenRootUriIsNullShouldThrowException() throws Exception {
public void createWhenRootUriIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("RootUri must not be null");
new RootUriRequestExpectationManager(null, this.delegate);
}
@Test
public void createWhenExpectationManagerIsNullShouldThrowException()
throws Exception {
public void createWhenExpectationManagerIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("ExpectationManager must not be null");
new RootUriRequestExpectationManager(this.uri, null);
}
@Test
public void expectRequestShouldDelegateToExpectationManager() throws Exception {
public void expectRequestShouldDelegateToExpectationManager() {
ExpectedCount count = mock(ExpectedCount.class);
RequestMatcher requestMatcher = mock(RequestMatcher.class);
this.manager.expectRequest(count, requestMatcher);
@@ -128,13 +127,13 @@ public class RootUriRequestExpectationManagerTests {
}
@Test
public void resetRequestShouldDelegateToExpectationManager() throws Exception {
public void resetRequestShouldDelegateToExpectationManager() {
this.manager.reset();
verify(this.delegate).reset();
}
@Test
public void bindToShouldReturnMockRestServiceServer() throws Exception {
public void bindToShouldReturnMockRestServiceServer() {
RestTemplate restTemplate = new RestTemplateBuilder().build();
MockRestServiceServer bound = RootUriRequestExpectationManager
.bindTo(restTemplate);
@@ -142,8 +141,7 @@ public class RootUriRequestExpectationManagerTests {
}
@Test
public void bindToWithExpectationManagerShouldReturnMockRestServiceServer()
throws Exception {
public void bindToWithExpectationManagerShouldReturnMockRestServiceServer() {
RestTemplate restTemplate = new RestTemplateBuilder().build();
MockRestServiceServer bound = RootUriRequestExpectationManager
.bindTo(restTemplate, this.delegate);
@@ -151,8 +149,7 @@ public class RootUriRequestExpectationManagerTests {
}
@Test
public void forRestTemplateWhenUsingRootUriTemplateHandlerShouldReturnRootUriRequestExpectationManager()
throws Exception {
public void forRestTemplateWhenUsingRootUriTemplateHandlerShouldReturnRootUriRequestExpectationManager() {
RestTemplate restTemplate = new RestTemplateBuilder().rootUri(this.uri).build();
RequestExpectationManager actual = RootUriRequestExpectationManager
.forRestTemplate(restTemplate, this.delegate);
@@ -161,8 +158,7 @@ public class RootUriRequestExpectationManagerTests {
}
@Test
public void forRestTemplateWhenNotUsingRootUriTemplateHandlerShouldReturnOriginalRequestExpectationManager()
throws Exception {
public void forRestTemplateWhenNotUsingRootUriTemplateHandlerShouldReturnOriginalRequestExpectationManager() {
RestTemplate restTemplate = new RestTemplateBuilder().build();
RequestExpectationManager actual = RootUriRequestExpectationManager
.forRestTemplate(restTemplate, this.delegate);

View File

@@ -113,7 +113,7 @@ public class TestRestTemplateTests {
}
@Test
public void options() throws Exception {
public void options() {
TestRestTemplate template = new TestRestTemplate(
HttpClientOption.ENABLE_REDIRECTS);
CustomHttpComponentsClientHttpRequestFactory factory = (CustomHttpComponentsClientHttpRequestFactory) template
@@ -123,7 +123,7 @@ public class TestRestTemplateTests {
}
@Test
public void restOperationsAreAvailable() throws Exception {
public void restOperationsAreAvailable() {
RestTemplate delegate = mock(RestTemplate.class);
given(delegate.getUriTemplateHandler())
.willReturn(new DefaultUriBuilderFactory());
@@ -132,7 +132,7 @@ public class TestRestTemplateTests {
@Override
public void doWith(Method method)
throws IllegalArgumentException, IllegalAccessException {
throws IllegalArgumentException {
Method equivalent = ReflectionUtils.findMethod(TestRestTemplate.class,
method.getName(), method.getParameterTypes());
assertThat(equivalent).as("Method %s not found", method).isNotNull();
@@ -223,7 +223,7 @@ public class TestRestTemplateTests {
}
@Test
public void withBasicAuthDoesNotResetErrorHandler() throws Exception {
public void withBasicAuthDoesNotResetErrorHandler() {
TestRestTemplate originalTemplate = new TestRestTemplate("foo", "bar");
ResponseErrorHandler errorHandler = mock(ResponseErrorHandler.class);
originalTemplate.getRestTemplate().setErrorHandler(errorHandler);

View File

@@ -59,7 +59,7 @@ public class LocalHostWebClientTests {
}
@Test
public void createWhenEnvironmentIsNullWillThrowException() throws Exception {
public void createWhenEnvironmentIsNullWillThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Environment must not be null");
new LocalHostWebClient(null);

View File

@@ -59,31 +59,28 @@ public class LocalHostWebConnectionHtmlUnitDriverTests {
}
@Test
public void createWhenEnvironmentIsNullWillThrowException() throws Exception {
public void createWhenEnvironmentIsNullWillThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Environment must not be null");
new LocalHostWebConnectionHtmlUnitDriver(null);
}
@Test
public void createWithJavascriptFlagWhenEnvironmentIsNullWillThrowException()
throws Exception {
public void createWithJavascriptFlagWhenEnvironmentIsNullWillThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Environment must not be null");
new LocalHostWebConnectionHtmlUnitDriver(null, true);
}
@Test
public void createWithBrowserVersionWhenEnvironmentIsNullWillThrowException()
throws Exception {
public void createWithBrowserVersionWhenEnvironmentIsNullWillThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Environment must not be null");
new LocalHostWebConnectionHtmlUnitDriver(null, BrowserVersion.CHROME);
}
@Test
public void createWithCapabilitiesWhenEnvironmentIsNullWillThrowException()
throws Exception {
public void createWithCapabilitiesWhenEnvironmentIsNullWillThrowException() {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Environment must not be null");
Capabilities capabilities = mock(Capabilities.class);