Polish "Use idiomatic AssertJ map assertions"

See gh-31752
This commit is contained in:
Stéphane Nicoll
2023-12-05 10:39:33 +01:00
parent 6f11716b6f
commit 1da40b84e7
11 changed files with 48 additions and 81 deletions

View File

@@ -19,7 +19,6 @@ package org.springframework.orm.jpa.persistenceunit;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import javax.sql.DataSource;
@@ -37,6 +36,7 @@ import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup;
import org.springframework.jdbc.datasource.lookup.MapDataSourceLookup;
import static java.util.Map.entry;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatRuntimeException;
@@ -95,7 +95,7 @@ public class PersistenceXmlParsingTests {
assertThat(info[0].getMappingFileNames()).hasSize(1);
assertThat(info[0].getMappingFileNames().get(0)).isEqualTo("mappings.xml");
assertThat(info[0].getProperties().keySet()).isEmpty();
assertThat(info[0].getProperties()).isEmpty();
assertThat(info[0].excludeUnlistedClasses()).as("Exclude unlisted should default false in 1.0.").isFalse();
}
@@ -115,7 +115,7 @@ public class PersistenceXmlParsingTests {
assertThat(info[0].getJarFileUrls().get(0)).isEqualTo(new ClassPathResource("order.jar").getURL());
assertThat(info[0].getJarFileUrls().get(1)).isEqualTo(new ClassPathResource("order-supplemental.jar").getURL());
assertThat(info[0].getProperties().keySet()).isEmpty();
assertThat(info[0].getProperties()).isEmpty();
assertThat(info[0].getJtaDataSource()).isNull();
assertThat(info[0].getNonJtaDataSource()).isNull();
@@ -148,7 +148,7 @@ public class PersistenceXmlParsingTests {
assertThat(info[0].excludeUnlistedClasses()).as("Exclude unlisted should be true when no value.").isTrue();
assertThat(info[0].getTransactionType()).isSameAs(PersistenceUnitTransactionType.RESOURCE_LOCAL);
assertThat(info[0].getProperties().keySet()).isEmpty();
assertThat(info[0].getProperties()).isEmpty();
builder.clear();
}
@@ -173,7 +173,7 @@ public class PersistenceXmlParsingTests {
assertThat(info[0].getJarFileUrls().get(1)).isEqualTo(new ClassPathResource("order-supplemental.jar").getURL());
assertThat(info[0].getPersistenceProviderClassName()).isEqualTo("com.acme.AcmePersistence");
assertThat(info[0].getProperties().keySet()).isEmpty();
assertThat(info[0].getProperties()).isEmpty();
assertThat(info[0].excludeUnlistedClasses()).as("Exclude unlisted should default false in 1.0.").isFalse();
}
@@ -210,10 +210,8 @@ public class PersistenceXmlParsingTests {
assertThat(pu1.getTransactionType()).isSameAs(PersistenceUnitTransactionType.RESOURCE_LOCAL);
Properties props = pu1.getProperties();
assertThat(props.keySet()).hasSize(2);
assertThat(props.getProperty("com.acme.persistence.sql-logging")).isEqualTo("on");
assertThat(props.getProperty("foo")).isEqualTo("bar");
assertThat(pu1.getProperties()).containsOnly(
entry("com.acme.persistence.sql-logging", "on"), entry("foo", "bar"));
assertThat(pu1.getNonJtaDataSource()).isNull();
@@ -249,7 +247,7 @@ public class PersistenceXmlParsingTests {
PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource);
assertThat(info).hasSize(1);
assertThat(info[0].getPersistenceUnitName()).isEqualTo("pu");
assertThat(info[0].getProperties().keySet()).isEmpty();
assertThat(info[0].getProperties()).isEmpty();
assertThat(info[0].excludeUnlistedClasses()).as("Exclude unlisted should default false in 1.0.").isFalse();
}