Created
December 28, 2018 14:49
-
-
Save lordofthejars/8a5ec5514e49e62557d246de67c47254 to your computer and use it in GitHub Desktop.
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
@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