Use AssertJ's hasSize() for collections and maps
Achieved via a global search-and-replace.
This commit is contained in:
@@ -271,9 +271,9 @@ class MockHttpServletRequestTests {
|
||||
params.put("key2", "value2");
|
||||
params.put("key3", new String[] { "value3A", "value3B" });
|
||||
request.addParameters(params);
|
||||
assertThat(request.getParameterMap().size()).isEqualTo(3);
|
||||
assertThat(request.getParameterMap()).hasSize(3);
|
||||
request.removeAllParameters();
|
||||
assertThat(request.getParameterMap().size()).isEqualTo(0);
|
||||
assertThat(request.getParameterMap()).hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -252,7 +252,7 @@ class MockHttpServletResponseTests {
|
||||
response.addHeader(headerName, "value1");
|
||||
Collection<String> responseHeaders = response.getHeaderNames();
|
||||
assertThat(responseHeaders).isNotNull();
|
||||
assertThat(responseHeaders.size()).isEqualTo(1);
|
||||
assertThat(responseHeaders).hasSize(1);
|
||||
assertThat(responseHeaders.iterator().next()).as("HTTP header casing not being preserved").isEqualTo(headerName);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,14 +87,14 @@ class MockMultipartHttpServletRequestTests {
|
||||
while (fileIter.hasNext()) {
|
||||
fileNames.add(fileIter.next());
|
||||
}
|
||||
assertThat(fileNames.size()).isEqualTo(2);
|
||||
assertThat(fileNames).hasSize(2);
|
||||
assertThat(fileNames.contains("file1")).isTrue();
|
||||
assertThat(fileNames.contains("file2")).isTrue();
|
||||
MultipartFile file1 = request.getFile("file1");
|
||||
MultipartFile file2 = request.getFile("file2");
|
||||
Map<String, MultipartFile> fileMap = request.getFileMap();
|
||||
List<String> fileMapKeys = new ArrayList<>(fileMap.keySet());
|
||||
assertThat(fileMapKeys.size()).isEqualTo(2);
|
||||
assertThat(fileMapKeys).hasSize(2);
|
||||
assertThat(fileMap.get("file1")).isEqualTo(file1);
|
||||
assertThat(fileMap.get("file2")).isEqualTo(file2);
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ class MockServletContextTests {
|
||||
void getServletRegistrations() {
|
||||
Map<String, ? extends ServletRegistration> servletRegistrations = servletContext.getServletRegistrations();
|
||||
assertThat(servletRegistrations).isNotNull();
|
||||
assertThat(servletRegistrations.size()).isEqualTo(0);
|
||||
assertThat(servletRegistrations).hasSize(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,7 +198,7 @@ class MockServletContextTests {
|
||||
void getFilterRegistrations() {
|
||||
Map<String, ? extends FilterRegistration> filterRegistrations = servletContext.getFilterRegistrations();
|
||||
assertThat(filterRegistrations).isNotNull();
|
||||
assertThat(filterRegistrations.size()).isEqualTo(0);
|
||||
assertThat(filterRegistrations).hasSize(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class InitializerConfiguredViaMetaAnnotationTests {
|
||||
|
||||
@Test
|
||||
public void beansFromInitializerAndComposedAnnotation() {
|
||||
assertThat(strings.size()).isEqualTo(2);
|
||||
assertThat(strings).hasSize(2);
|
||||
assertThat(foo).isEqualTo("foo");
|
||||
assertThat(bar).isEqualTo("bar");
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class ContextLoaderUtilsConfigurationAttributesTests extends AbstractContextConf
|
||||
Class<BareAnnotations> testClass = BareAnnotations.class;
|
||||
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
|
||||
assertThat(attributesList).isNotNull();
|
||||
assertThat(attributesList.size()).isEqualTo(1);
|
||||
assertThat(attributesList).hasSize(1);
|
||||
assertAttributes(attributesList.get(0),
|
||||
testClass, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ class ContextLoaderUtilsConfigurationAttributesTests extends AbstractContextConf
|
||||
void resolveConfigAttributesWithLocalAnnotationAndLocations() {
|
||||
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(LocationsFoo.class);
|
||||
assertThat(attributesList).isNotNull();
|
||||
assertThat(attributesList.size()).isEqualTo(1);
|
||||
assertThat(attributesList).hasSize(1);
|
||||
assertLocationsFooAttributes(attributesList.get(0));
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class ContextLoaderUtilsConfigurationAttributesTests extends AbstractContextConf
|
||||
Class<MetaLocationsFoo> testClass = MetaLocationsFoo.class;
|
||||
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
|
||||
assertThat(attributesList).isNotNull();
|
||||
assertThat(attributesList.size()).isEqualTo(1);
|
||||
assertThat(attributesList).hasSize(1);
|
||||
assertAttributes(attributesList.get(0),
|
||||
testClass, new String[] {"/foo.xml"}, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ class ContextLoaderUtilsConfigurationAttributesTests extends AbstractContextConf
|
||||
Class<MetaLocationsFooWithOverrides> testClass = MetaLocationsFooWithOverrides.class;
|
||||
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
|
||||
assertThat(attributesList).isNotNull();
|
||||
assertThat(attributesList.size()).isEqualTo(1);
|
||||
assertThat(attributesList).hasSize(1);
|
||||
assertAttributes(attributesList.get(0),
|
||||
testClass, new String[] {"/foo.xml"}, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class ContextLoaderUtilsConfigurationAttributesTests extends AbstractContextConf
|
||||
Class<MetaLocationsFooWithOverriddenAttributes> testClass = MetaLocationsFooWithOverriddenAttributes.class;
|
||||
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
|
||||
assertThat(attributesList).isNotNull();
|
||||
assertThat(attributesList.size()).isEqualTo(1);
|
||||
assertThat(attributesList).hasSize(1);
|
||||
assertAttributes(attributesList.get(0),
|
||||
testClass, new String[] {"foo1.xml", "foo2.xml"}, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ class ContextLoaderUtilsConfigurationAttributesTests extends AbstractContextConf
|
||||
Class<MetaLocationsBar> testClass = MetaLocationsBar.class;
|
||||
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(testClass);
|
||||
assertThat(attributesList).isNotNull();
|
||||
assertThat(attributesList.size()).isEqualTo(2);
|
||||
assertThat(attributesList).hasSize(2);
|
||||
assertAttributes(attributesList.get(0),
|
||||
testClass, new String[] {"/bar.xml"}, EMPTY_CLASS_ARRAY, ContextLoader.class, true);
|
||||
assertAttributes(attributesList.get(1),
|
||||
@@ -131,7 +131,7 @@ class ContextLoaderUtilsConfigurationAttributesTests extends AbstractContextConf
|
||||
void resolveConfigAttributesWithLocalAnnotationAndClasses() {
|
||||
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(ClassesFoo.class);
|
||||
assertThat(attributesList).isNotNull();
|
||||
assertThat(attributesList.size()).isEqualTo(1);
|
||||
assertThat(attributesList).hasSize(1);
|
||||
assertClassesFooAttributes(attributesList.get(0));
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ class ContextLoaderUtilsConfigurationAttributesTests extends AbstractContextConf
|
||||
void resolveConfigAttributesWithLocalAndInheritedAnnotationsAndLocations() {
|
||||
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(LocationsBar.class);
|
||||
assertThat(attributesList).isNotNull();
|
||||
assertThat(attributesList.size()).isEqualTo(2);
|
||||
assertThat(attributesList).hasSize(2);
|
||||
assertLocationsBarAttributes(attributesList.get(0));
|
||||
assertLocationsFooAttributes(attributesList.get(1));
|
||||
}
|
||||
@@ -148,7 +148,7 @@ class ContextLoaderUtilsConfigurationAttributesTests extends AbstractContextConf
|
||||
void resolveConfigAttributesWithLocalAndInheritedAnnotationsAndClasses() {
|
||||
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(ClassesBar.class);
|
||||
assertThat(attributesList).isNotNull();
|
||||
assertThat(attributesList.size()).isEqualTo(2);
|
||||
assertThat(attributesList).hasSize(2);
|
||||
assertClassesBarAttributes(attributesList.get(0));
|
||||
assertClassesFooAttributes(attributesList.get(1));
|
||||
}
|
||||
@@ -161,7 +161,7 @@ class ContextLoaderUtilsConfigurationAttributesTests extends AbstractContextConf
|
||||
void resolveConfigAttributesWithLocationsAndClasses() {
|
||||
List<ContextConfigurationAttributes> attributesList = resolveContextConfigurationAttributes(LocationsAndClasses.class);
|
||||
assertThat(attributesList).isNotNull();
|
||||
assertThat(attributesList.size()).isEqualTo(1);
|
||||
assertThat(attributesList).hasSize(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -67,18 +67,18 @@ class ContextLoaderUtilsContextHierarchyTests extends AbstractContextConfigurati
|
||||
@Test
|
||||
void resolveContextHierarchyAttributesForSingleTestClassWithImplicitSingleLevelContextHierarchy() {
|
||||
List<List<ContextConfigurationAttributes>> hierarchyAttributes = resolveContextHierarchyAttributes(BareAnnotations.class);
|
||||
assertThat(hierarchyAttributes.size()).isEqualTo(1);
|
||||
assertThat(hierarchyAttributes).hasSize(1);
|
||||
List<ContextConfigurationAttributes> configAttributesList = hierarchyAttributes.get(0);
|
||||
assertThat(configAttributesList.size()).isEqualTo(1);
|
||||
assertThat(configAttributesList).hasSize(1);
|
||||
debugConfigAttributes(configAttributesList);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveContextHierarchyAttributesForSingleTestClassWithSingleLevelContextHierarchy() {
|
||||
List<List<ContextConfigurationAttributes>> hierarchyAttributes = resolveContextHierarchyAttributes(SingleTestClassWithSingleLevelContextHierarchy.class);
|
||||
assertThat(hierarchyAttributes.size()).isEqualTo(1);
|
||||
assertThat(hierarchyAttributes).hasSize(1);
|
||||
List<ContextConfigurationAttributes> configAttributesList = hierarchyAttributes.get(0);
|
||||
assertThat(configAttributesList.size()).isEqualTo(1);
|
||||
assertThat(configAttributesList).hasSize(1);
|
||||
debugConfigAttributes(configAttributesList);
|
||||
}
|
||||
|
||||
@@ -86,11 +86,11 @@ class ContextLoaderUtilsContextHierarchyTests extends AbstractContextConfigurati
|
||||
void resolveContextHierarchyAttributesForSingleTestClassWithSingleLevelContextHierarchyFromMetaAnnotation() {
|
||||
Class<SingleTestClassWithSingleLevelContextHierarchyFromMetaAnnotation> testClass = SingleTestClassWithSingleLevelContextHierarchyFromMetaAnnotation.class;
|
||||
List<List<ContextConfigurationAttributes>> hierarchyAttributes = resolveContextHierarchyAttributes(testClass);
|
||||
assertThat(hierarchyAttributes.size()).isEqualTo(1);
|
||||
assertThat(hierarchyAttributes).hasSize(1);
|
||||
|
||||
List<ContextConfigurationAttributes> configAttributesList = hierarchyAttributes.get(0);
|
||||
assertThat(configAttributesList).isNotNull();
|
||||
assertThat(configAttributesList.size()).isEqualTo(1);
|
||||
assertThat(configAttributesList).hasSize(1);
|
||||
debugConfigAttributes(configAttributesList);
|
||||
assertAttributes(configAttributesList.get(0), testClass, new String[] { "A.xml" }, EMPTY_CLASS_ARRAY,
|
||||
ContextLoader.class, true);
|
||||
@@ -100,11 +100,11 @@ class ContextLoaderUtilsContextHierarchyTests extends AbstractContextConfigurati
|
||||
void resolveContextHierarchyAttributesForSingleTestClassWithTripleLevelContextHierarchy() {
|
||||
Class<SingleTestClassWithTripleLevelContextHierarchy> testClass = SingleTestClassWithTripleLevelContextHierarchy.class;
|
||||
List<List<ContextConfigurationAttributes>> hierarchyAttributes = resolveContextHierarchyAttributes(testClass);
|
||||
assertThat(hierarchyAttributes.size()).isEqualTo(1);
|
||||
assertThat(hierarchyAttributes).hasSize(1);
|
||||
|
||||
List<ContextConfigurationAttributes> configAttributesList = hierarchyAttributes.get(0);
|
||||
assertThat(configAttributesList).isNotNull();
|
||||
assertThat(configAttributesList.size()).isEqualTo(3);
|
||||
assertThat(configAttributesList).hasSize(3);
|
||||
debugConfigAttributes(configAttributesList);
|
||||
assertAttributes(configAttributesList.get(0), testClass, new String[] { "A.xml" }, EMPTY_CLASS_ARRAY,
|
||||
ContextLoader.class, true);
|
||||
@@ -117,32 +117,32 @@ class ContextLoaderUtilsContextHierarchyTests extends AbstractContextConfigurati
|
||||
@Test
|
||||
void resolveContextHierarchyAttributesForTestClassHierarchyWithSingleLevelContextHierarchies() {
|
||||
List<List<ContextConfigurationAttributes>> hierarchyAttributes = resolveContextHierarchyAttributes(TestClass3WithSingleLevelContextHierarchy.class);
|
||||
assertThat(hierarchyAttributes.size()).isEqualTo(3);
|
||||
assertThat(hierarchyAttributes).hasSize(3);
|
||||
|
||||
List<ContextConfigurationAttributes> configAttributesListClassLevel1 = hierarchyAttributes.get(0);
|
||||
debugConfigAttributes(configAttributesListClassLevel1);
|
||||
assertThat(configAttributesListClassLevel1.size()).isEqualTo(1);
|
||||
assertThat(configAttributesListClassLevel1).hasSize(1);
|
||||
assertThat(configAttributesListClassLevel1.get(0).getLocations()[0]).isEqualTo("one.xml");
|
||||
|
||||
List<ContextConfigurationAttributes> configAttributesListClassLevel2 = hierarchyAttributes.get(1);
|
||||
debugConfigAttributes(configAttributesListClassLevel2);
|
||||
assertThat(configAttributesListClassLevel2.size()).isEqualTo(1);
|
||||
assertThat(configAttributesListClassLevel2).hasSize(1);
|
||||
assertThat(configAttributesListClassLevel2.get(0).getLocations()).isEqualTo(new String[] { "two-A.xml", "two-B.xml" });
|
||||
|
||||
List<ContextConfigurationAttributes> configAttributesListClassLevel3 = hierarchyAttributes.get(2);
|
||||
debugConfigAttributes(configAttributesListClassLevel3);
|
||||
assertThat(configAttributesListClassLevel3.size()).isEqualTo(1);
|
||||
assertThat(configAttributesListClassLevel3).hasSize(1);
|
||||
assertThat(configAttributesListClassLevel3.get(0).getLocations()[0]).isEqualTo("three.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveContextHierarchyAttributesForTestClassHierarchyWithSingleLevelContextHierarchiesAndMetaAnnotations() {
|
||||
List<List<ContextConfigurationAttributes>> hierarchyAttributes = resolveContextHierarchyAttributes(TestClass3WithSingleLevelContextHierarchyFromMetaAnnotation.class);
|
||||
assertThat(hierarchyAttributes.size()).isEqualTo(3);
|
||||
assertThat(hierarchyAttributes).hasSize(3);
|
||||
|
||||
List<ContextConfigurationAttributes> configAttributesListClassLevel1 = hierarchyAttributes.get(0);
|
||||
debugConfigAttributes(configAttributesListClassLevel1);
|
||||
assertThat(configAttributesListClassLevel1.size()).isEqualTo(1);
|
||||
assertThat(configAttributesListClassLevel1).hasSize(1);
|
||||
assertThat(configAttributesListClassLevel1.get(0).getLocations()[0]).isEqualTo("A.xml");
|
||||
assertAttributes(configAttributesListClassLevel1.get(0),
|
||||
TestClass1WithSingleLevelContextHierarchyFromMetaAnnotation.class, new String[] { "A.xml" },
|
||||
@@ -150,7 +150,7 @@ class ContextLoaderUtilsContextHierarchyTests extends AbstractContextConfigurati
|
||||
|
||||
List<ContextConfigurationAttributes> configAttributesListClassLevel2 = hierarchyAttributes.get(1);
|
||||
debugConfigAttributes(configAttributesListClassLevel2);
|
||||
assertThat(configAttributesListClassLevel2.size()).isEqualTo(1);
|
||||
assertThat(configAttributesListClassLevel2).hasSize(1);
|
||||
assertThat(configAttributesListClassLevel2.get(0).getLocations()).isEqualTo(new String[] { "B-one.xml", "B-two.xml" });
|
||||
assertAttributes(configAttributesListClassLevel2.get(0),
|
||||
TestClass2WithSingleLevelContextHierarchyFromMetaAnnotation.class,
|
||||
@@ -159,7 +159,7 @@ class ContextLoaderUtilsContextHierarchyTests extends AbstractContextConfigurati
|
||||
|
||||
List<ContextConfigurationAttributes> configAttributesListClassLevel3 = hierarchyAttributes.get(2);
|
||||
debugConfigAttributes(configAttributesListClassLevel3);
|
||||
assertThat(configAttributesListClassLevel3.size()).isEqualTo(1);
|
||||
assertThat(configAttributesListClassLevel3).hasSize(1);
|
||||
assertThat(configAttributesListClassLevel3.get(0).getLocations()[0]).isEqualTo("C.xml");
|
||||
assertAttributes(configAttributesListClassLevel3.get(0),
|
||||
TestClass3WithSingleLevelContextHierarchyFromMetaAnnotation.class, new String[] { "C.xml" },
|
||||
@@ -167,17 +167,17 @@ class ContextLoaderUtilsContextHierarchyTests extends AbstractContextConfigurati
|
||||
}
|
||||
|
||||
private void assertOneTwo(List<List<ContextConfigurationAttributes>> hierarchyAttributes) {
|
||||
assertThat(hierarchyAttributes.size()).isEqualTo(2);
|
||||
assertThat(hierarchyAttributes).hasSize(2);
|
||||
|
||||
List<ContextConfigurationAttributes> configAttributesListClassLevel1 = hierarchyAttributes.get(0);
|
||||
List<ContextConfigurationAttributes> configAttributesListClassLevel2 = hierarchyAttributes.get(1);
|
||||
debugConfigAttributes(configAttributesListClassLevel1);
|
||||
debugConfigAttributes(configAttributesListClassLevel2);
|
||||
|
||||
assertThat(configAttributesListClassLevel1.size()).isEqualTo(1);
|
||||
assertThat(configAttributesListClassLevel1).hasSize(1);
|
||||
assertThat(configAttributesListClassLevel1.get(0).getLocations()[0]).isEqualTo("one.xml");
|
||||
|
||||
assertThat(configAttributesListClassLevel2.size()).isEqualTo(1);
|
||||
assertThat(configAttributesListClassLevel2).hasSize(1);
|
||||
assertThat(configAttributesListClassLevel2.get(0).getLocations()[0]).isEqualTo("two.xml");
|
||||
}
|
||||
|
||||
@@ -204,23 +204,23 @@ class ContextLoaderUtilsContextHierarchyTests extends AbstractContextConfigurati
|
||||
@Test
|
||||
void resolveContextHierarchyAttributesForTestClassHierarchyWithMultiLevelContextHierarchies() {
|
||||
List<List<ContextConfigurationAttributes>> hierarchyAttributes = resolveContextHierarchyAttributes(TestClass3WithMultiLevelContextHierarchy.class);
|
||||
assertThat(hierarchyAttributes.size()).isEqualTo(3);
|
||||
assertThat(hierarchyAttributes).hasSize(3);
|
||||
|
||||
List<ContextConfigurationAttributes> configAttributesListClassLevel1 = hierarchyAttributes.get(0);
|
||||
debugConfigAttributes(configAttributesListClassLevel1);
|
||||
assertThat(configAttributesListClassLevel1.size()).isEqualTo(2);
|
||||
assertThat(configAttributesListClassLevel1).hasSize(2);
|
||||
assertThat(configAttributesListClassLevel1.get(0).getLocations()[0]).isEqualTo("1-A.xml");
|
||||
assertThat(configAttributesListClassLevel1.get(1).getLocations()[0]).isEqualTo("1-B.xml");
|
||||
|
||||
List<ContextConfigurationAttributes> configAttributesListClassLevel2 = hierarchyAttributes.get(1);
|
||||
debugConfigAttributes(configAttributesListClassLevel2);
|
||||
assertThat(configAttributesListClassLevel2.size()).isEqualTo(2);
|
||||
assertThat(configAttributesListClassLevel2).hasSize(2);
|
||||
assertThat(configAttributesListClassLevel2.get(0).getLocations()[0]).isEqualTo("2-A.xml");
|
||||
assertThat(configAttributesListClassLevel2.get(1).getLocations()[0]).isEqualTo("2-B.xml");
|
||||
|
||||
List<ContextConfigurationAttributes> configAttributesListClassLevel3 = hierarchyAttributes.get(2);
|
||||
debugConfigAttributes(configAttributesListClassLevel3);
|
||||
assertThat(configAttributesListClassLevel3.size()).isEqualTo(3);
|
||||
assertThat(configAttributesListClassLevel3).hasSize(3);
|
||||
assertThat(configAttributesListClassLevel3.get(0).getLocations()[0]).isEqualTo("3-A.xml");
|
||||
assertThat(configAttributesListClassLevel3.get(1).getLocations()[0]).isEqualTo("3-B.xml");
|
||||
assertThat(configAttributesListClassLevel3.get(2).getLocations()[0]).isEqualTo("3-C.xml");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -215,7 +215,7 @@ class TestPropertySourceUtilsTests {
|
||||
|
||||
MutablePropertySources propertySources = environment.getPropertySources();
|
||||
propertySources.remove(MockPropertySource.MOCK_PROPERTIES_PROPERTY_SOURCE_NAME);
|
||||
assertThat(propertySources.size()).isEqualTo(0);
|
||||
assertThat(propertySources).hasSize(0);
|
||||
|
||||
String pair = "key = value";
|
||||
ByteArrayResource resource = new ByteArrayResource(pair.getBytes(), "from inlined property: " + pair);
|
||||
@@ -223,7 +223,7 @@ class TestPropertySourceUtilsTests {
|
||||
given(resourceLoader.getResource(anyString())).willReturn(resource);
|
||||
|
||||
addPropertiesFilesToEnvironment(environment, resourceLoader, FOO_LOCATIONS);
|
||||
assertThat(propertySources.size()).isEqualTo(1);
|
||||
assertThat(propertySources).hasSize(1);
|
||||
assertThat(environment.getProperty("key")).isEqualTo("value");
|
||||
}
|
||||
|
||||
@@ -275,10 +275,10 @@ class TestPropertySourceUtilsTests {
|
||||
ConfigurableEnvironment environment = new MockEnvironment();
|
||||
MutablePropertySources propertySources = environment.getPropertySources();
|
||||
propertySources.remove(MockPropertySource.MOCK_PROPERTIES_PROPERTY_SOURCE_NAME);
|
||||
assertThat(propertySources.size()).isEqualTo(0);
|
||||
assertThat(propertySources).hasSize(0);
|
||||
addInlinedPropertiesToEnvironment(environment, asArray(" "));
|
||||
assertThat(propertySources.size()).isEqualTo(1);
|
||||
assertThat(((Map) propertySources.iterator().next().getSource()).size()).isEqualTo(0);
|
||||
assertThat(propertySources).hasSize(1);
|
||||
assertThat(((Map<?, ?>) propertySources.iterator().next().getSource())).hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -99,17 +99,17 @@ public class MockServerTests {
|
||||
mutatedBuilder.defaultCookie("baz", "qux");
|
||||
WebTestClient clientFromMutatedBuilder = mutatedBuilder.build();
|
||||
|
||||
client1.mutate().filters(filters -> assertThat(filters.size()).isEqualTo(1));
|
||||
client1.mutate().defaultHeaders(headers -> assertThat(headers.size()).isEqualTo(1));
|
||||
client1.mutate().defaultCookies(cookies -> assertThat(cookies.size()).isEqualTo(1));
|
||||
client1.mutate().filters(filters -> assertThat(filters).hasSize(1));
|
||||
client1.mutate().defaultHeaders(headers -> assertThat(headers).hasSize(1));
|
||||
client1.mutate().defaultCookies(cookies -> assertThat(cookies).hasSize(1));
|
||||
|
||||
client2.mutate().filters(filters -> assertThat(filters.size()).isEqualTo(2));
|
||||
client2.mutate().defaultHeaders(headers -> assertThat(headers.size()).isEqualTo(2));
|
||||
client2.mutate().defaultCookies(cookies -> assertThat(cookies.size()).isEqualTo(2));
|
||||
client2.mutate().filters(filters -> assertThat(filters).hasSize(2));
|
||||
client2.mutate().defaultHeaders(headers -> assertThat(headers).hasSize(2));
|
||||
client2.mutate().defaultCookies(cookies -> assertThat(cookies).hasSize(2));
|
||||
|
||||
clientFromMutatedBuilder.mutate().filters(filters -> assertThat(filters.size()).isEqualTo(2));
|
||||
clientFromMutatedBuilder.mutate().defaultHeaders(headers -> assertThat(headers.size()).isEqualTo(2));
|
||||
clientFromMutatedBuilder.mutate().defaultCookies(cookies -> assertThat(cookies.size()).isEqualTo(2));
|
||||
clientFromMutatedBuilder.mutate().filters(filters -> assertThat(filters).hasSize(2));
|
||||
clientFromMutatedBuilder.mutate().defaultHeaders(headers -> assertThat(headers).hasSize(2));
|
||||
clientFromMutatedBuilder.mutate().defaultCookies(cookies -> assertThat(cookies).hasSize(2));
|
||||
}
|
||||
|
||||
@Test // SPR-16124
|
||||
|
||||
@@ -403,7 +403,7 @@ public class HtmlUnitRequestBuilderTests {
|
||||
|
||||
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
|
||||
|
||||
assertThat(actualRequest.getParameterMap().size()).isEqualTo(1);
|
||||
assertThat(actualRequest.getParameterMap()).hasSize(1);
|
||||
assertThat(actualRequest.getParameter("name")).isEqualTo("");
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ public class HtmlUnitRequestBuilderTests {
|
||||
|
||||
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
|
||||
|
||||
assertThat(actualRequest.getParameterMap().size()).isEqualTo(1);
|
||||
assertThat(actualRequest.getParameterMap()).hasSize(1);
|
||||
assertThat(actualRequest.getParameter("name")).isEqualTo("");
|
||||
}
|
||||
|
||||
@@ -423,7 +423,7 @@ public class HtmlUnitRequestBuilderTests {
|
||||
|
||||
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
|
||||
|
||||
assertThat(actualRequest.getParameterMap().size()).isEqualTo(1);
|
||||
assertThat(actualRequest.getParameterMap()).hasSize(1);
|
||||
assertThat(actualRequest.getParameter("name")).isEqualTo(" ");
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ public class MockWebResponseBuilderTests {
|
||||
WebResponse webResponse = this.responseBuilder.build();
|
||||
|
||||
List<NameValuePair> responseHeaders = webResponse.getResponseHeaders();
|
||||
assertThat(responseHeaders.size()).isEqualTo(3);
|
||||
assertThat(responseHeaders).hasSize(3);
|
||||
NameValuePair header = responseHeaders.get(0);
|
||||
assertThat(header.getName()).isEqualTo("Content-Type");
|
||||
assertThat(header.getValue()).isEqualTo("text/html");
|
||||
@@ -132,7 +132,7 @@ public class MockWebResponseBuilderTests {
|
||||
WebResponse webResponse = this.responseBuilder.build();
|
||||
|
||||
List<NameValuePair> responseHeaders = webResponse.getResponseHeaders();
|
||||
assertThat(responseHeaders.size()).isEqualTo(1);
|
||||
assertThat(responseHeaders).hasSize(1);
|
||||
NameValuePair header = responseHeaders.get(0);
|
||||
assertThat(header.getName()).isEqualTo("Set-Cookie");
|
||||
assertThat(header.getValue()).isEqualTo("cookieA=valueA");
|
||||
|
||||
@@ -345,7 +345,7 @@ class MockHttpServletRequestBuilderTests {
|
||||
List<String> accept = Collections.list(request.getHeaders("Accept"));
|
||||
List<MediaType> result = MediaType.parseMediaTypes(accept.get(0));
|
||||
|
||||
assertThat(accept.size()).isEqualTo(1);
|
||||
assertThat(accept).hasSize(1);
|
||||
assertThat(result.get(0).toString()).isEqualTo("text/html");
|
||||
assertThat(result.get(1).toString()).isEqualTo("application/xml");
|
||||
}
|
||||
@@ -366,7 +366,7 @@ class MockHttpServletRequestBuilderTests {
|
||||
List<String> contentTypes = Collections.list(request.getHeaders("Content-Type"));
|
||||
|
||||
assertThat(contentType).isEqualTo("text/html");
|
||||
assertThat(contentTypes.size()).isEqualTo(1);
|
||||
assertThat(contentTypes).hasSize(1);
|
||||
assertThat(contentTypes.get(0)).isEqualTo("text/html");
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ class MockHttpServletRequestBuilderTests {
|
||||
List<String> contentTypes = Collections.list(request.getHeaders("Content-Type"));
|
||||
|
||||
assertThat(contentType).isEqualTo("text/html");
|
||||
assertThat(contentTypes.size()).isEqualTo(1);
|
||||
assertThat(contentTypes).hasSize(1);
|
||||
assertThat(contentTypes.get(0)).isEqualTo("text/html");
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ class MockHttpServletRequestBuilderTests {
|
||||
MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);
|
||||
List<String> headers = Collections.list(request.getHeaders("foo"));
|
||||
|
||||
assertThat(headers.size()).isEqualTo(2);
|
||||
assertThat(headers).hasSize(2);
|
||||
assertThat(headers.get(0)).isEqualTo("bar");
|
||||
assertThat(headers.get(1)).isEqualTo("baz");
|
||||
}
|
||||
@@ -448,7 +448,7 @@ class MockHttpServletRequestBuilderTests {
|
||||
MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);
|
||||
List<String> headers = Collections.list(request.getHeaders("foo"));
|
||||
|
||||
assertThat(headers.size()).isEqualTo(2);
|
||||
assertThat(headers).hasSize(2);
|
||||
assertThat(headers.get(0)).isEqualTo("bar");
|
||||
assertThat(headers.get(1)).isEqualTo("baz");
|
||||
assertThat(request.getHeader("Content-Type")).isEqualTo(MediaType.APPLICATION_JSON.toString());
|
||||
|
||||
@@ -168,7 +168,7 @@ class PrintingResultHandlerTests {
|
||||
|
||||
// Manually validate cookie values since maxAge changes...
|
||||
List<String> cookieValues = this.response.getHeaders("Set-Cookie");
|
||||
assertThat(cookieValues.size()).isEqualTo(2);
|
||||
assertThat(cookieValues).hasSize(2);
|
||||
assertThat(cookieValues.get(0)).isEqualTo("cookie=cookieValue");
|
||||
assertThat(cookieValues.get(1).startsWith(
|
||||
"enigma=42; Path=/crumbs; Domain=.example.com; Max-Age=1234; Expires=")).as("Actual: " + cookieValues.get(1)).isTrue();
|
||||
|
||||
Reference in New Issue
Block a user