Skip to content

Commit

Permalink
Reformatting
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Strittmatter <[email protected]>
  • Loading branch information
Weltraumschaf committed Jan 26, 2024
1 parent eb42a7b commit 67f9f52
Showing 1 changed file with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,45 +27,45 @@
// but the generic code assumes every endpoint returns a list
class UserProfileServiceTest {

private Config config;
private UserProfileService underTest;
private MockRestServiceServer mockServer;
private Config config;
private UserProfileService underTest;
private MockRestServiceServer mockServer;

// This string does not contain every field of the api response as those are not implemented
private String apiResponse = """
{
"user": {
"id": 0,
"username": "GdqmXprK.j7R+OYE49SzL3mM2U6I0DyLRHnDg87i9It0AfP-kxvswW3qOI2i+31-@0",
"first_name": "string",
"last_name": "string",
"email": "[email protected]",
"last_login": "2022-11-01T16:20:19.373Z",
"is_active": true,
"is_superuser": true,
"configuration_permissions": [0]
}
}
""";

@BeforeEach
void setup() {
config = new Config("https://defectdojo.example.com", "abc", 42);
underTest = new UserProfileService(config);
mockServer = MockRestServiceServer.createServer(underTest.getRestTemplate());
// This string does not contain every field of the api response as those are not implemented
private String apiResponse = """
{
"user": {
"id": 0,
"username": "GdqmXprK.j7R+OYE49SzL3mM2U6I0DyLRHnDg87i9It0AfP-kxvswW3qOI2i+31-@0",
"first_name": "string",
"last_name": "string",
"email": "[email protected]",
"last_login": "2022-11-01T16:20:19.373Z",
"is_active": true,
"is_superuser": true,
"configuration_permissions": [0]
}
}
""";

@Test
void testSearch() throws JsonProcessingException, URISyntaxException {
var url = config.getUrl() + "/api/v2/" + underTest.getUrlPath() + "/?offset=0&limit=100";
mockServer.expect(requestTo(url)).andRespond(withSuccess(apiResponse, MediaType.APPLICATION_JSON));
@BeforeEach
void setup() {
config = new Config("https://defectdojo.example.com", "abc", 42);
underTest = new UserProfileService(config);
mockServer = MockRestServiceServer.createServer(underTest.getRestTemplate());
}

var user = new User(0L, "GdqmXprK.j7R+OYE49SzL3mM2U6I0DyLRHnDg87i9It0AfP-kxvswW3qOI2i+31-@0", "string", "string");
var userProfile = new UserProfile(user);
var expected = Arrays.asList(userProfile);
var actual = underTest.search();
@Test
void testSearch() throws JsonProcessingException, URISyntaxException {
var url = config.getUrl() + "/api/v2/" + underTest.getUrlPath() + "/?offset=0&limit=100";
mockServer.expect(requestTo(url)).andRespond(withSuccess(apiResponse, MediaType.APPLICATION_JSON));

mockServer.verify();
assertIterableEquals(expected, actual);
}
var user = new User(0L, "GdqmXprK.j7R+OYE49SzL3mM2U6I0DyLRHnDg87i9It0AfP-kxvswW3qOI2i+31-@0", "string", "string");
var userProfile = new UserProfile(user);
var expected = Arrays.asList(userProfile);
var actual = underTest.search();

mockServer.verify();
assertIterableEquals(expected, actual);
}
}

0 comments on commit 67f9f52

Please sign in to comment.