• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Adyen / adyen-java-api-library / #2672

02 Oct 2023 09:05AM CUT coverage: 12.623%. First build
#2672

push

web-flow
Merge ffa762935 into 28b29e141

125 of 125 new or added lines in 24 files covered. (100.0%)

11051 of 87544 relevant lines covered (12.62%)

0.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/adyen/httpclient/AdyenResponseHandler.java
1
/*
2
 *                       ######
3
 *                       ######
4
 * ############    ####( ######  #####. ######  ############   ############
5
 * #############  #####( ######  #####. ######  #############  #############
6
 *        ######  #####( ######  #####. ######  #####  ######  #####  ######
7
 * ###### ######  #####( ######  #####. ######  #####  #####   #####  ######
8
 * ###### ######  #####( ######  #####. ######  #####          #####  ######
9
 * #############  #############  #############  #############  #####  ######
10
 *  ############   ############  #############   ############  #####  ######
11
 *                                      ######
12
 *                               #############
13
 *                               ############
14
 *
15
 * Adyen Java API Library
16
 *
17
 * Copyright (c) 2021 Adyen B.V.
18
 * This file is open source and available under the MIT license.
19
 * See the LICENSE file for more info.
20
 */
21
package com.adyen.httpclient;
22

23
import org.apache.hc.core5.http.ClassicHttpResponse;
24
import org.apache.hc.core5.http.Header;
25
import org.apache.hc.core5.http.HttpEntity;
26
import org.apache.hc.core5.http.ParseException;
27
import org.apache.hc.core5.http.io.HttpClientResponseHandler;
28
import org.apache.hc.core5.http.io.entity.EntityUtils;
29

30
import java.io.IOException;
31
import java.util.Collections;
32
import java.util.HashMap;
33
import java.util.List;
34
import java.util.Map;
35

36
public class AdyenResponseHandler implements HttpClientResponseHandler<AdyenResponse> {
×
37

38
    @Override
39
    public AdyenResponse handleResponse(ClassicHttpResponse httpResponse) throws IOException, ParseException {
40
        AdyenResponse adyenResponse = new AdyenResponse();
×
41
        adyenResponse.setStatus(httpResponse.getCode());
×
42
        adyenResponse.setHeaders(getHeaders(httpResponse.getHeaders()));
×
43

44
        HttpEntity entity = httpResponse.getEntity();
×
45
        if (entity != null) {
×
46
            adyenResponse.setBody(EntityUtils.toString(entity));
×
47
        }
48
        return adyenResponse;
×
49
    }
50

51
    private Map<String, List<String>> getHeaders(Header[] allHeaders) {
52
        Map<String, List<String>> headers = new HashMap<>();
×
53
        for (Header header : allHeaders) {
×
54
            headers.put(header.getName(), Collections.singletonList(header.getValue()));
×
55
        }
56
        return headers;
×
57
    }
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc