Skip to content

Commit 39f029c

Browse files
committed
Coverage
1 parent 2269855 commit 39f029c

File tree

3 files changed

+95
-8
lines changed

3 files changed

+95
-8
lines changed

src/main/java/org/mybatis/dynamic/sql/insert/render/FieldAndValueAndParameters.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ public String valuePhrase() {
3838
return valuePhrase;
3939
}
4040

41-
public String valuePhrase(int row) {
42-
return String.format(valuePhrase, row);
43-
}
44-
4541
public Map<String, Object> parameters() {
4642
return parameters;
4743
}

src/main/java/org/mybatis/dynamic/sql/util/ColumnMappingVisitor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ public interface ColumnMappingVisitor<T> {
3333
T visit(StringConstantMapping mapping);
3434

3535
default <R> T visit(ValueMapping<R> mapping) {
36-
return null;
36+
throw new UnsupportedOperationException();
3737
}
3838

3939
default T visit(SelectMapping mapping) {
40-
return null;
40+
throw new UnsupportedOperationException();
4141
}
4242

4343
default T visit(PropertyMapping mapping) {
44-
return null;
44+
throw new UnsupportedOperationException();
4545
}
4646

4747
default T visit(ColumnToColumnMapping columnMapping) {
48-
return null;
48+
throw new UnsupportedOperationException();
4949
}
5050
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/**
2+
* Copyright 2016-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.mybatis.dynamic.sql.util;
17+
18+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
19+
20+
import org.junit.jupiter.api.Test;
21+
import org.mybatis.dynamic.sql.SqlBuilder;
22+
import org.mybatis.dynamic.sql.SqlColumn;
23+
import org.mybatis.dynamic.sql.SqlTable;
24+
25+
public class ColumnMappingVisitorTest {
26+
27+
@Test
28+
public void testThatUnimplementedMethod1ThrowExceptions() {
29+
TestTable table = new TestTable();
30+
TestVisitor tv = new TestVisitor();
31+
ColumnToColumnMapping mapping = ColumnToColumnMapping.of(table.id, table.description);
32+
33+
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> tv.visit(mapping));
34+
}
35+
36+
@Test
37+
public void testThatUnimplementedMethod2ThrowExceptions() {
38+
TestTable table = new TestTable();
39+
TestVisitor tv = new TestVisitor();
40+
ValueMapping<Integer> mapping = ValueMapping.of(table.id, () -> 3);
41+
42+
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> tv.visit(mapping));
43+
}
44+
45+
@Test
46+
public void testThatUnimplementedMethod3ThrowExceptions() {
47+
TestTable table = new TestTable();
48+
TestVisitor tv = new TestVisitor();
49+
SelectMapping mapping = SelectMapping.of(table.id, SqlBuilder.select(table.id).from(table));
50+
51+
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> tv.visit(mapping));
52+
}
53+
54+
@Test
55+
public void testThatUnimplementedMethod4ThrowExceptions() {
56+
TestTable table = new TestTable();
57+
TestVisitor tv = new TestVisitor();
58+
PropertyMapping mapping = PropertyMapping.of(table.id, "id");
59+
60+
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> tv.visit(mapping));
61+
}
62+
63+
private static class TestTable extends SqlTable {
64+
public SqlColumn<Integer> id;
65+
public SqlColumn<String> description;
66+
67+
public TestTable() {
68+
super("Test");
69+
70+
id = column("id");
71+
description = column("description");
72+
}
73+
}
74+
75+
private static class TestVisitor implements ColumnMappingVisitor<String> {
76+
@Override
77+
public String visit(NullMapping mapping) {
78+
return "Null Mapping";
79+
}
80+
81+
@Override
82+
public String visit(ConstantMapping mapping) {
83+
return "Constant Mapping";
84+
}
85+
86+
@Override
87+
public String visit(StringConstantMapping mapping) {
88+
return "String Constant Mapping";
89+
}
90+
}
91+
}

0 commit comments

Comments
 (0)