|
17 | 17 |
|
18 | 18 | package org.apache.shardingsphere.encrypt.rewrite.token;
|
19 | 19 |
|
20 |
| -import lombok.SneakyThrows; |
21 |
| -import org.apache.shardingsphere.encrypt.rewrite.aware.EncryptRuleAware; |
22 | 20 | import org.apache.shardingsphere.encrypt.rewrite.token.generator.projection.EncryptSelectProjectionTokenGenerator;
|
23 | 21 | import org.apache.shardingsphere.encrypt.rule.EncryptRule;
|
24 | 22 | import org.apache.shardingsphere.infra.binder.context.segment.select.orderby.OrderByItem;
|
|
29 | 27 | import org.junit.jupiter.api.extension.ExtendWith;
|
30 | 28 | import org.mockito.Answers;
|
31 | 29 | import org.mockito.Mock;
|
32 |
| -import org.mockito.internal.configuration.plugins.Plugins; |
33 | 30 | import org.mockito.junit.jupiter.MockitoExtension;
|
34 | 31 |
|
35 |
| -import java.lang.reflect.Field; |
36 | 32 | import java.util.Collection;
|
37 | 33 | import java.util.Collections;
|
38 | 34 | import java.util.Iterator;
|
@@ -64,30 +60,5 @@ void assertGetSQLTokenGenerators() {
|
64 | 60 | Iterator<SQLTokenGenerator> iterator = sqlTokenGenerators.iterator();
|
65 | 61 | SQLTokenGenerator item1 = iterator.next();
|
66 | 62 | assertThat(item1, instanceOf(EncryptSelectProjectionTokenGenerator.class));
|
67 |
| - assertSQLTokenGenerator(item1); |
68 |
| - } |
69 |
| - |
70 |
| - private void assertSQLTokenGenerator(final SQLTokenGenerator sqlTokenGenerator) { |
71 |
| - if (sqlTokenGenerator instanceof EncryptRuleAware) { |
72 |
| - assertField(sqlTokenGenerator, encryptRule, "encryptRule"); |
73 |
| - } |
74 |
| - } |
75 |
| - |
76 |
| - @SneakyThrows(ReflectiveOperationException.class) |
77 |
| - private void assertField(final SQLTokenGenerator sqlTokenGenerator, final Object filedInstance, final String fieldName) { |
78 |
| - assertThat(Plugins.getMemberAccessor().get(findField(sqlTokenGenerator.getClass(), fieldName, filedInstance.getClass()), sqlTokenGenerator), is(filedInstance)); |
79 |
| - } |
80 |
| - |
81 |
| - private Field findField(final Class<?> clazz, final String fieldName, final Class<?> fieldType) { |
82 |
| - Class<?> searchClass = clazz; |
83 |
| - while (null != searchClass && !Object.class.equals(searchClass)) { |
84 |
| - for (Field each : searchClass.getDeclaredFields()) { |
85 |
| - if (fieldName.equals(each.getName()) && fieldType.equals(each.getType())) { |
86 |
| - return each; |
87 |
| - } |
88 |
| - } |
89 |
| - searchClass = searchClass.getSuperclass(); |
90 |
| - } |
91 |
| - throw new IllegalStateException("No such field in class."); |
92 | 63 | }
|
93 | 64 | }
|
0 commit comments