diff --git a/src/test/java/io/securecodebox/persistence/defectdojo/service/UserProfileServiceTest.java b/src/test/java/io/securecodebox/persistence/defectdojo/service/UserProfileServiceTest.java index 3e5d7382..75347c5e 100644 --- a/src/test/java/io/securecodebox/persistence/defectdojo/service/UserProfileServiceTest.java +++ b/src/test/java/io/securecodebox/persistence/defectdojo/service/UserProfileServiceTest.java @@ -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": "user@example.com", - "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": "user@example.com", + "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); + } }