Created
April 8, 2013 13:51
-
-
Save roughy/5336904 to your computer and use it in GitHub Desktop.
Delete Profile DocTest example
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
class ProfileDocTest extends com.devbliss.doctest.DocTest { | |
... | |
/** | |
* Write a test annotated method like you would do for a common junit test | |
*/ | |
@Test | |
public void testDeleteProfile() { | |
/* | |
* Introduce the delete-profile endpoint to the reader of your documentation. | |
* Create a default profile to setup your test. This will be invisible for the reader of your documentation. | |
*/ | |
sayNextSection("Delete a profile"); | |
say("A user with admin rights can delete a profile."); | |
createDefaultProfile(); // internal convinience method to handle test profiles | |
/* | |
* Show the profile of interest to the reader of your documentation. | |
*/ | |
say("We want to delete the profile with the id \"" + profile.id + "\"."); | |
final ApiResponse response1 = makeGetRequest(buildUri("api/v1/profile/" + profile.id)); | |
assertEquals(HttpStatus.SC_OK, response1.httpStatus); | |
/* | |
* Do the request of your interest and test everything you think is important. | |
*/ | |
say("A request to the delete-profile endpoint with the correct rigths and " | |
+ "an existing profile id will end up in a response with the status code " + HttpStatus.SC_NO_CONTENT); | |
final ApiResponse response2 = makeDeleteRequest(buildUri("api/v1/profile/" + profile.id)); | |
assertEquals(HttpStatus.SC_NO_CONTENT, response2.httpStatus); | |
/* | |
* Show how the response of the GET endpoint changed after the DELETE request was successful. | |
*/ | |
say("After the deleting of a profile was successful the request to get the profile with the id \"" | |
+ profile.id + "\" will end up in a response with the status code " + HttpStatus.SC_NOT_FOUND); | |
final ApiResponse response3 = makeGetRequest(buildUri("api/v1/profile/" + profile.id)); | |
assertEqualsAndSay(HttpStatus.SC_NOT_FOUND, response3.httpStatus, "The profile is not found since it has been deleted."); | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment