Browse Source

Polishing.

Reformat code. Remove duplicate, lingering Javadoc. Add override annotations. Use entities instead of < and >. Reduce method/class visibility in tests.

See #1003
Original pull request: #1018.
pull/1014/head
Mark Paluch 4 years ago
parent
commit
d47020d868
No known key found for this signature in database
GPG Key ID: 4406B84C1661DCD1
  1. 2
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/BindMarker.java
  2. 1
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Column.java
  3. 8
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Comparison.java
  4. 16
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/ConstantCondition.java
  5. 3
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/DefaultSelectBuilder.java
  6. 17
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/InlineQuery.java
  7. 4
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Select.java
  8. 5
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/SelectBuilder.java
  9. 6
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Table.java
  10. 12
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/TableLike.java
  11. 5
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/ColumnVisitor.java
  12. 1
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/ComparisonVisitor.java
  13. 2
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/ConstantConditionVisitor.java
  14. 2
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/ExpressionVisitor.java
  15. 6
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/FromTableVisitor.java
  16. 6
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/SelectListVisitor.java
  17. 3
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/SelectRenderContext.java
  18. 4
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/SimpleRenderContext.java
  19. 17
      spring-data-relational/src/test/java/org/springframework/data/relational/core/sql/render/FromClauseVisitorUnitTests.java
  20. 20
      spring-data-relational/src/test/java/org/springframework/data/relational/core/sql/render/JoinVisitorTestsUnitTest.java
  21. 54
      spring-data-relational/src/test/java/org/springframework/data/relational/core/sql/render/SelectRendererUnitTests.java
  22. 48
      spring-data-relational/src/test/java/org/springframework/data/relational/core/sql/render/TypedSubtreeVisitorUnitTests.java

2
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/BindMarker.java

@ -15,8 +15,6 @@ @@ -15,8 +15,6 @@
*/
package org.springframework.data.relational.core.sql;
import org.springframework.lang.Nullable;
/**
* Bind marker/parameter placeholder used to construct prepared statements with parameter substitution.
*

1
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Column.java

@ -56,6 +56,7 @@ public class Column extends AbstractSegment implements Expression, Named { @@ -56,6 +56,7 @@ public class Column extends AbstractSegment implements Expression, Named {
* @param name column name, must not {@literal null} or empty.
* @param table the table, must not be {@literal null}.
* @return the new {@link Column}.
* @since 2.3
*/
public static Column create(String name, TableLike table) {

8
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Comparison.java

@ -61,11 +61,13 @@ public class Comparison extends AbstractSegment implements Condition { @@ -61,11 +61,13 @@ public class Comparison extends AbstractSegment implements Condition {
/**
* Creates a new {@link Comparison} from simple {@literal StringP} arguments
* @param unqualifiedColumnName gets turned in a {@link Expressions#just(String)} and is expected to be an unqualified unique column name but also could be an verbatim expression. Must not be {@literal null}.
*
* @param unqualifiedColumnName gets turned in a {@link Expressions#just(String)} and is expected to be an unqualified
* unique column name but also could be an verbatim expression. Must not be {@literal null}.
* @param comparator must not be {@literal null}.
* @param rightValue is considered a {@link Literal}. Must not be {@literal null}.
* @return a new {@literal Comparison} of the first with the third argument using the second argument as comparison operator. Guaranteed to be not {@literal null}.
*
* @return a new {@literal Comparison} of the first with the third argument using the second argument as comparison
* operator. Guaranteed to be not {@literal null}.
* @since 2.3
*/
public static Comparison create(String unqualifiedColumnName, String comparator, Object rightValue) {

16
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/ConstantCondition.java

@ -23,14 +23,14 @@ package org.springframework.data.relational.core.sql; @@ -23,14 +23,14 @@ package org.springframework.data.relational.core.sql;
*/
public class ConstantCondition extends AbstractSegment implements Condition {
private final String condition;
private final String condition;
ConstantCondition(String condition) {
this.condition = condition;
}
ConstantCondition(String condition) {
this.condition = condition;
}
@Override
public String toString() {
return condition;
}
@Override
public String toString() {
return condition;
}
}

3
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/DefaultSelectBuilder.java

@ -285,7 +285,8 @@ class DefaultSelectBuilder implements SelectBuilder, SelectAndFrom, SelectFromAn @@ -285,7 +285,8 @@ class DefaultSelectBuilder implements SelectBuilder, SelectAndFrom, SelectFromAn
@Override
public Select build() {
DefaultSelect select = new DefaultSelect(distinct, selectList, from, limit, offset, joins, where, orderBy, lockMode);
DefaultSelect select = new DefaultSelect(distinct, selectList, from, limit, offset, joins, where, orderBy,
lockMode);
SelectValidator.validate(select);
return select;
}

17
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/InlineQuery.java

@ -18,14 +18,14 @@ package org.springframework.data.relational.core.sql; @@ -18,14 +18,14 @@ package org.springframework.data.relational.core.sql;
import org.springframework.util.Assert;
/**
* Represents a inline query within a SQL statement. Typically used in {@code FROM} or {@code JOIN} clauses.
* <p/>
* Renders to: {@code (<SELECT>) AS <ALIAS>} in a from or join clause, and to {@code <ALIAS>} when used in an
* expression.
* <p/>
* Represents a inline query within a SQL statement. Typically, used in {@code FROM} or {@code JOIN} clauses.
* <p>
* Renders to: {@code (&gt;SELECT&lt;) AS &gt;ALIAS&lt;} in a from or join clause, and to {@code &gt;ALIAS&lt;} when
* used in an expression.
* <p>
* Note that this does not implement {@link Aliased} because the Alias is not optional but required and therefore more
* like a name although the SQL term is "alias".
*
*
* @author Jens Schauder
* @since 2.3
*/
@ -68,13 +68,11 @@ public class InlineQuery extends AbstractSegment implements TableLike { @@ -68,13 +68,11 @@ public class InlineQuery extends AbstractSegment implements TableLike {
return create(select, SqlIdentifier.unquoted(alias));
}
/**
* @return the table name.
*/
/*
* (non-Javadoc)
* @see org.springframework.data.relational.core.sql.Named#getName()
*/
@Override
public SqlIdentifier getName() {
return alias;
}
@ -83,6 +81,7 @@ public class InlineQuery extends AbstractSegment implements TableLike { @@ -83,6 +81,7 @@ public class InlineQuery extends AbstractSegment implements TableLike {
* @return the table name as it is used in references. This can be the actual {@link #getName() name} or an
* {@link Aliased#getAlias() alias}.
*/
@Override
public SqlIdentifier getReferenceName() {
return alias;
}

4
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Select.java

@ -15,11 +15,11 @@ @@ -15,11 +15,11 @@
*/
package org.springframework.data.relational.core.sql;
import org.springframework.lang.Nullable;
import java.util.List;
import java.util.OptionalLong;
import org.springframework.lang.Nullable;
/**
* AST for a {@code SELECT} statement. Visiting order:
* <ol>

5
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/SelectBuilder.java

@ -251,7 +251,7 @@ public interface SelectBuilder { @@ -251,7 +251,7 @@ public interface SelectBuilder {
* Builder exposing {@code FROM}, {@code JOIN}, {@code WHERE}, {@code LIMIT/OFFSET} and {@code LOCK} methods.
*/
interface SelectFromAndJoin
extends SelectFromAndOrderBy, BuildSelect, SelectJoin, SelectWhere, SelectLimitOffset, SelectLock {
extends SelectFromAndOrderBy, BuildSelect, SelectJoin, SelectWhere, SelectLimitOffset, SelectLock {
/**
* Declare a {@link Table} to {@code SELECT FROM}. Multiple calls to this or other {@code from} methods keep
@ -317,7 +317,8 @@ public interface SelectBuilder { @@ -317,7 +317,8 @@ public interface SelectBuilder {
}
/**
* Builder exposing {@code FROM}, {@code WHERE}, {@code LIMIT/OFFSET}, JOIN {@code AND} and {@code LOCK} continuation methods.
* Builder exposing {@code FROM}, {@code WHERE}, {@code LIMIT/OFFSET}, JOIN {@code AND} and {@code LOCK} continuation
* methods.
*/
interface SelectFromAndJoinCondition
extends BuildSelect, SelectJoin, SelectWhere, SelectOnCondition, SelectLimitOffset, SelectLock {

6
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Table.java

@ -107,13 +107,12 @@ public class Table extends AbstractSegment implements TableLike { @@ -107,13 +107,12 @@ public class Table extends AbstractSegment implements TableLike {
return new AliasedTable(name, alias);
}
/**
* @return the table name.
*/
/*
* (non-Javadoc)
* @see org.springframework.data.relational.core.sql.Named#getName()
*/
@Override
public SqlIdentifier getName() {
return name;
}
@ -122,6 +121,7 @@ public class Table extends AbstractSegment implements TableLike { @@ -122,6 +121,7 @@ public class Table extends AbstractSegment implements TableLike {
* @return the table name as it is used in references. This can be the actual {@link #getName() name} or an
* {@link Aliased#getAlias() alias}.
*/
@Override
public SqlIdentifier getReferenceName() {
return name;
}

12
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/TableLike.java

@ -15,13 +15,13 @@ @@ -15,13 +15,13 @@
*/
package org.springframework.data.relational.core.sql;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.springframework.util.Assert;
/**
* A segment that can be used as table in a query.
*
@ -61,6 +61,7 @@ public interface TableLike extends Segment { @@ -61,6 +61,7 @@ public interface TableLike extends Segment {
return new Column(name, this);
}
/**
* Creates a {@link List} of {@link Column}s associated with this {@link Table}.
* <p/>
@ -132,7 +133,14 @@ public interface TableLike extends Segment { @@ -132,7 +133,14 @@ public interface TableLike extends Segment {
return new AsteriskFromTable(this);
}
/**
* @return the table name.
*/
SqlIdentifier getName();
/**
* @return the table name as it is used in references. This can be the actual {@link #getName() name} or an
* {@link Aliased#getAlias() alias}.
*/
SqlIdentifier getReferenceName();
}

5
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/ColumnVisitor.java

@ -22,9 +22,8 @@ import org.springframework.data.relational.core.sql.Visitable; @@ -22,9 +22,8 @@ import org.springframework.data.relational.core.sql.Visitable;
import org.springframework.lang.Nullable;
/**
* Renderer for {@link Column}s. Renders a column as {@literal
* <table>
* .<column>} or {@literal <column>}.
* Renderer for {@link Column}s. Renders a column as {@literal &gt;table&lt;.&gt;column&lt;} or
* {@literal &gt;column&lt;}.
*
* @author Mark Paluch
* @since 1.1

1
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/ComparisonVisitor.java

@ -18,7 +18,6 @@ package org.springframework.data.relational.core.sql.render; @@ -18,7 +18,6 @@ package org.springframework.data.relational.core.sql.render;
import org.springframework.data.relational.core.sql.Comparison;
import org.springframework.data.relational.core.sql.Condition;
import org.springframework.data.relational.core.sql.Expression;
import org.springframework.data.relational.core.sql.SimpleFunction;
import org.springframework.data.relational.core.sql.Visitable;
import org.springframework.lang.Nullable;

2
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/ConstantConditionVisitor.java

@ -33,8 +33,8 @@ class ConstantConditionVisitor extends TypedSingleConditionRenderSupport<Constan @@ -33,8 +33,8 @@ class ConstantConditionVisitor extends TypedSingleConditionRenderSupport<Constan
}
/**
*
* (non-Javadoc)
*
* @see org.springframework.data.relational.core.sql.render.TypedSubtreeVisitor#leaveMatched(org.springframework.data.relational.core.sql.Visitable)
*/
@Override

2
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/ExpressionVisitor.java

@ -46,6 +46,7 @@ class ExpressionVisitor extends TypedSubtreeVisitor<Expression> implements PartR @@ -46,6 +46,7 @@ class ExpressionVisitor extends TypedSubtreeVisitor<Expression> implements PartR
/**
* Creates an {@code ExpressionVisitor} that does not use aliases for column names
*
* @param context must not be {@literal null}.
*/
ExpressionVisitor(RenderContext context) {
@ -155,6 +156,7 @@ class ExpressionVisitor extends TypedSubtreeVisitor<Expression> implements PartR @@ -155,6 +156,7 @@ class ExpressionVisitor extends TypedSubtreeVisitor<Expression> implements PartR
/**
* Describes how aliases of columns should be rendered.
*
* @since 2.3
*/
enum AliasHandling {

6
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/FromTableVisitor.java

@ -35,10 +35,8 @@ class FromTableVisitor extends TypedSubtreeVisitor<TableLike> { @@ -35,10 +35,8 @@ class FromTableVisitor extends TypedSubtreeVisitor<TableLike> {
private final RenderContext context;
private final RenderTarget parent;
@Nullable
private SelectStatementVisitor delegate;
@Nullable
private StringBuilder builder = null;
@Nullable private SelectStatementVisitor delegate;
@Nullable private StringBuilder builder = null;
FromTableVisitor(RenderContext context, RenderTarget parent) {
super();

6
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/SelectListVisitor.java

@ -15,7 +15,10 @@ @@ -15,7 +15,10 @@
*/
package org.springframework.data.relational.core.sql.render;
import org.springframework.data.relational.core.sql.*;
import org.springframework.data.relational.core.sql.Aliased;
import org.springframework.data.relational.core.sql.Expression;
import org.springframework.data.relational.core.sql.SelectList;
import org.springframework.data.relational.core.sql.Visitable;
/**
* {@link PartRenderer} for {@link SelectList}s.
@ -99,5 +102,4 @@ class SelectListVisitor extends TypedSubtreeVisitor<SelectList> implements PartR @@ -99,5 +102,4 @@ class SelectListVisitor extends TypedSubtreeVisitor<SelectList> implements PartR
return builder;
}
}

3
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/SelectRenderContext.java

@ -41,8 +41,7 @@ public interface SelectRenderContext { @@ -41,8 +41,7 @@ public interface SelectRenderContext {
}
/**
* Customization hook: Rendition of a part after {@code FROM} table.
* Renders an empty string by default.
* Customization hook: Rendition of a part after {@code FROM} table. Renders an empty string by default.
*
* @return render {@link Function} invoked after rendering {@code FROM} table.
*/

4
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/SimpleRenderContext.java

@ -48,9 +48,7 @@ final class SimpleRenderContext implements RenderContext { @@ -48,9 +48,7 @@ final class SimpleRenderContext implements RenderContext {
@Override
public String toString() {
return "SimpleRenderContext{" +
"namingStrategy=" + namingStrategy +
'}';
return "SimpleRenderContext{" + "namingStrategy=" + namingStrategy + '}';
}
enum DefaultSelectRenderContext implements SelectRenderContext {

17
spring-data-relational/src/test/java/org/springframework/data/relational/core/sql/render/FromClauseVisitorUnitTests.java

@ -15,13 +15,14 @@ @@ -15,13 +15,14 @@
*/
package org.springframework.data.relational.core.sql.render;
import static java.util.Arrays.*;
import static org.assertj.core.api.Assertions.*;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.springframework.data.relational.core.sql.Column;
import org.springframework.data.relational.core.sql.From;
import org.springframework.data.relational.core.sql.InlineQuery;
@ -34,7 +35,7 @@ import org.springframework.data.relational.core.sql.TestFrom; @@ -34,7 +35,7 @@ import org.springframework.data.relational.core.sql.TestFrom;
*
* @author Jens Schauder
*/
public class FromClauseVisitorUnitTests {
class FromClauseVisitorUnitTests {
StringBuilder renderResult = new StringBuilder();
FromClauseVisitor visitor = new FromClauseVisitor(new SimpleRenderContext(NamingStrategies.asIs()), renderResult::append);
@ -47,17 +48,17 @@ public class FromClauseVisitorUnitTests { @@ -47,17 +48,17 @@ public class FromClauseVisitorUnitTests {
from.visit(visitor);
assertThat(renderResult.toString()).isEqualTo(f.renderResult);
assertThat(renderResult).hasToString(f.renderResult);
}
static List<Fixture> testRendering() {
final Table tabOne = Table.create("tabOne");
final Table tabTwo = Table.create("tabTwo");
final Select selectOne = Select.builder().select(Column.create("oneId", tabOne)).from(tabOne).build();
final Select selectTwo = Select.builder().select(Column.create("twoId", tabTwo)).from(tabTwo).build();
Table tabOne = Table.create("tabOne");
Table tabTwo = Table.create("tabTwo");
Select selectOne = Select.builder().select(Column.create("oneId", tabOne)).from(tabOne).build();
Select selectTwo = Select.builder().select(Column.create("twoId", tabTwo)).from(tabTwo).build();
return asList(
return Arrays.asList(
fixture("single table", new TestFrom(Table.create("one")), "one"),
fixture("single table with alias", new TestFrom(Table.aliased("one", "one_alias")), "one one_alias"),
fixture("multiple tables", new TestFrom(Table.create("one"),Table.create("two")), "one, two"),

20
spring-data-relational/src/test/java/org/springframework/data/relational/core/sql/render/JoinVisitorTestsUnitTest.java

@ -15,13 +15,14 @@ @@ -15,13 +15,14 @@
*/
package org.springframework.data.relational.core.sql.render;
import static java.util.Arrays.*;
import static org.assertj.core.api.Assertions.*;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.springframework.data.relational.core.sql.Column;
import org.springframework.data.relational.core.sql.InlineQuery;
import org.springframework.data.relational.core.sql.Join;
@ -30,6 +31,11 @@ import org.springframework.data.relational.core.sql.Table; @@ -30,6 +31,11 @@ import org.springframework.data.relational.core.sql.Table;
import org.springframework.data.relational.core.sql.TestJoin;
import org.springframework.data.relational.core.sql.Visitor;
/**
* Unit tests for {@link JoinVisitor}.
*
* @author Jens Schauder
*/
public class JoinVisitorTestsUnitTest {
final StringBuilder builder = new StringBuilder();
@ -43,7 +49,7 @@ public class JoinVisitorTestsUnitTest { @@ -43,7 +49,7 @@ public class JoinVisitorTestsUnitTest {
join.visit(visitor);
assertThat(builder.toString()).isEqualTo(f.renderResult);
assertThat(builder).hasToString(f.renderResult);
}
static List<Fixture> renderJoins() {
@ -51,11 +57,11 @@ public class JoinVisitorTestsUnitTest { @@ -51,11 +57,11 @@ public class JoinVisitorTestsUnitTest {
Column colOne = Column.create("colOne", Table.create("tabOne"));
Table tabTwo = Table.create("tabTwo");
Column colTwo = Column.create("colTwo", tabTwo);
final Column renamed = colOne.as("renamed");
final Select select = Select.builder().select(renamed).from(colOne.getTable()).build();
final InlineQuery inlineQuery = InlineQuery.create(select, "inline");
Column renamed = colOne.as("renamed");
Select select = Select.builder().select(renamed).from(colOne.getTable()).build();
InlineQuery inlineQuery = InlineQuery.create(select, "inline");
return asList(
return Arrays.asList(
fixture("simple join", new TestJoin(Join.JoinType.JOIN, tabTwo, colOne.isEqualTo(colTwo)),
"JOIN tabTwo ON tabOne.colOne = tabTwo.colTwo"),
fixture("inlineQuery",
@ -65,7 +71,7 @@ public class JoinVisitorTestsUnitTest { @@ -65,7 +71,7 @@ public class JoinVisitorTestsUnitTest {
private static Fixture fixture(String comment, Join join, String renderResult) {
final Fixture fixture = new Fixture();
Fixture fixture = new Fixture();
fixture.comment = comment;
fixture.join = join;
fixture.renderResult = renderResult;

54
spring-data-relational/src/test/java/org/springframework/data/relational/core/sql/render/SelectRendererUnitTests.java

@ -29,10 +29,10 @@ import org.springframework.util.StringUtils; @@ -29,10 +29,10 @@ import org.springframework.util.StringUtils;
* @author Mark Paluch
* @author Jens Schauder
*/
public class SelectRendererUnitTests {
class SelectRendererUnitTests {
@Test // DATAJDBC-309, DATAJDBC-278
public void shouldRenderSingleColumn() {
void shouldRenderSingleColumn() {
Table bar = SQL.table("bar");
Column foo = bar.column("foo");
@ -43,7 +43,7 @@ public class SelectRendererUnitTests { @@ -43,7 +43,7 @@ public class SelectRendererUnitTests {
}
@Test
public void honorsNamingStrategy() {
void honorsNamingStrategy() {
Table bar = SQL.table("bar");
Column foo = bar.column("foo");
@ -55,7 +55,7 @@ public class SelectRendererUnitTests { @@ -55,7 +55,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldRenderAliasedColumnAndFrom() {
void shouldRenderAliasedColumnAndFrom() {
Table table = Table.create("bar").as("my_bar");
@ -65,7 +65,7 @@ public class SelectRendererUnitTests { @@ -65,7 +65,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldRenderMultipleColumnsFromTables() {
void shouldRenderMultipleColumnsFromTables() {
Table table1 = Table.create("table1");
Table table2 = Table.create("table2");
@ -77,7 +77,7 @@ public class SelectRendererUnitTests { @@ -77,7 +77,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldRenderDistinct() {
void shouldRenderDistinct() {
Table table = SQL.table("bar");
Column foo = table.column("foo");
@ -89,7 +89,7 @@ public class SelectRendererUnitTests { @@ -89,7 +89,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldRenderCountFunction() {
void shouldRenderCountFunction() {
Table table = SQL.table("bar");
Column foo = table.column("foo");
@ -101,7 +101,7 @@ public class SelectRendererUnitTests { @@ -101,7 +101,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-340
public void shouldRenderCountFunctionWithAliasedColumn() {
void shouldRenderCountFunctionWithAliasedColumn() {
Table table = SQL.table("bar");
Column foo = table.column("foo").as("foo_bar");
@ -112,7 +112,7 @@ public class SelectRendererUnitTests { @@ -112,7 +112,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldRenderSimpleJoin() {
void shouldRenderSimpleJoin() {
Table employee = SQL.table("employee");
Table department = SQL.table("department");
@ -126,7 +126,7 @@ public class SelectRendererUnitTests { @@ -126,7 +126,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-340
public void shouldRenderOuterJoin() {
void shouldRenderOuterJoin() {
Table employee = SQL.table("employee");
Table department = SQL.table("department");
@ -141,7 +141,7 @@ public class SelectRendererUnitTests { @@ -141,7 +141,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldRenderSimpleJoinWithAnd() {
void shouldRenderSimpleJoinWithAnd() {
Table employee = SQL.table("employee");
Table department = SQL.table("department");
@ -157,7 +157,7 @@ public class SelectRendererUnitTests { @@ -157,7 +157,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldRenderMultipleJoinWithAnd() {
void shouldRenderMultipleJoinWithAnd() {
Table employee = SQL.table("employee");
Table department = SQL.table("department");
@ -176,7 +176,7 @@ public class SelectRendererUnitTests { @@ -176,7 +176,7 @@ public class SelectRendererUnitTests {
}
@Test // GH-1003
public void shouldRenderJoinWithInlineQuery() {
void shouldRenderJoinWithInlineQuery() {
Table employee = SQL.table("employee");
Table department = SQL.table("department");
@ -199,7 +199,7 @@ public class SelectRendererUnitTests { @@ -199,7 +199,7 @@ public class SelectRendererUnitTests {
}
@Test // GH-1003
public void shouldRenderJoinWithTwoInlineQueries() {
void shouldRenderJoinWithTwoInlineQueries() {
Table employee = SQL.table("employee");
Table department = SQL.table("department");
@ -225,7 +225,7 @@ public class SelectRendererUnitTests { @@ -225,7 +225,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldRenderOrderByName() {
void shouldRenderOrderByName() {
Table employee = SQL.table("employee").as("emp");
Column column = employee.column("name").as("emp_name");
@ -237,7 +237,7 @@ public class SelectRendererUnitTests { @@ -237,7 +237,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldRenderIsNull() {
void shouldRenderIsNull() {
Table table = SQL.table("foo");
Column bar = table.column("bar");
@ -248,7 +248,7 @@ public class SelectRendererUnitTests { @@ -248,7 +248,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldRenderNotNull() {
void shouldRenderNotNull() {
Table table = SQL.table("foo");
Column bar = table.column("bar");
@ -259,7 +259,7 @@ public class SelectRendererUnitTests { @@ -259,7 +259,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldRenderEqualityCondition() {
void shouldRenderEqualityCondition() {
Table table = SQL.table("foo");
Column bar = table.column("bar");
@ -271,7 +271,7 @@ public class SelectRendererUnitTests { @@ -271,7 +271,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldRendersAndOrConditionWithProperParentheses() {
void shouldRendersAndOrConditionWithProperParentheses() {
Table table = SQL.table("foo");
Column bar = table.column("bar");
@ -285,7 +285,7 @@ public class SelectRendererUnitTests { @@ -285,7 +285,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldInWithNamedParameter() {
void shouldInWithNamedParameter() {
Table table = SQL.table("foo");
Column bar = table.column("bar");
@ -296,7 +296,7 @@ public class SelectRendererUnitTests { @@ -296,7 +296,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldInWithNamedParameters() {
void shouldInWithNamedParameters() {
Table table = SQL.table("foo");
Column bar = table.column("bar");
@ -308,7 +308,7 @@ public class SelectRendererUnitTests { @@ -308,7 +308,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldRenderInSubselect() {
void shouldRenderInSubselect() {
Table foo = SQL.table("foo");
Column bar = foo.column("bar");
@ -325,7 +325,7 @@ public class SelectRendererUnitTests { @@ -325,7 +325,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-309
public void shouldConsiderNamingStrategy() {
void shouldConsiderNamingStrategy() {
Table foo = SQL.table("Foo");
Column bar = foo.column("BaR");
@ -345,7 +345,7 @@ public class SelectRendererUnitTests { @@ -345,7 +345,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-340
public void shouldRenderCountStar() {
void shouldRenderCountStar() {
Select select = Select.builder() //
.select(Functions.count(Expressions.asterisk())) //
@ -358,7 +358,7 @@ public class SelectRendererUnitTests { @@ -358,7 +358,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-340
public void shouldRenderCountTableStar() {
void shouldRenderCountTableStar() {
Table foo = SQL.table("foo");
Select select = Select.builder() //
@ -372,7 +372,7 @@ public class SelectRendererUnitTests { @@ -372,7 +372,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-340
public void shouldRenderFunctionWithAlias() {
void shouldRenderFunctionWithAlias() {
Table foo = SQL.table("foo");
Select select = Select.builder() //
@ -386,7 +386,7 @@ public class SelectRendererUnitTests { @@ -386,7 +386,7 @@ public class SelectRendererUnitTests {
}
@Test // DATAJDBC-479
public void shouldRenderWithRenderContext() {
void shouldRenderWithRenderContext() {
Table table = Table.create(SqlIdentifier.quoted("my_table"));
Table join_table = Table.create(SqlIdentifier.quoted("join_table"));

48
spring-data-relational/src/test/java/org/springframework/data/relational/core/sql/render/TypedSubtreeVisitorUnitTests.java

@ -29,7 +29,7 @@ import org.springframework.data.relational.core.sql.Visitable; @@ -29,7 +29,7 @@ import org.springframework.data.relational.core.sql.Visitable;
/**
* Unit tests for {@link org.springframework.data.relational.core.sql.render.TypedSubtreeVisitor}.
*
*
* @author Jens Schauder
*/
class TypedSubtreeVisitorUnitTests {
@ -39,8 +39,8 @@ class TypedSubtreeVisitorUnitTests { @@ -39,8 +39,8 @@ class TypedSubtreeVisitorUnitTests {
@Test // GH-1003
void enterAndLeavesSingleSegment() {
final TypedSubtreeVisitor<TestSegment> visitor = new LoggingTypedSubtreeVisitor();
final TestSegment root = new TestSegment("root");
TypedSubtreeVisitor<TestSegment> visitor = new LoggingTypedSubtreeVisitor();
TestSegment root = new TestSegment("root");
root.visit(visitor);
@ -50,8 +50,8 @@ class TypedSubtreeVisitorUnitTests { @@ -50,8 +50,8 @@ class TypedSubtreeVisitorUnitTests {
@Test // GH-1003
void enterAndLeavesChainOfMatchingSegmentsAsNested() {
final TypedSubtreeVisitor<TestSegment> visitor = new LoggingTypedSubtreeVisitor();
final TestSegment root = new TestSegment("root", new TestSegment("level 1", new TestSegment("level 2")));
TypedSubtreeVisitor<TestSegment> visitor = new LoggingTypedSubtreeVisitor();
TestSegment root = new TestSegment("root", new TestSegment("level 1", new TestSegment("level 2")));
root.visit(visitor);
@ -62,8 +62,8 @@ class TypedSubtreeVisitorUnitTests { @@ -62,8 +62,8 @@ class TypedSubtreeVisitorUnitTests {
@Test // GH-1003
void enterAndLeavesMatchingChildrenAsNested() {
final TypedSubtreeVisitor<TestSegment> visitor = new LoggingTypedSubtreeVisitor();
final TestSegment root = new TestSegment("root", new TestSegment("child 1"), new TestSegment("child 2"));
TypedSubtreeVisitor<TestSegment> visitor = new LoggingTypedSubtreeVisitor();
TestSegment root = new TestSegment("root", new TestSegment("child 1"), new TestSegment("child 2"));
root.visit(visitor);
@ -74,8 +74,8 @@ class TypedSubtreeVisitorUnitTests { @@ -74,8 +74,8 @@ class TypedSubtreeVisitorUnitTests {
@Test // GH-1003
void enterAndLeavesChainOfOtherSegmentsAsNested() {
final TypedSubtreeVisitor<TestSegment> visitor = new LoggingTypedSubtreeVisitor();
final TestSegment root = new TestSegment("root", new OtherSegment("level 1", new OtherSegment("level 2")));
TypedSubtreeVisitor<TestSegment> visitor = new LoggingTypedSubtreeVisitor();
TestSegment root = new TestSegment("root", new OtherSegment("level 1", new OtherSegment("level 2")));
root.visit(visitor);
@ -86,8 +86,8 @@ class TypedSubtreeVisitorUnitTests { @@ -86,8 +86,8 @@ class TypedSubtreeVisitorUnitTests {
@Test // GH-1003
void enterAndLeavesOtherChildrenAsNested() {
final TypedSubtreeVisitor<TestSegment> visitor = new LoggingTypedSubtreeVisitor();
final TestSegment root = new TestSegment("root", new OtherSegment("child 1"), new OtherSegment("child 2"));
TypedSubtreeVisitor<TestSegment> visitor = new LoggingTypedSubtreeVisitor();
TestSegment root = new TestSegment("root", new OtherSegment("child 1"), new OtherSegment("child 2"));
root.visit(visitor);
@ -98,9 +98,9 @@ class TypedSubtreeVisitorUnitTests { @@ -98,9 +98,9 @@ class TypedSubtreeVisitorUnitTests {
@Test // GH-1003
void visitorIsReentrant() {
final LoggingTypedSubtreeVisitor visitor = new LoggingTypedSubtreeVisitor();
final TestSegment root1 = new TestSegment("root 1");
final TestSegment root2 = new TestSegment("root 2");
LoggingTypedSubtreeVisitor visitor = new LoggingTypedSubtreeVisitor();
TestSegment root1 = new TestSegment("root 1");
TestSegment root2 = new TestSegment("root 2");
root1.visit(visitor);
root2.visit(visitor);
@ -112,10 +112,10 @@ class TypedSubtreeVisitorUnitTests { @@ -112,10 +112,10 @@ class TypedSubtreeVisitorUnitTests {
@Test // GH-1003
void delegateToOtherVisitorOnEnterMatchedRevisitsTheSegment() {
final LoggingTypedSubtreeVisitor first = new LoggingTypedSubtreeVisitor("first ");
final LoggingTypedSubtreeVisitor second = new LoggingTypedSubtreeVisitor("second ");
LoggingTypedSubtreeVisitor first = new LoggingTypedSubtreeVisitor("first ");
LoggingTypedSubtreeVisitor second = new LoggingTypedSubtreeVisitor("second ");
first.enterMatched(s -> delegateTo(second));
final TestSegment root = new TestSegment("root", new TestSegment("child 1"), new TestSegment("child 2"));
TestSegment root = new TestSegment("root", new TestSegment("child 1"), new TestSegment("child 2"));
root.visit(first);
@ -127,11 +127,11 @@ class TypedSubtreeVisitorUnitTests { @@ -127,11 +127,11 @@ class TypedSubtreeVisitorUnitTests {
@Test // GH-1003
void delegateToOtherVisitorOnEnterNestedRevisitsTheNestedSegment() {
final LoggingTypedSubtreeVisitor first = new LoggingTypedSubtreeVisitor("first ");
final LoggingTypedSubtreeVisitor second = new LoggingTypedSubtreeVisitor("second ");
LoggingTypedSubtreeVisitor first = new LoggingTypedSubtreeVisitor("first ");
LoggingTypedSubtreeVisitor second = new LoggingTypedSubtreeVisitor("second ");
first.enterNested(
s -> ((TestSegment) s).name.equals("child 2") ? delegateTo(second) : DelegatingVisitor.Delegation.retain());
final TestSegment root = new TestSegment("root", new TestSegment("child 1"), new TestSegment("child 2"),
TestSegment root = new TestSegment("root", new TestSegment("child 1"), new TestSegment("child 2"),
new TestSegment("child 3"));
root.visit(first);
@ -144,7 +144,7 @@ class TypedSubtreeVisitorUnitTests { @@ -144,7 +144,7 @@ class TypedSubtreeVisitorUnitTests {
static class TestSegment extends AbstractTestSegment {
private final String name;
private String name;
TestSegment(String name, Segment... children) {
@ -160,7 +160,7 @@ class TypedSubtreeVisitorUnitTests { @@ -160,7 +160,7 @@ class TypedSubtreeVisitorUnitTests {
static class OtherSegment extends AbstractTestSegment {
private final String name;
private String name;
public OtherSegment(String name, Segment... children) {
@ -176,7 +176,7 @@ class TypedSubtreeVisitorUnitTests { @@ -176,7 +176,7 @@ class TypedSubtreeVisitorUnitTests {
class LoggingTypedSubtreeVisitor extends TypedSubtreeVisitor<TestSegment> {
final String prefix;
String prefix;
Function<TestSegment, Delegation> enterMatchedDelegation;
Function<Visitable, Delegation> enterNestedDelegation;
@ -192,7 +192,7 @@ class TypedSubtreeVisitorUnitTests { @@ -192,7 +192,7 @@ class TypedSubtreeVisitorUnitTests {
Delegation enterMatched(TestSegment segment) {
events.add(prefix + "enter matched " + segment);
final Delegation delegation = super.enterMatched(segment);
Delegation delegation = super.enterMatched(segment);
return enterMatchedDelegation == null ? delegation : enterMatchedDelegation.apply(segment);
}

Loading…
Cancel
Save