Skip to content

Commit 46854d8

Browse files
the-simmonWeltraumschaf
authored andcommitted
Convert user profile response to defectdojoresponse class
Signed-off-by: Simon Hülkenberg <simon.huelkenberg@iteratec.com>
1 parent a489a8b commit 46854d8

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/main/java/io/securecodebox/persistence/defectdojo/service/UserProfileService.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@
1717
*/
1818
package io.securecodebox.persistence.defectdojo.service;
1919

20+
import java.util.ArrayList;
21+
import java.util.List;
22+
2023
import com.fasterxml.jackson.core.JsonProcessingException;
2124
import com.fasterxml.jackson.core.type.TypeReference;
25+
2226
import io.securecodebox.persistence.defectdojo.config.DefectDojoConfig;
2327
import io.securecodebox.persistence.defectdojo.models.DefectDojoResponse;
2428
import io.securecodebox.persistence.defectdojo.models.UserProfile;
@@ -41,7 +45,15 @@ protected Class<UserProfile> getModelClass() {
4145

4246
@Override
4347
protected DefectDojoResponse<UserProfile> deserializeList(String response) throws JsonProcessingException {
44-
return this.objectMapper.readValue(response, new TypeReference<>() {});
48+
// GenericDefectDojoService expects that the response from the defectdojo api is a list
49+
// This endpoint returns a single object though, to not break the code this response gets converted to a defectdojo response
50+
UserProfile userProfile = this.objectMapper.readValue(response, new TypeReference<>() {});
51+
List<UserProfile> userProfileList = new ArrayList<>();
52+
userProfileList.add(userProfile);
53+
54+
DefectDojoResponse<UserProfile> fakeResult = new DefectDojoResponse<>();
55+
fakeResult.setResults(userProfileList);
56+
fakeResult.setCount(1);
57+
return fakeResult;
4558
}
46-
4759
}

0 commit comments

Comments
 (0)