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 RestApiTest and TestCase #17775

Merged
merged 3 commits into from
Jul 17, 2023
Merged

Conversation

007DXR
Copy link
Contributor

@007DXR 007DXR commented Jul 14, 2023

What changes are proposed in this pull request?

I refactor RestApiTest and TestCase. I wrap the method to create TestCase instance.

Why are the changes needed?

In the former, every unit test creates a TestCase instance like this.

HttpURLConnection connection = new TestCase(mHostname, mPort, mBaseUri,
        bucketUri, NO_PARAMS, HttpMethod.PUT,
        options).execute();
    Assert.assertEquals(Response.Status.CONFLICT.getStatusCode(), connection.getResponseCode());
    S3Error response =
        new XmlMapper().readerFor(S3Error.class).readValue(connection.getErrorStream());
    Assert.assertEquals(S3ErrorCode.Name.BUCKET_ALREADY_EXISTS, response.getCode());

It's too ugly and unreadable.
now you can use the following instead of above.

 createBucketTestCase(bucketName).checkResponseCode(Status.CONFLICT.getStatusCode())
        .checkErrorCode(S3ErrorCode.Name.BUCKET_ALREADY_EXISTS);

Does this PR introduce any user facing changes?

none.

@007DXR
Copy link
Contributor Author

007DXR commented Jul 14, 2023

@Jackson-Wang-7 ask for review

@Jackson-Wang-7 Jackson-Wang-7 self-requested a review July 17, 2023 02:35
Copy link
Contributor

@Jackson-Wang-7 Jackson-Wang-7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! looks good to me

}

String result = runAndGetResponse();
System.out.println(result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the println

@Jackson-Wang-7 Jackson-Wang-7 added the type-code-quality code quality improvement label Jul 17, 2023
@Jackson-Wang-7
Copy link
Contributor

alluxio-bot, merge this please

@alluxio-bot alluxio-bot merged commit 9792513 into Alluxio:main Jul 17, 2023
15 checks passed
@007DXR 007DXR deleted the object-operation branch July 17, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-code-quality code quality improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants