Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lordofthejars/8a5ec5514e49e62557d246de67c47254 to your computer and use it in GitHub Desktop.
Save lordofthejars/8a5ec5514e49e62557d246de67c47254 to your computer and use it in GitHub Desktop.
@RunWith(SerenityRunner.class)
public class WhenSecurityServiceNeedsUsersInformation {
private String theRestApiBaseUrl;
private EnvironmentVariables environmentVariables;
private Actor securityService;
@Before
public void configureBaseUrl() {
theRestApiBaseUrl = environmentVariables.optionalProperty("restapi.baseurl")
.orElseThrow(IllegalArgumentException::new);
securityService = Actor.named("Security service").whoCan(CallAnApi.at(theRestApiBaseUrl));
}
@Test
public void list_all_users() {
securityService.attemptsTo(
UserTasks.listAllUsers()
);
securityService.should(
seeThatResponse("all the expected users should be returned",
response -> response.statusCode(200)
.body("data.first_name", hasItems("George", "Janet", "Emma")))
);
}
@Test
public void find_an_individual_user() {
securityService.attemptsTo(
FindAUser.withId(1)
);
securityService.should(
seeThatResponse( "User details should be correct",
response -> response.statusCode(200)
.body("data.first_name", equalTo("George"))
.body("data.last_name", equalTo("Bluth"))
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment