Skip to content

Commit

Permalink
#23 Clean Code
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Strittmatter <[email protected]>
  • Loading branch information
Weltraumschaf committed Feb 2, 2024
1 parent 09d1f1c commit 85e5cf5
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.ArrayList;
import java.util.List;

public class UserProfileService extends GenericDefectDojoService<UserProfile> {
public final class UserProfileService extends GenericDefectDojoService<UserProfile> {

public UserProfileService(Config config) {
super(config);
Expand All @@ -31,16 +31,15 @@ protected Class<UserProfile> getModelClass() {

@Override
protected PaginatedResult<UserProfile> deserializeList(String response) throws JsonProcessingException {
// GenericDefectDojoService expects that the response from the defectdojo api is a list
// This endpoint returns a single object though, to not break the code this response gets converted to a defectdojo response
UserProfile userProfile = this.objectMapper.readValue(response, new TypeReference<>() {
/* GenericDefectDojoService expects that the response from the defectdojo api is a list.
* This endpoint returns a single object though, to not break the code this response
* gets converted to a defectdojo response.
*/
final var userProfile = this.objectMapper.readValue(response, new TypeReference<UserProfile>() {
});
List<UserProfile> userProfileList = new ArrayList<>();
userProfileList.add(userProfile);

PaginatedResult<UserProfile> fakeResult = new PaginatedResult<>();
fakeResult.setResults(userProfileList);
fakeResult.setCount(1);
return fakeResult;
final var result = new PaginatedResult<UserProfile>();
result.setResults(List.of(userProfile));
result.setCount(1);
return result;
}
}

0 comments on commit 85e5cf5

Please sign in to comment.