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
区分signature错误和ak错误 #99
Conversation
75f1b63
to
d7feb68
Compare
try { | ||
client.distinguishError(request, error, baseResponse); | ||
} catch (Exception e) { | ||
Assert.assertEquals("500 : ServerException", e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果上面没有抛错呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果期待报错,用ExpectedException来做
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
distinguishError()这个方法建议改成private的,不能为了方便测试而改成public的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DefaultAcsClient不太适合提供distinguishError的功能,并且暴露给用户,这个函数建议可以放到工具类里面,这样也容易测试
try { | ||
client.distinguishError(request, error, baseResponse); | ||
} catch (Exception e) { | ||
Assert.assertEquals("InvalidAccessSecret : Specified Access Key Secret is not valid.", e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review 的时候说过多少次了 InvalidAccessKeySecret 不是 InvalidAccessSecret
try { | ||
client.distinguishError(request, error, baseResponse); | ||
} catch (ClientException e) { | ||
Assert.fail(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里要断言,code 不是 InvalidAccessKeySecret
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有2个小问题要修改下
Mockito.when(error.getErrorCode()).thenReturn("error"); | ||
try { | ||
client.distinguishError(request, error, baseResponse); | ||
} catch (ClientException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上。
} | ||
} | ||
|
||
public void distinguishError(AcsRequest request, AcsError error, HttpResponse baseResponse) throws ClientException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public -> private 是不是好一点
d7feb68
to
cef5ff6
Compare
} | ||
} | ||
|
||
public <T extends AcsResponse> T distinguishError(AcsRequest<T> request, AcsError error, HttpResponse baseResponse) throws ClientException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
说了一天了 这个 public 还在。
cef5ff6
to
8d2abf5
Compare
Codecov Report
@@ Coverage Diff @@
## master #99 +/- ##
============================================
+ Coverage 70.92% 71.77% +0.84%
- Complexity 845 856 +11
============================================
Files 88 88
Lines 3006 3015 +9
Branches 305 308 +3
============================================
+ Hits 2132 2164 +32
+ Misses 809 782 -27
- Partials 65 69 +4
Continue to review full report at Codecov.
|
4e0b973
to
9785f50
Compare
+1 |
No description provided.