sijie commented on a change in pull request #3168: Refactor api commands
URL: https://github.com/apache/pulsar/pull/3168#discussion_r243146167
##########
File path:
pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/rest/api/v2/SinkApiV2ResourceTest.java
##########
@@ -180,54 +182,69 @@ public void setup() throws Exception {
// Register Functions
//
- @Test
- public void testRegisterSinkMissingTenant() throws IOException {
- testRegisterSinkMissingArguments(
- null,
- namespace,
- sink,
- mockedInputStream,
- mockedFormData,
- topicsToSerDeClassName,
- className,
- parallelism,
+ @Test(expectedExceptions = RestException.class,
expectedExceptionsMessageRegExp = "Tenant is not provided")
+ public void testRegisterSinkMissingTenant() {
+ try {
+ testRegisterSinkMissingArguments(
null,
- "Tenant is not provided");
+ namespace,
+ sink,
+ mockedInputStream,
+ mockedFormData,
+ topicsToSerDeClassName,
+ className,
+ parallelism,
+ null
+ );
+ } catch (RestException re){
+ assertEquals(re.getResponse().getStatusInfo(),
Response.Status.BAD_REQUEST);
+ throw re;
Review comment:
keep all assertions in one place. you already catch the exception here, you
should also validate `@Test(expectedExceptions = RestException.class,
expectedExceptionsMessageRegExp = "Tenant is not provided")` rather than
rethrowing the exception and use a different way to do assertions.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services