add spring-trpc junit by chenhao26-nineteen · Pull Request #36 · trpc-group/trpc-java
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
|
|
||
|
|
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多余空行,下面也是,一般只有一个空行
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i fix it
| } | ||
|
|
||
| @Test | ||
| public void testEmptyIfNull() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数可以通过AddFilterTRpcConfigManagerCustomizer构造函数测,尽量减少使用setAccessible。
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i fix it
| } | ||
|
|
||
| @Test | ||
| public void testMerge() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数可以通过customize函数测,尽量减少使用setAccessible。
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i fix it
| Assert.assertEquals((long) value, addFilterTRpcConfigManagerCustomizer.getOrder()); | ||
| } | ||
|
|
||
| static final class AddFilterTRpcConfigManagerCustomizer2 extends AddFilterTRpcConfigManagerCustomizer { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议不用出现1 2 3这种数字的命名,可以命名为TestFilterConfigManagerCustomizer
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i fix it
| public void testGetOrder() { | ||
| AddFilterTRpcConfigManagerCustomizer addFilterTRpcConfigManagerCustomizer = new AddFilterTRpcConfigManagerCustomizer2(); | ||
| Assert.assertEquals(Integer.MAX_VALUE, addFilterTRpcConfigManagerCustomizer.getOrder()); | ||
| Integer value = 1024; |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
把这个定义为常量,getOrder里面直接返回常量就行。
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i fix it
|
|
||
| @Test | ||
| public void testGetOrder() { | ||
| AddFilterTRpcConfigManagerCustomizer addFilterTRpcConfigManagerCustomizer = new AddFilterTRpcConfigManagerCustomizer2(); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new AddFilterTRpcConfigManagerCustomizer();然后断言
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i fix it
|
|
||
| @Override | ||
| public int getOrder() { | ||
| return System.getProperty(KEY) == null ? super.getOrder() : Integer.parseInt(System.getProperty(KEY)); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
返回一个固定值就行
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i fix it
| public void testAddClientFilters() { | ||
| AddFilterTRpcConfigManagerCustomizer addFilterTRpcConfigManagerCustomizer = new AddFilterTRpcConfigManagerCustomizer(); | ||
| AddFilterTRpcConfigManagerCustomizer customizer = addFilterTRpcConfigManagerCustomizer.addClientFilters( | ||
| "filter1", "filter2"); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议这些字符串也提取为常量
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i fix it
|
|
||
| @Test | ||
| public void testConstructorWithNullEmpty() { | ||
| addFilterTRpcConfigManagerCustomizer.addClientFilters(FILTER_ONE, FILTER_TWO); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这一行可以移动到L95行之后
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| } | ||
|
|
||
| @Test | ||
| public void testConstructorWithNullEmpty() { |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数是测emptyIfNull,可以在new AddFilterTRpcConfigManagerCustomizer(null, null);后,向clientFilters和serverFilters添加插件,然后断言
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
This file contains hidden or 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