Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor MaskAlgorithmMetaData #28546

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class MaskResultDecoratorEngine implements ResultDecoratorEngine<Ma
public Optional<ResultDecorator<MaskRule>> newInstance(final ShardingSphereDatabase database,
final MaskRule maskRule, final ConfigurationProperties props, final SQLStatementContext sqlStatementContext) {
return sqlStatementContext instanceof SelectStatementContext
? Optional.of(new MaskDQLResultDecorator(new MaskAlgorithmMetaData(database, maskRule, (SelectStatementContext) sqlStatementContext)))
? Optional.of(new MaskDQLResultDecorator(new MaskAlgorithmMetaData(maskRule, (SelectStatementContext) sqlStatementContext)))
: Optional.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.shardingsphere.infra.binder.context.segment.select.projection.Projection;
import org.apache.shardingsphere.infra.binder.context.segment.select.projection.impl.ColumnProjection;
import org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.mask.rule.MaskRule;
import org.apache.shardingsphere.mask.spi.MaskAlgorithm;

Expand All @@ -35,8 +34,6 @@
@RequiredArgsConstructor
public final class MaskAlgorithmMetaData {

private final ShardingSphereDatabase database;

private final MaskRule maskRule;

private final SelectStatementContext selectStatementContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.shardingsphere.infra.binder.context.segment.select.projection.impl.ColumnProjection;
import org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mask.rule.MaskRule;
import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
Expand All @@ -43,9 +42,6 @@
@ExtendWith(MockitoExtension.class)
class MaskAlgorithmMetaDataTest {

@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ShardingSphereDatabase database;

@Mock
private MaskRule maskRule;

Expand All @@ -61,7 +57,7 @@ void assertFindMaskAlgorithmByColumnIndex() {
columnProjection.setOriginalTable(new IdentifierValue("t_order"));
when(selectStatementContext.getProjectionsContext().getExpandProjections()).thenReturn(Collections.singletonList(columnProjection));
when(selectStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("t_order"));
Optional<MaskAlgorithm> actual = new MaskAlgorithmMetaData(database, maskRule, selectStatementContext).findMaskAlgorithmByColumnIndex(1);
Optional<MaskAlgorithm> actual = new MaskAlgorithmMetaData(maskRule, selectStatementContext).findMaskAlgorithmByColumnIndex(1);
assertTrue(actual.isPresent());
assertThat(actual.get().getType(), is("MD5"));
}
Expand Down