ExecutionContextBuilder { public static Collection<ExecutionUnit> build(final ShardingSphereMetaData metaData, final SQLRewriteResult sqlRewriteResult, final SQLStatementContext<?> sqlStatementContext) { return sqlRewriteResult instanceof GenericSQLRewriteResult ? build(metaData, (GenericSQLRewriteResult) sqlRewriteResult, sqlStatementContext) : build(metaData, (RouteSQLRewriteResult) sqlRewriteResult); }  static Collection<ExecutionUnit> build(final ShardingSphereMetaData metaData, final SQLRewriteResult sqlRewriteResult, final SQLStatementContext<?> sqlStatementContext);  }
@Test public void assertBuildGenericSQLRewriteResult() { String sql = "sql"; List<Object> parameters = Collections.singletonList("parameter"); GenericSQLRewriteResult genericSQLRewriteResult = new GenericSQLRewriteResult(new SQLRewriteUnit(sql, parameters)); DataSourcesMetaData dataSourcesMetaData = mock(DataSourcesMetaData.class); String firstDataSourceName = "firstDataSourceName"; when(dataSourcesMetaData.getAllInstanceDataSourceNames()).thenReturn(Arrays.asList(firstDataSourceName, "lastDataSourceName")); ShardingSphereMetaData metaData = new ShardingSphereMetaData(dataSourcesMetaData, buildRuleSchemaMetaData(), mock(CachedDatabaseMetaData.class)); Collection<ExecutionUnit> actual = ExecutionContextBuilder.build(metaData, genericSQLRewriteResult, mock(SQLStatementContext.class)); Collection<ExecutionUnit> expected = Collections.singletonList(new ExecutionUnit(firstDataSourceName, new SQLUnit(sql, parameters))); assertThat(actual, is(expected)); }