DATAJDBC-272 - Reformat code and optimize imports.

This commit is contained in:
Mark Paluch
2018-10-11 16:14:43 +02:00
committed by Jens Schauder
parent 6a60c53602
commit dd7362516b
46 changed files with 130 additions and 172 deletions

View File

@@ -103,7 +103,7 @@ class SelectBuilder {
return conditions.stream() //
.map(WhereCondition::toSql) //
.collect(Collectors.joining("AND", " WHERE ", "") //
);
);
}
private String joinClause() {

View File

@@ -23,8 +23,8 @@ import java.util.Map;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
/**
* Provides {@link SqlGenerator}s per domain type. Instances get cached, so when asked multiple times for the same domain
* type, the same generator will get returned.
* Provides {@link SqlGenerator}s per domain type. Instances get cached, so when asked multiple times for the same
* domain type, the same generator will get returned.
*
* @author Jens Schauder
*/

View File

@@ -24,9 +24,7 @@ import org.springframework.lang.Nullable;
*
* @param <T> the type of the referenced aggregate root.
* @param <ID> the type of the id of the referenced aggregate root.
*
* @author Jens Schauder
*
* @since 1.0
*/
public interface AggregateReference<T, ID> {
@@ -42,9 +40,8 @@ public interface AggregateReference<T, ID> {
ID getId();
/**
* An {@link AggregateReference} that only holds the id of the referenced aggregate root.
*
* Note that there is no check that a matching aggregate for this id actually exists.
* An {@link AggregateReference} that only holds the id of the referenced aggregate root. Note that there is no check
* that a matching aggregate for this id actually exists.
*
* @param <T>
* @param <ID>

View File

@@ -4,4 +4,4 @@
@NonNullApi
package org.springframework.data.jdbc.core;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullApi;

View File

@@ -33,7 +33,8 @@ public class MyBatisContext {
private final Class domainType;
private final Map<String, Object> additonalValues;
public MyBatisContext(@Nullable Object id, @Nullable Object instance, Class domainType, Map<String, Object> additonalValues) {
public MyBatisContext(@Nullable Object id, @Nullable Object instance, Class domainType,
Map<String, Object> additonalValues) {
this.id = id;
this.instance = instance;

View File

@@ -131,8 +131,7 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy {
public <T> Object insert(T instance, Class<T> domainType, Map<String, Object> additionalParameters) {
MyBatisContext myBatisContext = new MyBatisContext(null, instance, domainType, additionalParameters);
sqlSession().insert(namespace(domainType) + ".insert",
myBatisContext);
sqlSession().insert(namespace(domainType) + ".insert", myBatisContext);
return myBatisContext.getId();
}

View File

@@ -45,7 +45,8 @@ public @interface EnableJdbcRepositories {
/**
* Alias for the {@link #basePackages()} attribute. Allows for more concise annotation declarations e.g.:
* {@code @EnableJdbcRepositories("org.my.pkg")} instead of {@code @EnableJdbcRepositories(basePackages="org.my.pkg")}.
* {@code @EnableJdbcRepositories("org.my.pkg")} instead of
* {@code @EnableJdbcRepositories(basePackages="org.my.pkg")}.
*/
String[] value() default {};

View File

@@ -23,7 +23,6 @@ import org.springframework.core.convert.converter.Converter;
import org.springframework.data.jdbc.core.convert.BasicJdbcConverter;
import org.springframework.data.jdbc.core.convert.JdbcCustomConversions;
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
import org.springframework.data.relational.core.conversion.BasicRelationalConverter;
import org.springframework.data.relational.core.conversion.RelationalConverter;
import org.springframework.data.relational.core.mapping.NamingStrategy;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
@@ -49,8 +48,7 @@ public class JdbcConfiguration {
@Bean
protected JdbcMappingContext jdbcMappingContext(Optional<NamingStrategy> namingStrategy) {
JdbcMappingContext mappingContext = new JdbcMappingContext(
namingStrategy.orElse(NamingStrategy.INSTANCE));
JdbcMappingContext mappingContext = new JdbcMappingContext(namingStrategy.orElse(NamingStrategy.INSTANCE));
mappingContext.setSimpleTypeHolder(jdbcCustomConversions().getSimpleTypeHolder());
return mappingContext;

View File

@@ -25,10 +25,9 @@ import org.springframework.data.annotation.QueryAnnotation;
import org.springframework.jdbc.core.RowMapper;
/**
* Annotation to provide SQL statements that will get used for executing the method.
*
* The SQL statement may contain named parameters as supported by {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate}.
* Those parameters will get bound to the arguments of the annotated method.
* Annotation to provide SQL statements that will get used for executing the method. The SQL statement may contain named
* parameters as supported by {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate}. Those
* parameters will get bound to the arguments of the annotated method.
*
* @author Jens Schauder
*/

View File

@@ -52,8 +52,8 @@ class JdbcRepositoryQuery implements RepositoryQuery {
private final RowMapper<?> rowMapper;
/**
* Creates a new {@link JdbcRepositoryQuery} for the given {@link JdbcQueryMethod}, {@link RelationalMappingContext} and
* {@link RowMapper}.
* Creates a new {@link JdbcRepositoryQuery} for the given {@link JdbcQueryMethod}, {@link RelationalMappingContext}
* and {@link RowMapper}.
*
* @param publisher must not be {@literal null}.
* @param context must not be {@literal null}.

View File

@@ -310,8 +310,7 @@ public class AggregateTemplateIntegrationTests {
private String name;
private Manual manual;
@Column("alternative")
private Manual alternativeInstructions;
@Column("alternative") private Manual alternativeInstructions;
}
@Data

View File

@@ -35,11 +35,11 @@ import org.springframework.data.relational.core.mapping.RelationalPersistentProp
public class CascadingDataAccessStrategyUnitTests {
int errorIndex = 1;
String[] errorMessages = {"Sorry I don't support this method. Please try again later", "Still no luck"};
String[] errorMessages = { "Sorry I don't support this method. Please try again later", "Still no luck" };
DataAccessStrategy alwaysFails = mock(DataAccessStrategy.class, i -> {
errorIndex ++;
errorIndex %=2;
errorIndex++;
errorIndex %= 2;
throw new UnsupportedOperationException(errorMessages[errorIndex]);
});
DataAccessStrategy succeeds = mock(DataAccessStrategy.class);
@@ -47,7 +47,6 @@ public class CascadingDataAccessStrategyUnitTests {
throw new AssertionFailedError("this shouldn't have get called");
});
@Test // DATAJDBC-123
public void findByReturnsFirstSuccess() {
@@ -75,7 +74,8 @@ public class CascadingDataAccessStrategyUnitTests {
@Test // DATAJDBC-123
public void findByPropertyReturnsFirstSuccess() {
doReturn(Collections.singletonList("success")).when(succeeds).findAllByProperty(eq(23L), any(RelationalPersistentProperty.class));
doReturn(Collections.singletonList("success")).when(succeeds).findAllByProperty(eq(23L),
any(RelationalPersistentProperty.class));
CascadingDataAccessStrategy access = new CascadingDataAccessStrategy(asList(alwaysFails, succeeds, mayNotCall));
Iterable<Object> findAll = access.findAllByProperty(23L, mock(RelationalPersistentProperty.class));

View File

@@ -247,7 +247,7 @@ public class EntityRowMapperUnitTests {
"Number of values [%d] must be a multiple of the number of columns [%d]", //
values.length, //
columns.size() //
) //
) //
);
List<Map<String, Object>> result = convertValues(columns, values);

View File

@@ -78,7 +78,7 @@ public class MyBatisDataAccessStrategyUnitTests {
null, //
String.class, //
"value" //
);
);
}
@Test // DATAJDBC-123
@@ -100,7 +100,7 @@ public class MyBatisDataAccessStrategyUnitTests {
null, //
String.class, //
null //
);
);
}
@Test // DATAJDBC-123
@@ -122,7 +122,7 @@ public class MyBatisDataAccessStrategyUnitTests {
"an-id", //
String.class, //
null //
);
);
}
@Test // DATAJDBC-123
@@ -146,7 +146,7 @@ public class MyBatisDataAccessStrategyUnitTests {
null, //
ChildTwo.class, //
null //
);
);
}
@Test // DATAJDBC-123
@@ -168,7 +168,7 @@ public class MyBatisDataAccessStrategyUnitTests {
null, //
String.class, //
null //
);
);
}
@Test // DATAJDBC-123
@@ -191,7 +191,7 @@ public class MyBatisDataAccessStrategyUnitTests {
null, "rootid", //
ChildTwo.class, //
null //
);
);
}
@Test // DATAJDBC-123
@@ -212,7 +212,7 @@ public class MyBatisDataAccessStrategyUnitTests {
null, "an-id", //
String.class, //
null //
);
);
}
@Test // DATAJDBC-123
@@ -234,7 +234,7 @@ public class MyBatisDataAccessStrategyUnitTests {
null, //
String.class, //
null //
);
);
}
@Test // DATAJDBC-123
@@ -256,7 +256,7 @@ public class MyBatisDataAccessStrategyUnitTests {
asList("id1", "id2"), //
String.class, //
null //
);
);
}
@SuppressWarnings("unchecked")
@@ -285,7 +285,7 @@ public class MyBatisDataAccessStrategyUnitTests {
"id", //
Number.class, //
null //
);
);
}
@Test // DATAJDBC-123
@@ -307,7 +307,7 @@ public class MyBatisDataAccessStrategyUnitTests {
"id", //
String.class, //
null //
);
);
}
@Test // DATAJDBC-157
@@ -331,7 +331,7 @@ public class MyBatisDataAccessStrategyUnitTests {
null, //
String.class, //
null //
);
);
}
private static class DummyEntity {

View File

@@ -114,8 +114,8 @@ public class SqlGeneratorFixedNamingStrategyUnitTests {
String sql = sqlGenerator.createDeleteByPath(getPath("ref", DummyEntity.class));
assertThat(sql).isEqualTo("DELETE FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity "
+ "WHERE dummy_entity = :rootId");
assertThat(sql).isEqualTo(
"DELETE FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity " + "WHERE dummy_entity = :rootId");
}
@Test // DATAJDBC-107
@@ -126,9 +126,8 @@ public class SqlGeneratorFixedNamingStrategyUnitTests {
String sql = sqlGenerator.createDeleteByPath(getPath("ref.further", DummyEntity.class));
assertThat(sql).isEqualTo("DELETE FROM FixedCustomSchema.FixedCustomTablePrefix_SecondLevelReferencedEntity "
+ "WHERE referenced_entity IN "
+ "(SELECT FixedCustomPropertyPrefix_l1id " + "FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity "
+ "WHERE dummy_entity = :rootId)");
+ "WHERE referenced_entity IN " + "(SELECT FixedCustomPropertyPrefix_l1id "
+ "FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity " + "WHERE dummy_entity = :rootId)");
}
@Test // DATAJDBC-107
@@ -148,8 +147,8 @@ public class SqlGeneratorFixedNamingStrategyUnitTests {
String sql = sqlGenerator.createDeleteAllSql(getPath("ref", DummyEntity.class));
assertThat(sql).isEqualTo("DELETE FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity "
+ "WHERE dummy_entity IS NOT NULL");
assertThat(sql).isEqualTo(
"DELETE FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity " + "WHERE dummy_entity IS NOT NULL");
}
@Test // DATAJDBC-107
@@ -160,9 +159,8 @@ public class SqlGeneratorFixedNamingStrategyUnitTests {
String sql = sqlGenerator.createDeleteAllSql(getPath("ref.further", DummyEntity.class));
assertThat(sql).isEqualTo("DELETE FROM FixedCustomSchema.FixedCustomTablePrefix_SecondLevelReferencedEntity "
+ "WHERE referenced_entity IN "
+ "(SELECT FixedCustomPropertyPrefix_l1id " + "FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity "
+ "WHERE dummy_entity IS NOT NULL)");
+ "WHERE referenced_entity IN " + "(SELECT FixedCustomPropertyPrefix_l1id "
+ "FROM FixedCustomSchema.FixedCustomTablePrefix_ReferencedEntity " + "WHERE dummy_entity IS NOT NULL)");
}
@Test // DATAJDBC-113

View File

@@ -199,9 +199,7 @@ public class SqlGeneratorUnitTests {
String findAll = sqlGenerator.getFindAll();
assertThat(findAll).containsSequence(
"SELECT",
"child.parent_of_no_id_child AS child_parent_of_no_id_child",
assertThat(findAll).containsSequence("SELECT", "child.parent_of_no_id_child AS child_parent_of_no_id_child",
"FROM");
}
@@ -256,8 +254,7 @@ public class SqlGeneratorUnitTests {
NoIdChild child;
}
static class NoIdChild {
}
static class NoIdChild {}
static class OtherAggregate {
@Id Long id;

View File

@@ -72,8 +72,7 @@ public class BasicRelationalConverterAggregateReferenceUnitTests {
private static class DummyEntity {
@Id
Long simple;
@Id Long simple;
AggregateReference<DummyEntity, Long> reference;
}
}

View File

@@ -97,8 +97,8 @@ public class BasicJdbcPersistentPropertyUnitTests {
public void detectsAnnotatedColumnAndKeyName() {
RelationalPersistentProperty listProperty = context //
.getRequiredPersistentEntity(DummyEntity.class) //
.getRequiredPersistentProperty("someList");
.getRequiredPersistentEntity(DummyEntity.class) //
.getRequiredPersistentProperty("someList");
assertThat(listProperty.getReverseColumnName()).isEqualTo("dummy_column_name");
assertThat(listProperty.getKeyColumn()).isEqualTo("dummy_key_column_name");

View File

@@ -26,8 +26,7 @@ import org.springframework.data.annotation.Id;
@Alias("DummyEntity")
class DummyEntity {
@Wither
@Id final Long id;
@Wither @Id final Long id;
final String name;
public DummyEntity(Long id, String name) {

View File

@@ -91,8 +91,7 @@ public class MyBatisHsqlIntegrationTests {
DataAccessStrategy dataAccessStrategy(RelationalMappingContext context, RelationalConverter converter,
SqlSession sqlSession, EmbeddedDatabase db) {
return MyBatisDataAccessStrategy.createCombinedAccessStrategy(context, converter,
new NamedParameterJdbcTemplate(db),
sqlSession);
new NamedParameterJdbcTemplate(db), sqlSession);
}
}

View File

@@ -80,7 +80,7 @@ public class JdbcRepositoryManipulateDbActionsIntegrationTests {
entity.id, //
entity.name, //
true) //
);
);
}
@@ -103,14 +103,14 @@ public class JdbcRepositoryManipulateDbActionsIntegrationTests {
one.id, //
one.name, //
true) //
);
);
assertThat(repository.findById(two.id)) //
.contains(new DummyEntity( //
two.id, //
two.name, //
true) //
);
);
}
@Test // DATAJDBC-120

View File

@@ -188,7 +188,7 @@ public class JdbcRepositoryWithCollectionsAndManuallyAssignedIdHsqlIntegrationTe
.containsExactlyInAnyOrder( //
tuple(element2.id, "two changed"), //
tuple(element3.id, "three") //
);
);
Long count = template.queryForObject("select count(1) from Element", new HashMap<>(), Long.class);
assertThat(count).isEqualTo(2);
@@ -214,9 +214,6 @@ public class JdbcRepositoryWithCollectionsAndManuallyAssignedIdHsqlIntegrationTe
assertThat(count).isEqualTo(0);
}
private Element createElement(String content) {
Element element = new Element();

View File

@@ -164,7 +164,7 @@ public class JdbcRepositoryWithCollectionsIntegrationTests {
.containsExactlyInAnyOrder( //
tuple(element2.id, "two changed"), //
tuple(element3.id, "three") //
);
);
Long count = template.queryForObject("select count(1) from Element", new HashMap<>(), Long.class);
assertThat(count).isEqualTo(2);
@@ -190,9 +190,6 @@ public class JdbcRepositoryWithCollectionsIntegrationTests {
assertThat(count).isEqualTo(0);
}
private Element createElement(String content) {
Element element = new Element();

View File

@@ -55,8 +55,7 @@ public class JdbcRepositoryWithListsIntegrationTests {
@Import(TestConfiguration.class)
static class Config {
@Autowired
JdbcRepositoryFactory factory;
@Autowired JdbcRepositoryFactory factory;
@Bean
Class<?> testClass() {
@@ -69,15 +68,11 @@ public class JdbcRepositoryWithListsIntegrationTests {
}
}
@ClassRule
public static final SpringClassRule classRule = new SpringClassRule();
@Rule
public SpringMethodRule methodRule = new SpringMethodRule();
@ClassRule public static final SpringClassRule classRule = new SpringClassRule();
@Rule public SpringMethodRule methodRule = new SpringMethodRule();
@Autowired
NamedParameterJdbcTemplate template;
@Autowired
DummyEntityRepository repository;
@Autowired NamedParameterJdbcTemplate template;
@Autowired DummyEntityRepository repository;
@Test // DATAJDBC-130
public void saveAndLoadEmptyList() {
@@ -211,14 +206,12 @@ public class JdbcRepositoryWithListsIntegrationTests {
return entity;
}
interface DummyEntityRepository extends CrudRepository<DummyEntity, Long> {
}
interface DummyEntityRepository extends CrudRepository<DummyEntity, Long> {}
@Data
static class DummyEntity {
@Id
private Long id;
@Id private Long id;
String name;
List<Element> content = new ArrayList<>();
@@ -227,8 +220,7 @@ public class JdbcRepositoryWithListsIntegrationTests {
@RequiredArgsConstructor
static class Element {
@Id
private Long id;
@Id private Long id;
String content;
}

View File

@@ -165,7 +165,7 @@ public class JdbcRepositoryWithMapsIntegrationTests {
.containsExactlyInAnyOrder( //
tuple("two", element2.id, "two changed"), //
tuple("three", element3.id, "three") //
);
);
Long count = template.queryForObject("select count(1) from Element", new HashMap<>(), Long.class);
assertThat(count).isEqualTo(2);

View File

@@ -81,8 +81,7 @@ public class SimpleJdbcRepositoryEventsUnitTests {
NamedParameterJdbcOperations operations = createIdGeneratingOperations();
SqlGeneratorSource generatorSource = new SqlGeneratorSource(context);
this.dataAccessStrategy = spy(
new DefaultDataAccessStrategy(generatorSource, context, converter, operations));
this.dataAccessStrategy = spy(new DefaultDataAccessStrategy(generatorSource, context, converter, operations));
JdbcRepositoryFactory factory = new JdbcRepositoryFactory(dataAccessStrategy, context, converter, publisher,
operations);
@@ -103,7 +102,7 @@ public class SimpleJdbcRepositoryEventsUnitTests {
.containsExactly( //
BeforeSaveEvent.class, //
AfterSaveEvent.class //
);
);
}
@Test // DATAJDBC-99
@@ -122,7 +121,7 @@ public class SimpleJdbcRepositoryEventsUnitTests {
AfterSaveEvent.class, //
BeforeSaveEvent.class, //
AfterSaveEvent.class //
);
);
}
@Test // DATAJDBC-99
@@ -153,7 +152,7 @@ public class SimpleJdbcRepositoryEventsUnitTests {
.containsExactly( //
BeforeDeleteEvent.class, //
AfterDeleteEvent.class //
);
);
}
@Test // DATAJDBC-197
@@ -172,7 +171,7 @@ public class SimpleJdbcRepositoryEventsUnitTests {
.containsExactly( //
AfterLoadEvent.class, //
AfterLoadEvent.class //
);
);
}
@Test // DATAJDBC-197
@@ -191,7 +190,7 @@ public class SimpleJdbcRepositoryEventsUnitTests {
.containsExactly( //
AfterLoadEvent.class, //
AfterLoadEvent.class //
);
);
}
@Test // DATAJDBC-197
@@ -208,7 +207,7 @@ public class SimpleJdbcRepositoryEventsUnitTests {
.extracting(e -> (Class) e.getClass()) //
.containsExactly( //
AfterLoadEvent.class //
);
);
}
private static NamedParameterJdbcOperations createIdGeneratingOperations() {

View File

@@ -73,7 +73,8 @@ public class EnableJdbcAuditingHsqlIntegrationTests {
softly.assertThat(entity.getCreatedBy()).as("created by set").isEqualTo("user01");
softly.assertThat(entity.getCreatedDate()).as("created date set").isAfter(now);
softly.assertThat(entity.getLastModifiedBy()).as("modified by set").isEqualTo("user01");
softly.assertThat(entity.getLastModifiedDate()).as("modified date set").isAfterOrEqualTo(entity.getCreatedDate());
softly.assertThat(entity.getLastModifiedDate()).as("modified date set")
.isAfterOrEqualTo(entity.getCreatedDate());
softly.assertThat(entity.getLastModifiedDate()).as("modified date after instance creation").isAfter(now);
AuditingAnnotatedDummyEntity reloaded = repository.findById(entity.id).get();
@@ -97,7 +98,8 @@ public class EnableJdbcAuditingHsqlIntegrationTests {
softly.assertThat(entity.getCreatedBy()).as("created by unchanged").isEqualTo("user01");
softly.assertThat(entity.getCreatedDate()).as("created date unchanged").isEqualTo(beforeCreatedDate);
softly.assertThat(entity.getLastModifiedBy()).as("modified by updated").isEqualTo("user02");
softly.assertThat(entity.getLastModifiedDate()).as("modified date updated").isAfter(beforeLastModifiedDate);
softly.assertThat(entity.getLastModifiedDate()).as("modified date updated")
.isAfter(beforeLastModifiedDate);
reloaded = repository.findById(entity.id).get();

View File

@@ -90,7 +90,8 @@ public class EnableJdbcRepositoriesIntegrationTests {
}
@ComponentScan("org.springframework.data.jdbc.testing")
@EnableJdbcRepositories(considerNestedRepositories = true, includeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = DummyRepository.class))
@EnableJdbcRepositories(considerNestedRepositories = true,
includeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = DummyRepository.class))
static class TestConfiguration {
@Bean

View File

@@ -341,7 +341,6 @@ public class QueryAnnotationHsqlIntegrationTests {
@Query("SELECT 'one' one, 'two' two, 3 three FROM (VALUES (0))")
ImmutableTuple immutableTuple();
@Value
class ImmutableTuple {
String one;

View File

@@ -28,10 +28,8 @@ import org.testcontainers.containers.MariaDBContainer;
import org.testcontainers.jdbc.ext.ScriptUtils;
/**
* {@link DataSource} setup for MariaDB.
*
* Starts a Docker-container with a MariaDB database, and sets up database "test".
* {@link DataSource} setup for MariaDB. Starts a Docker-container with a MariaDB database, and sets up database "test".
*
* @author Christoph Preißner
*/
@Configuration
@@ -56,7 +54,7 @@ class MariaDBDataSourceConfiguration extends DataSourceConfiguration {
dataSource.setUser(MARIADB_CONTAINER.getUsername());
dataSource.setPassword(MARIADB_CONTAINER.getPassword());
return dataSource;
} catch(SQLException sqlex) {
} catch (SQLException sqlex) {
throw new RuntimeException(sqlex);
}
}

View File

@@ -29,9 +29,8 @@ import org.testcontainers.jdbc.ext.ScriptUtils;
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
/**
* {@link DataSource} setup for MySQL.
*
* Starts a docker container with a MySql database and sets up a database name "test" in it.
* {@link DataSource} setup for MySQL. Starts a docker container with a MySql database and sets up a database name
* "test" in it.
*
* @author Jens Schauder
* @author Oliver Gierke

View File

@@ -24,9 +24,7 @@ import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.testcontainers.containers.PostgreSQLContainer;
/**
* {@link DataSource} setup for PostgreSQL.
*
* Starts a docker container with a Postgres database.
* {@link DataSource} setup for PostgreSQL. Starts a docker container with a Postgres database.
*
* @author Jens Schauder
* @author Oliver Gierke

View File

@@ -25,9 +25,7 @@ import java.util.Map;
import org.springframework.data.mapping.PersistentPropertyPath;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
import org.springframework.data.util.Pair;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
* An instance of this interface represents a (conceptual) single interaction with a database, e.g. a single update,
@@ -242,7 +240,7 @@ public interface DbAction<T> {
*
* @author Jens Schauder
*/
interface WithDependingOn<T> extends WithPropertyPath<T>, WithEntity<T>{
interface WithDependingOn<T> extends WithPropertyPath<T>, WithEntity<T> {
/**
* The {@link DbAction} of a parent entity, possibly the aggregate root. This is used to obtain values needed to

View File

@@ -56,7 +56,8 @@ public interface RelationalConverter {
* properties.
*
* @param entity the kind of entity to create. Must not be {@code null}.
* @param parameterValueProvider a function that provides the value to pass to a constructor, given a {@link Parameter}. Must not be {@code null}.
* @param parameterValueProvider a function that provides the value to pass to a constructor, given a
* {@link Parameter}. Must not be {@code null}.
* @param <T> the type of entity to create.
* @return the instantiated entity. Guaranteed to be not {@code null}.
*/

View File

@@ -15,6 +15,8 @@
*/
package org.springframework.data.relational.core.conversion;
import lombok.Value;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -22,7 +24,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Value;
import org.springframework.data.convert.EntityWriter;
import org.springframework.data.mapping.PersistentProperty;
import org.springframework.data.mapping.PersistentPropertyPath;
@@ -241,8 +242,8 @@ public class RelationalEntityWriter implements EntityWriter<Object, AggregateCha
}
/**
* Represents a single entity in an aggregate along with its property path from the root entity and the chain of objects
* to traverse a long this path.
* Represents a single entity in an aggregate along with its property path from the root entity and the chain of
* objects to traverse a long this path.
*/
@Value
static class PathNode {
@@ -251,11 +252,9 @@ public class RelationalEntityWriter implements EntityWriter<Object, AggregateCha
PersistentPropertyPath<RelationalPersistentProperty> path;
/**
* The parent {@link PathNode}. This is {@code null} if this is
* the root entity.
* The parent {@link PathNode}. This is {@code null} if this is the root entity.
*/
@Nullable
PathNode parent;
@Nullable PathNode parent;
/** The value of the entity. */
Object value;

View File

@@ -61,8 +61,8 @@ public interface NamingStrategy {
}
/**
* Defaults to return the given {@link RelationalPersistentProperty}'s name with the parts of a camel case name separated by
* '_';
* Defaults to return the given {@link RelationalPersistentProperty}'s name with the parts of a camel case name
* separated by '_';
*/
default String getColumnName(RelationalPersistentProperty property) {

View File

@@ -15,7 +15,6 @@
*/
package org.springframework.data.relational.core.mapping;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.data.mapping.PersistentProperty;
import org.springframework.lang.Nullable;
@@ -45,8 +44,8 @@ public interface RelationalPersistentProperty extends PersistentProperty<Relatio
/**
* The SQL type constant used when using this property as a parameter for a SQL statement.
*
* @return Must not be {@code null}.
*
* @see java.sql.Types
*/
int getSqlType();

View File

@@ -16,8 +16,8 @@
package org.springframework.data.relational.core.mapping.event;
/**
* Interface for {@link SimpleRelationalEvent}s which are guaranteed to have an entity. Allows direct access to that entity,
* without going through an {@link java.util.Optional}
* Interface for {@link SimpleRelationalEvent}s which are guaranteed to have an entity. Allows direct access to that
* entity, without going through an {@link java.util.Optional}
*
* @author Jens Schauder
*/

View File

@@ -18,8 +18,8 @@ package org.springframework.data.relational.core.mapping.event;
import org.springframework.data.relational.core.mapping.event.Identifier.Specified;
/**
* Interface for {@link SimpleRelationalEvent}s which are guaranteed to have a {@link Specified} identifier. Offers direct
* access to the {@link Specified} identifier.
* Interface for {@link SimpleRelationalEvent}s which are guaranteed to have a {@link Specified} identifier. Offers
* direct access to the {@link Specified} identifier.
*
* @author Jens Schauder
*/

View File

@@ -18,8 +18,6 @@ package org.springframework.data.relational.core.conversion;
import static org.mockito.Mockito.*;
import org.junit.Test;
import org.springframework.data.relational.core.conversion.DbAction;
import org.springframework.data.relational.core.conversion.DbActionExecutionException;
/**
* @author Jens Schauder

View File

@@ -24,11 +24,11 @@ import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.data.annotation.Id;
import org.springframework.data.mapping.PersistentPropertyPath;
import org.springframework.data.relational.core.conversion.AggregateChange.Kind;
import org.springframework.data.relational.core.conversion.DbAction.Delete;
import org.springframework.data.relational.core.conversion.DbAction.DeleteAll;
import org.springframework.data.relational.core.conversion.DbAction.DeleteAllRoot;
import org.springframework.data.relational.core.conversion.DbAction.DeleteRoot;
import org.springframework.data.relational.core.conversion.AggregateChange.Kind;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
/**
@@ -65,7 +65,7 @@ public class RelationalEntityDeleteWriterUnitTests {
Tuple.tuple(Delete.class, YetAnother.class, "other.yetAnother"), //
Tuple.tuple(Delete.class, OtherEntity.class, "other"), //
Tuple.tuple(DeleteRoot.class, SomeEntity.class, null) //
);
);
}
@Test // DATAJDBC-188
@@ -81,7 +81,7 @@ public class RelationalEntityDeleteWriterUnitTests {
Tuple.tuple(DeleteAll.class, YetAnother.class, "other.yetAnother"), //
Tuple.tuple(DeleteAll.class, OtherEntity.class, "other"), //
Tuple.tuple(DeleteAllRoot.class, SomeEntity.class, null) //
);
);
}
@Data

View File

@@ -30,11 +30,11 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.conversion.AggregateChange.Kind;
import org.springframework.data.relational.core.conversion.DbAction.Delete;
import org.springframework.data.relational.core.conversion.DbAction.Insert;
import org.springframework.data.relational.core.conversion.DbAction.InsertRoot;
import org.springframework.data.relational.core.conversion.DbAction.UpdateRoot;
import org.springframework.data.relational.core.conversion.AggregateChange.Kind;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
/**
@@ -62,7 +62,7 @@ public class RelationalEntityWriterUnitTests {
this::isWithDependsOn) //
.containsExactly( //
tuple(InsertRoot.class, SingleReferenceEntity.class, "", SingleReferenceEntity.class, false) //
);
);
}
@Test // DATAJDBC-112
@@ -82,7 +82,7 @@ public class RelationalEntityWriterUnitTests {
.containsExactly( //
tuple(InsertRoot.class, SingleReferenceEntity.class, "", SingleReferenceEntity.class, false), //
tuple(Insert.class, Element.class, "other", Element.class, true) //
);
);
}
@Test // DATAJDBC-112
@@ -101,7 +101,7 @@ public class RelationalEntityWriterUnitTests {
.containsExactly( //
tuple(Delete.class, Element.class, "other", null, false), //
tuple(UpdateRoot.class, SingleReferenceEntity.class, "", SingleReferenceEntity.class, false) //
);
);
}
@Test // DATAJDBC-112
@@ -122,7 +122,7 @@ public class RelationalEntityWriterUnitTests {
tuple(Delete.class, Element.class, "other", null, false), //
tuple(UpdateRoot.class, SingleReferenceEntity.class, "", SingleReferenceEntity.class, false), //
tuple(Insert.class, Element.class, "other", Element.class, true) //
);
);
}
@Test // DATAJDBC-113
@@ -158,7 +158,7 @@ public class RelationalEntityWriterUnitTests {
tuple(InsertRoot.class, SetContainer.class, "", SetContainer.class, false), //
tuple(Insert.class, Element.class, "elements", Element.class, true), //
tuple(Insert.class, Element.class, "elements", Element.class, true) //
);
);
}
@Test // DATAJDBC-113
@@ -194,7 +194,7 @@ public class RelationalEntityWriterUnitTests {
tuple(Insert.class, Element.class, "other.element", Element.class, true), //
tuple(Insert.class, Element.class, "other.element", Element.class, true), //
tuple(Insert.class, Element.class, "other.element", Element.class, true) //
);
);
}
@Test // DATAJDBC-188
@@ -232,7 +232,7 @@ public class RelationalEntityWriterUnitTests {
tuple(Insert.class, Element.class, "other.element", Element.class, true), //
tuple(Insert.class, Element.class, "other.element", Element.class, true), //
tuple(Insert.class, Element.class, "other.element", Element.class, true) //
);
);
}
@Test // DATAJDBC-131
@@ -270,7 +270,7 @@ public class RelationalEntityWriterUnitTests {
).containsSubsequence( // container comes before the elements
tuple(InsertRoot.class, MapContainer.class, null, ""), //
tuple(Insert.class, Element.class, "one", "elements") //
);
);
}
@Test // DATAJDBC-183
@@ -309,7 +309,7 @@ public class RelationalEntityWriterUnitTests {
tuple(Insert.class, Element.class, "0", "elements"), //
tuple(Insert.class, Element.class, "a", "elements"), //
tuple(Insert.class, Element.class, "b", "elements") //
);
);
}
@Test // DATAJDBC-130
@@ -347,7 +347,7 @@ public class RelationalEntityWriterUnitTests {
).containsSubsequence( // container comes before the elements
tuple(InsertRoot.class, ListContainer.class, null, ""), //
tuple(Insert.class, Element.class, 0, "elements") //
);
);
}
@Test // DATAJDBC-131
@@ -366,7 +366,7 @@ public class RelationalEntityWriterUnitTests {
tuple(Delete.class, Element.class, null, "elements"), //
tuple(UpdateRoot.class, MapContainer.class, null, ""), //
tuple(Insert.class, Element.class, "one", "elements") //
);
);
}
@Test // DATAJDBC-130
@@ -385,7 +385,7 @@ public class RelationalEntityWriterUnitTests {
tuple(Delete.class, Element.class, null, "elements"), //
tuple(UpdateRoot.class, ListContainer.class, null, ""), //
tuple(Insert.class, Element.class, 0, "elements") //
);
);
}
private CascadingReferenceMiddleElement createMiddleElement(Element first, Element second) {
@@ -397,11 +397,15 @@ public class RelationalEntityWriterUnitTests {
}
private Object getMapKey(DbAction a) {
return a instanceof DbAction.WithDependingOn ? ((DbAction.WithDependingOn) a).getAdditionalValues().get("map_container_key") : null;
return a instanceof DbAction.WithDependingOn
? ((DbAction.WithDependingOn) a).getAdditionalValues().get("map_container_key")
: null;
}
private Object getListKey(DbAction a) {
return a instanceof DbAction.WithDependingOn ? ((DbAction.WithDependingOn) a).getAdditionalValues().get("list_container_key") : null;
return a instanceof DbAction.WithDependingOn
? ((DbAction.WithDependingOn) a).getAdditionalValues().get("list_container_key")
: null;
}
private String extractPath(DbAction action) {

View File

@@ -22,9 +22,6 @@ import java.util.List;
import org.junit.Test;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
import org.springframework.data.relational.core.mapping.NamingStrategy;
import org.springframework.data.relational.core.mapping.RelationalPersistentEntityImplUnitTests.DummySubEntity;
/**

View File

@@ -36,10 +36,10 @@ public class RelationalMappingContextUnitTests {
public void uuidPropertyIsNotEntity() {
SimpleTypeHolder holder = new SimpleTypeHolder(new HashSet<>(Arrays.asList(UUID.class)), true);
RelationalMappingContext mappingContext = new RelationalMappingContext();
mappingContext.setSimpleTypeHolder(holder);
RelationalPersistentEntity<?> entity = mappingContext.getPersistentEntity(EntityWithUuid.class);
RelationalPersistentProperty uuidProperty = entity.getRequiredPersistentProperty("uuid");
@@ -49,6 +49,5 @@ public class RelationalMappingContextUnitTests {
static class EntityWithUuid {
@Id UUID uuid;
}
}

View File

@@ -18,10 +18,6 @@ package org.springframework.data.relational.core.mapping;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
import org.springframework.data.relational.core.mapping.RelationalPersistentEntityImpl;
import org.springframework.data.relational.core.mapping.Table;
/**
* Unit tests for {@link RelationalPersistentEntityImpl}.

View File

@@ -15,12 +15,11 @@
*/
package org.springframework.data.relational.core.mapping.event;
import org.junit.Test;
import org.springframework.data.relational.core.mapping.event.Identifier;
import static org.assertj.core.api.Assertions.*;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
/**
* Unit tests for {@link Identifier}
@@ -40,7 +39,7 @@ public class IdentifierTest {
}
@Test
public void indentifierOfNullHasEmptyValue(){
public void indentifierOfNullHasEmptyValue() {
Identifier identifier = Identifier.ofNullable(null);
@@ -49,10 +48,10 @@ public class IdentifierTest {
@SuppressWarnings("unchecked")
@Test
public void indentifierOfXHasValueX(){
public void indentifierOfXHasValueX() {
Identifier identifier = Identifier.ofNullable("x");
assertThat((Optional<Object>) identifier.getOptionalValue()).hasValue("x");
}
}
}