Skip to content

Commit 1d31a17

Browse files
committed
Misc code cleanup
1 parent ad7254e commit 1d31a17

File tree

4 files changed

+9
-101
lines changed

4 files changed

+9
-101
lines changed

src/test/java/org/mybatis/dynamic/sql/insert/InsertStatementTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2018 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -137,7 +137,7 @@ public void testParallelStream() {
137137

138138
FieldAndValueCollector<TestRecord> collector =
139139
mappings.parallelStream().collect(Collector.of(
140-
() -> new FieldAndValueCollector<>(),
140+
FieldAndValueCollector::new,
141141
FieldAndValueCollector::add,
142142
FieldAndValueCollector::merge));
143143

src/test/java/org/mybatis/dynamic/sql/mybatis3/CriterionRendererTest.java

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2018 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -86,54 +86,6 @@ public void testAliasWithoutIgnore() {
8686
);
8787
}
8888

89-
@Test
90-
public void testNoAliasWithIgnore() {
91-
SqlTable table = SqlTable.of("foo");
92-
SqlColumn<Integer> column = table.column("id", JDBCType.INTEGER);
93-
IsEqualTo<Integer> condition = IsEqualTo.of(() -> 3);
94-
SqlCriterion<Integer> criterion = SqlCriterion.withColumn(column)
95-
.withCondition(condition)
96-
.build();
97-
AtomicInteger sequence = new AtomicInteger(1);
98-
FragmentAndParameters fp = CriterionRenderer.withCriterion(criterion)
99-
.withSequence(sequence)
100-
.withRenderingStrategy(RenderingStrategy.MYBATIS3)
101-
.withTableAliasCalculator(TableAliasCalculator.empty())
102-
.build()
103-
.render()
104-
.get()
105-
.renderWithInitialConnector();
106-
107-
assertAll(
108-
() -> assertThat(fp.fragment()).isEqualTo("id = #{parameters.p1,jdbcType=INTEGER}"),
109-
() -> assertThat(fp.parameters().size()).isEqualTo(1)
110-
);
111-
}
112-
113-
@Test
114-
public void testNoAliasWithoutIgnore() {
115-
SqlTable table = SqlTable.of("foo");
116-
SqlColumn<Integer> column = table.column("id", JDBCType.INTEGER);
117-
IsEqualTo<Integer> condition = IsEqualTo.of(() -> 3);
118-
SqlCriterion<Integer> criterion = SqlCriterion.withColumn(column)
119-
.withCondition(condition)
120-
.build();
121-
AtomicInteger sequence = new AtomicInteger(1);
122-
FragmentAndParameters fp = CriterionRenderer.withCriterion(criterion)
123-
.withSequence(sequence)
124-
.withRenderingStrategy(RenderingStrategy.MYBATIS3)
125-
.withTableAliasCalculator(TableAliasCalculator.empty())
126-
.build()
127-
.render()
128-
.get()
129-
.renderWithInitialConnector();
130-
131-
assertAll(
132-
() -> assertThat(fp.fragment()).isEqualTo("id = #{parameters.p1,jdbcType=INTEGER}"),
133-
() -> assertThat(fp.parameters().size()).isEqualTo(1)
134-
);
135-
}
136-
13789
@Test
13890
public void testTypeHandler() {
13991
SqlTable table = SqlTable.of("foo");
@@ -142,7 +94,7 @@ public void testTypeHandler() {
14294
.withJdbcType(JDBCType.DATE)
14395
.withTypeHandler("foo.Bar")
14496
.build();
145-
IsEqualTo<Date> condition = IsEqualTo.of(() -> new Date());
97+
IsEqualTo<Date> condition = IsEqualTo.of(Date::new);
14698
SqlCriterion<Date> criterion = SqlCriterion.withColumn(column)
14799
.withCondition(condition)
148100
.build();

src/test/java/org/mybatis/dynamic/sql/where/render/CriterionRendererTest.java

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2018 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -83,50 +83,4 @@ public void testAliasWithoutIgnore() {
8383
assertThat(fp.parameters().size()).isEqualTo(1);
8484
assertThat(fp.parameters().get("p1")).isEqualTo(3);
8585
}
86-
87-
@Test
88-
public void testNoAliasWithIgnore() {
89-
SqlTable table = SqlTable.of("foo");
90-
SqlColumn<Integer> column = table.column("id", JDBCType.INTEGER);
91-
IsEqualTo<Integer> condition = IsEqualTo.of(() -> 3);
92-
SqlCriterion<Integer> criterion = SqlCriterion.withColumn(column)
93-
.withCondition(condition)
94-
.build();
95-
AtomicInteger sequence = new AtomicInteger(1);
96-
FragmentAndParameters fp = CriterionRenderer.withCriterion(criterion)
97-
.withSequence(sequence)
98-
.withRenderingStrategy(RenderingStrategy.MYBATIS3)
99-
.withTableAliasCalculator(TableAliasCalculator.empty())
100-
.build()
101-
.render()
102-
.get()
103-
.renderWithInitialConnector();
104-
105-
assertThat(fp.fragment()).isEqualTo("id = #{parameters.p1,jdbcType=INTEGER}");
106-
assertThat(fp.parameters().size()).isEqualTo(1);
107-
assertThat(fp.parameters().get("p1")).isEqualTo(3);
108-
}
109-
110-
@Test
111-
public void testNoAliasWithoutIgnore() {
112-
SqlTable table = SqlTable.of("foo");
113-
SqlColumn<Integer> column = table.column("id", JDBCType.INTEGER);
114-
IsEqualTo<Integer> condition = IsEqualTo.of(() -> 3);
115-
SqlCriterion<Integer> criterion = SqlCriterion.withColumn(column)
116-
.withCondition(condition)
117-
.build();
118-
AtomicInteger sequence = new AtomicInteger(1);
119-
FragmentAndParameters fp = CriterionRenderer.withCriterion(criterion)
120-
.withSequence(sequence)
121-
.withRenderingStrategy(RenderingStrategy.MYBATIS3)
122-
.withTableAliasCalculator(TableAliasCalculator.empty())
123-
.build()
124-
.render()
125-
.get()
126-
.renderWithInitialConnector();
127-
128-
assertThat(fp.fragment()).isEqualTo("id = #{parameters.p1,jdbcType=INTEGER}");
129-
assertThat(fp.parameters().size()).isEqualTo(1);
130-
assertThat(fp.parameters().get("p1")).isEqualTo(3);
131-
}
13286
}

src/test/java/org/mybatis/dynamic/sql/where/render/OptionalCriterionRenderTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2018 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,8 @@
1919
import static org.junit.jupiter.api.Assertions.assertAll;
2020
import static org.mybatis.dynamic.sql.SqlBuilder.*;
2121

22+
import java.util.Objects;
23+
2224
import org.junit.jupiter.api.Test;
2325
import org.mybatis.dynamic.sql.SqlColumn;
2426
import org.mybatis.dynamic.sql.SqlTable;
@@ -48,7 +50,7 @@ public void testNoRenderableCriteria() {
4850
public void testNoRenderableCriteriaWithIf() {
4951
Integer nullId = null;
5052

51-
WhereClauseProvider whereClause = where(id, isEqualTo(nullId).when(v -> v != null))
53+
WhereClauseProvider whereClause = where(id, isEqualTo(nullId).when(Objects::nonNull))
5254
.build()
5355
.render(RenderingStrategy.SPRING_NAMED_PARAMETER);
5456

0 commit comments

Comments
 (0)