提交 8dcc1039 编写于 作者: N nancyzrh 提交者: Liang Zhang

remove two methods and change xml for tableAssert (#3228)

* test for git corrupt

* remove repeate integration cases

* remove method and change xml for tableAssert

* fix form
上级 a1dcdf1d
......@@ -23,12 +23,7 @@ import org.apache.shardingsphere.core.parse.integrate.jaxb.table.ExpectedTable;
import org.apache.shardingsphere.core.parse.sql.segment.generic.TableSegment;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
......@@ -50,33 +45,12 @@ public final class TableAssert {
* @param expected expected tables
*/
public void assertTables(final Collection<TableSegment> actual, final List<ExpectedTable> expected) {
Collection<TableSegment> mergedActual = mergeTableSegments(actual);
Map<String, ExpectedTable> expectedMap = getExpectedMap(expected);
assertThat(assertMessage.getFullAssertMessage("Tables size assertion error: "), mergedActual.size(), is(expectedMap.size()));
for (TableSegment each : mergedActual) {
assertThat(assertMessage.getFullAssertMessage("Table name assertion error: "), each.getTableName(), is(expectedMap.get(each.getTableName()).getName()));
assertThat(assertMessage.getFullAssertMessage("Table alias assertion error: "), each.getAlias().orNull(), is(expectedMap.get(each.getTableName()).getAlias()));
}
}
// TODO yanan remove this method and make sure the table number of xml is correct
private Collection<TableSegment> mergeTableSegments(final Collection<TableSegment> actual) {
Collection<TableSegment> result = new LinkedList<>();
Set<String> tableNames = new HashSet<>(actual.size(), 1);
assertThat(assertMessage.getFullAssertMessage("Tables size assertion error: "), actual.size(), is(expected.size()));
int count = 0;
for (TableSegment each : actual) {
if (tableNames.add(each.getTableName())) {
result.add(each);
}
}
return result;
}
// TODO yanan remove this method and make sure the seq of xml is correct
private Map<String, ExpectedTable> getExpectedMap(final List<ExpectedTable> expected) {
Map<String, ExpectedTable> result = new HashMap<>(expected.size(), 1);
for (ExpectedTable each : expected) {
result.put(each.getName(), each);
assertThat(assertMessage.getFullAssertMessage("Table name assertion error: "), each.getTableName(), is(expected.get(count).getName()));
assertThat(assertMessage.getFullAssertMessage("Table alias assertion error: "), each.getAlias().orNull(), is(expected.get(count).getAlias()));
count++;
}
return result;
}
}
......@@ -34,4 +34,10 @@ public final class ExpectedTable {
@XmlAttribute
private String alias;
@XmlAttribute(name = "start-index")
private int startIndex;
@XmlAttribute(name = "stop-index")
private int stopIndex;
}
......@@ -501,7 +501,8 @@
<parser-result sql-case-id="create_table_with_create_index">
<tables>
<table name="t_order" />
<table name="t_order" start-index="13" stop-index="19" />
<table name="t_order" start-index="95" stop-index="101" />
</tables>
<tokens>
<table-token start-index="13" table-name="t_order" length="7" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册