-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add EncryptTableMapperRuleTest * Add ShardingTableMapperRuleTest * Add BroadcastTableMapperRuleTest * Add MaskTableMapperRuleTest * Add MaskTableMapperRuleTest * Add SingleTableMapperRuleTest
- Loading branch information
Showing
7 changed files
with
257 additions
and
36 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
.../src/test/java/org/apache/shardingsphere/broadcast/rule/BroadcastTableMapperRuleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.broadcast.rule; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Collections; | ||
import java.util.LinkedList; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
class BroadcastTableMapperRuleTest { | ||
|
||
private final BroadcastTableMapperRule tableMapperRule = new BroadcastTableMapperRule(Collections.singleton("foo_tbl")); | ||
|
||
@Test | ||
void assertGetLogicTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getLogicTableMapper().getTableNames()), is(Collections.singletonList("foo_tbl"))); | ||
} | ||
|
||
@Test | ||
void assertGetDistributedTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getDistributedTableMapper().getTableNames()), is(Collections.singletonList("foo_tbl"))); | ||
} | ||
|
||
@Test | ||
void assertGetEnhancedTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getEnhancedTableMapper().getTableNames()), is(Collections.emptyList())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptTableMapperRuleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.encrypt.rule; | ||
|
||
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Collections; | ||
import java.util.LinkedList; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
class EncryptTableMapperRuleTest { | ||
|
||
private final EncryptTableMapperRule tableMapperRule = new EncryptTableMapperRule(Collections.singleton(new EncryptTableRuleConfiguration("foo_tbl", Collections.emptyList()))); | ||
|
||
@Test | ||
void assertGetLogicTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getLogicTableMapper().getTableNames()), is(Collections.singletonList("foo_tbl"))); | ||
} | ||
|
||
@Test | ||
void assertGetDistributedTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getDistributedTableMapper().getTableNames()), is(Collections.emptyList())); | ||
} | ||
|
||
@Test | ||
void assertGetEnhancedTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getEnhancedTableMapper().getTableNames()), is(Collections.singletonList("foo_tbl"))); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
.../mask/core/src/test/java/org/apache/shardingsphere/mask/rule/MaskTableMapperRuleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.mask.rule; | ||
|
||
import org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Collections; | ||
import java.util.LinkedList; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
class MaskTableMapperRuleTest { | ||
|
||
private final MaskTableMapperRule tableMapperRule = new MaskTableMapperRule(Collections.singleton(new MaskTableRuleConfiguration("foo_tbl", Collections.emptyList()))); | ||
|
||
@Test | ||
void assertGetLogicTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getLogicTableMapper().getTableNames()), is(Collections.singletonList("foo_tbl"))); | ||
} | ||
|
||
@Test | ||
void assertGetDistributedTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getDistributedTableMapper().getTableNames()), is(Collections.emptyList())); | ||
} | ||
|
||
@Test | ||
void assertGetEnhancedTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getEnhancedTableMapper().getTableNames()), is(Collections.emptyList())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...re/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingTableMapperRuleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.sharding.rule; | ||
|
||
import org.apache.shardingsphere.infra.datanode.DataNode; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Collections; | ||
import java.util.LinkedList; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class ShardingTableMapperRuleTest { | ||
|
||
private ShardingTableMapperRule tableMapperRule; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
ShardingTable shardingTable = mock(ShardingTable.class); | ||
when(shardingTable.getLogicTable()).thenReturn("foo_tbl"); | ||
when(shardingTable.getActualDataNodes()).thenReturn(Collections.singletonList(new DataNode("foo_ds.foo_tbl_0"))); | ||
tableMapperRule = new ShardingTableMapperRule(Collections.singletonMap("foo_tbl", shardingTable)); | ||
} | ||
|
||
@Test | ||
void assertGetLogicTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getLogicTableMapper().getTableNames()), is(Collections.singletonList("foo_tbl"))); | ||
} | ||
|
||
@Test | ||
void assertGetActualTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getActualTableMapper().getTableNames()), is(Collections.singletonList("foo_tbl_0"))); | ||
} | ||
|
||
@Test | ||
void assertGetDistributedTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getDistributedTableMapper().getTableNames()), is(Collections.singletonList("foo_tbl"))); | ||
} | ||
|
||
@Test | ||
void assertGetEnhancedTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getEnhancedTableMapper().getTableNames()), is(Collections.singletonList("foo_tbl"))); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...e/core/src/test/java/org/apache/shardingsphere/single/rule/SingleTableMapperRuleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.shardingsphere.single.rule; | ||
|
||
import org.apache.shardingsphere.infra.datanode.DataNode; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Collections; | ||
import java.util.LinkedList; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
class SingleTableMapperRuleTest { | ||
|
||
private final SingleTableMapperRule tableMapperRule = new SingleTableMapperRule(Collections.singletonMap("foo_tbl", Collections.singleton(new DataNode("foo_ds.foo_tbl")))); | ||
|
||
@Test | ||
void assertGetLogicTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getLogicTableMapper().getTableNames()), is(Collections.singletonList("foo_tbl"))); | ||
} | ||
|
||
@Test | ||
void assertGetDistributedTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getDistributedTableMapper().getTableNames()), is(Collections.emptyList())); | ||
} | ||
|
||
@Test | ||
void assertGetEnhancedTableMapper() { | ||
assertThat(new LinkedList<>(tableMapperRule.getEnhancedTableMapper().getTableNames()), is(Collections.emptyList())); | ||
} | ||
} |