Skip to content

Commit

Permalink
Fix compile error (#28608)
Browse files Browse the repository at this point in the history
* Refactor ResourceMetaData

* Refactor ResourceMetaData

* Fix compile error

* Fix compile error
  • Loading branch information
terrymanu authored Sep 27, 2023
1 parent d21f3e8 commit b695780
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ShardingRuleStatementCheckerTest {

private final ShardingRuleConfiguration shardingRuleConfig = createShardingRuleConfiguration();

private final ResourceMetaData resourceMetaData = new ResourceMetaData("sharding_db", createDataSource());
private final ResourceMetaData resourceMetaData = new ResourceMetaData(createDataSource());

@BeforeEach
void before() {
Expand All @@ -84,7 +84,7 @@ void before() {
}

@Test
void assertCheckCreatSuccess() {
void assertCheckCreateSuccess() {
Collection<AbstractTableRuleSegment> rules = new LinkedList<>();
rules.add(createCompleteAutoTableRule());
rules.add(createCompleteTableRule());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class AlterShardingTableRuleStatementUpdaterTest {

private final ShardingRuleConfiguration currentRuleConfig = createCurrentShardingRuleConfiguration();

private final ResourceMetaData resourceMetaData = new ResourceMetaData("sharding_db", createDataSource());
private final ResourceMetaData resourceMetaData = new ResourceMetaData(createDataSource());

private final AlterShardingTableRuleStatementUpdater updater = new AlterShardingTableRuleStatementUpdater();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class CreateShardingTableRuleStatementUpdaterTest {
@BeforeEach
void before() {
when(database.getName()).thenReturn("schema");
ResourceMetaData resourceMetaData = new ResourceMetaData("sharding_db", createDataSource());
ResourceMetaData resourceMetaData = new ResourceMetaData(createDataSource());
when(database.getResourceMetaData()).thenReturn(resourceMetaData);
when(database.getRuleMetaData()).thenReturn(new RuleMetaData(Collections.singleton(new MockDataSourceContainedRule())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void assertExecuteWithPreparedStatement() throws SQLException {

private ShardingSphereDatabase createDatabase(final Map<String, String> expectedResultSetMap) throws SQLException {
return new ShardingSphereDatabase("auth_db", TypedSPILoader.getService(DatabaseType.class, "FIXTURE"),
new ResourceMetaData("sharding_db", Collections.singletonMap("foo_ds", new MockedDataSource(mockConnection(expectedResultSetMap)))),
new ResourceMetaData(Collections.singletonMap("foo_ds", new MockedDataSource(mockConnection(expectedResultSetMap)))),
mock(RuleMetaData.class), Collections.emptyMap());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private ShardingSphereDatabase mockDatabase() {
RuleMetaData ruleMetaData = new RuleMetaData(
Arrays.asList(mockShardingRule(), mockReadwriteSplittingRule(), mockEncryptRule(), mockShadowRule(), mockMaskRule()));
when(result.getRuleMetaData()).thenReturn(ruleMetaData);
ResourceMetaData resourceMetaData = new ResourceMetaData("sharding_db", Collections.singletonMap("foo_ds", new MockedDataSource()));
ResourceMetaData resourceMetaData = new ResourceMetaData(Collections.singletonMap("foo_ds", new MockedDataSource()));
when(result.getResourceMetaData()).thenReturn(resourceMetaData);
return result;
}
Expand Down Expand Up @@ -154,7 +154,7 @@ void assertGetEmptyRowData() {
private ShardingSphereDatabase mockEmptyDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class);
when(result.getRuleMetaData()).thenReturn(new RuleMetaData(Collections.emptyList()));
ResourceMetaData resourceMetaData = new ResourceMetaData("sharding_db", Collections.singletonMap("empty_ds", new MockedDataSource()));
ResourceMetaData resourceMetaData = new ResourceMetaData(Collections.singletonMap("empty_ds", new MockedDataSource()));
when(result.getResourceMetaData()).thenReturn(resourceMetaData);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ShowStorageUnitExecutorTest {

@BeforeEach
void before() {
ResourceMetaData resourceMetaData = new ResourceMetaData("sharding_db", createDataSources());
ResourceMetaData resourceMetaData = new ResourceMetaData(createDataSources());
RuleMetaData metaData = new RuleMetaData(Collections.singleton(createShardingRule()));
when(database.getResourceMetaData()).thenReturn(resourceMetaData);
when(database.getRuleMetaData()).thenReturn(metaData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void assertCreateWithOtherSelectStatementForNoResource() {

@Test
void assertCreateWithOtherSelectStatementForDatabaseName() {
ResourceMetaData resourceMetaData = new ResourceMetaData("sharding_db", Collections.singletonMap("ds", new MockedDataSource()));
ResourceMetaData resourceMetaData = new ResourceMetaData(Collections.singletonMap("ds", new MockedDataSource()));
ShardingSphereDatabase database = new ShardingSphereDatabase("db_0", databaseType, resourceMetaData, mock(RuleMetaData.class), Collections.emptyMap());
Map<String, ShardingSphereDatabase> result = Collections.singletonMap("db_0", database);
initProxyContext(result);
Expand All @@ -282,7 +282,7 @@ void assertCreateWithOtherSelectStatementForDatabaseName() {

@Test
void assertCreateWithOtherSelectStatementForNullDatabaseName() {
ResourceMetaData resourceMetaData = new ResourceMetaData("sharding_db", Collections.singletonMap("ds_0", new MockedDataSource()));
ResourceMetaData resourceMetaData = new ResourceMetaData(Collections.singletonMap("ds_0", new MockedDataSource()));
ShardingSphereDatabase database = new ShardingSphereDatabase("db_0", databaseType, resourceMetaData, mock(RuleMetaData.class), Collections.emptyMap());
Map<String, ShardingSphereDatabase> result = Collections.singletonMap("db_0", database);
initProxyContext(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ private ShardingSphereDatabase createDatabase(final String databaseName, final R
}

private ShardingSphereDatabase createDatabase(final String databaseName) {
return createDatabase(databaseName, new ResourceMetaData(databaseName, Collections.emptyMap()));
return createDatabase(databaseName, new ResourceMetaData(Collections.emptyMap()));
}

private ShardingSphereDatabase createDatabase(final Map<String, String> expectedResultSetMap) throws SQLException {
return createDatabase("auth_db", new ResourceMetaData("auth_db", Collections.singletonMap("foo_ds", new MockedDataSource(mockConnection(expectedResultSetMap)))));
return createDatabase("auth_db", new ResourceMetaData(Collections.singletonMap("foo_ds", new MockedDataSource(mockConnection(expectedResultSetMap)))));
}

private Connection mockConnection(final Map<String, String> expectedResultSetMap) throws SQLException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private ContextManager mockContextManager() {
ShardingSphereSchema schema = new ShardingSphereSchema();
schema.getTables().put("user", table);
ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db", TypedSPILoader.getService(DatabaseType.class, "MySQL"),
new ResourceMetaData("foo_db", Collections.emptyMap()), new RuleMetaData(Collections.emptyList()), Collections.singletonMap("foo_db", schema));
new ResourceMetaData(Collections.emptyMap()), new RuleMetaData(Collections.emptyList()), Collections.singletonMap("foo_db", schema));
when(result.getMetaDataContexts().getMetaData().getDatabase("foo_db")).thenReturn(database);
when(result.getMetaDataContexts().getMetaData().containsDatabase("foo_db")).thenReturn(true);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private MetaDataContexts mockMetaDataContexts() {
ShardingSphereSchema schema = new ShardingSphereSchema();
schema.getTables().put("t", table);
ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db", TypedSPILoader.getService(DatabaseType.class, "MySQL"),
new ResourceMetaData("foo_db", Collections.emptyMap()), new RuleMetaData(Collections.emptyList()), Collections.singletonMap("foo_db", schema));
new ResourceMetaData(Collections.emptyMap()), new RuleMetaData(Collections.emptyList()), Collections.singletonMap("foo_db", schema));
when(result.getMetaData().getDatabase("foo_db")).thenReturn(database);
when(result.getMetaData().containsDatabase("foo_db")).thenReturn(true);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private ContextManager mockContextManager() {
schema.getTables().put("t_test", testTable);
schema.getTables().put("sbtest1", sbTestTable);
ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db", TypedSPILoader.getService(DatabaseType.class, "PostgreSQL"),
new ResourceMetaData("foo_db", Collections.emptyMap()), new RuleMetaData(Collections.emptyList()), Collections.singletonMap("public", schema));
new ResourceMetaData(Collections.emptyMap()), new RuleMetaData(Collections.emptyList()), Collections.singletonMap("public", schema));
when(result.getMetaDataContexts().getMetaData().getDatabase("foo_db")).thenReturn(database);
when(result.getMetaDataContexts().getMetaData().containsDatabase("foo_db")).thenReturn(true);
return result;
Expand Down

0 comments on commit b695780

Please sign in to comment.