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

TrueLayer / truelayer-java / #100

17 Oct 2024 12:55PM UTC coverage: 89.676%. First build
#100

Pull #322

github

dili91
acceptance test for SU+ uk
Pull Request #322: Adds support for Signup+ and fixes a few PayIn/Out asymmetries with our public API reference

7 of 11 new or added lines in 3 files covered. (63.64%)

443 of 494 relevant lines covered (89.68%)

0.9 hits per line

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

75.0
/src/main/java/com/truelayer/java/TrueLayerClient.java
1
package com.truelayer.java;
2

3
import com.truelayer.java.auth.IAuthenticationHandler;
4
import com.truelayer.java.commonapi.ICommonHandler;
5
import com.truelayer.java.commonapi.entities.SubmitPaymentsProviderReturnRequest;
6
import com.truelayer.java.commonapi.entities.SubmitPaymentsProviderReturnResponse;
7
import com.truelayer.java.hpp.IHostedPaymentPageLinkBuilder;
8
import com.truelayer.java.http.entities.ApiResponse;
9
import com.truelayer.java.mandates.IMandatesHandler;
10
import com.truelayer.java.merchantaccounts.IMerchantAccountsHandler;
11
import com.truelayer.java.payments.IPaymentsHandler;
12
import com.truelayer.java.paymentsproviders.IPaymentsProvidersHandler;
13
import com.truelayer.java.payouts.IPayoutsHandler;
14
import com.truelayer.java.signupplus.ISignupPlusHandler;
15
import java.util.concurrent.CompletableFuture;
16
import lombok.AllArgsConstructor;
17
import org.apache.commons.lang3.ObjectUtils;
18

19
/**
20
 * Main class that holds TrueLayer API client. Should be built with the help of its builder
21
 * class. Acts as entrypoint for the Java client library capabilities.
22
 *
23
 * @see TrueLayerClientBuilder
24
 */
25
@AllArgsConstructor
26
public class TrueLayerClient implements ITrueLayerClient {
27

28
    private IAuthenticationHandler authenticationHandler;
29
    private IPaymentsHandler paymentsHandler;
30
    private IPaymentsProvidersHandler paymentsProvidersHandler;
31
    private IMerchantAccountsHandler merchantAccountsHandler;
32
    private IMandatesHandler mandatesHandler;
33
    private IPayoutsHandler payoutsHandler;
34
    private ISignupPlusHandler signupPlusHandler;
35
    private ICommonHandler commonHandler;
36

37
    private IHostedPaymentPageLinkBuilder hostedPaymentPageLinkBuilder;
38

39
    public TrueLayerClient(
40
            IAuthenticationHandler authenticationHandler,
41
            IHostedPaymentPageLinkBuilder hostedPaymentPageLinkBuilder,
42
            ICommonHandler commonHandler) {
1✔
43
        this.authenticationHandler = authenticationHandler;
1✔
44
        this.hostedPaymentPageLinkBuilder = hostedPaymentPageLinkBuilder;
1✔
45
        this.commonHandler = commonHandler;
1✔
46
    }
1✔
47

48
    /**
49
     * Static utility to return a builder instance.
50
     * @return an instance of the TrueLayer API client builder.
51
     */
52
    public static TrueLayerClientBuilder New() {
53
        return new TrueLayerClientBuilder();
1✔
54
    }
55

56
    /**
57
     * {@inheritDoc}
58
     */
59
    @Override
60
    public IAuthenticationHandler auth() {
61
        return this.authenticationHandler;
1✔
62
    }
63

64
    /**
65
     * {@inheritDoc}
66
     */
67
    @Override
68
    public IPaymentsHandler payments() {
69
        if (ObjectUtils.isEmpty(paymentsHandler)) {
1✔
70
            throw buildInitializationException("payments");
1✔
71
        }
72
        return paymentsHandler;
1✔
73
    }
74

75
    /**
76
     * {@inheritDoc}
77
     */
78
    @Override
79
    public IPaymentsProvidersHandler paymentsProviders() {
80
        if (ObjectUtils.isEmpty(paymentsProvidersHandler)) {
×
81
            throw buildInitializationException("payment providers");
×
82
        }
83
        return paymentsProvidersHandler;
×
84
    }
85

86
    /**
87
     * {@inheritDoc}
88
     */
89
    @Override
90
    public IMerchantAccountsHandler merchantAccounts() {
91
        if (ObjectUtils.isEmpty(merchantAccountsHandler)) {
1✔
92
            throw buildInitializationException("merchant accounts");
1✔
93
        }
94
        return merchantAccountsHandler;
1✔
95
    }
96

97
    @Override
98
    public IMandatesHandler mandates() {
99
        if (ObjectUtils.isEmpty(mandatesHandler)) {
1✔
100
            throw buildInitializationException("mandates");
1✔
101
        }
102
        return mandatesHandler;
1✔
103
    }
104

105
    @Override
106
    public IPayoutsHandler payouts() {
107
        if (ObjectUtils.isEmpty(payoutsHandler)) {
1✔
108
            throw buildInitializationException("payouts");
1✔
109
        }
110
        return payoutsHandler;
1✔
111
    }
112

113
    @Override
114
    public ISignupPlusHandler signupPlus() {
NEW
115
        if (ObjectUtils.isEmpty(signupPlusHandler)) {
×
NEW
116
            throw buildInitializationException("signup plus");
×
117
        }
NEW
118
        return signupPlusHandler;
×
119
    }
120

121
    /**
122
     * {@inheritDoc}
123
     */
124
    @Override
125
    public IHostedPaymentPageLinkBuilder hpp() {
126
        return this.hostedPaymentPageLinkBuilder;
1✔
127
    }
128

129
    /**
130
     * {@inheritDoc}
131
     */
132
    @Override
133
    public CompletableFuture<ApiResponse<SubmitPaymentsProviderReturnResponse>> submitPaymentReturnParameters(
134
            SubmitPaymentsProviderReturnRequest request) {
135
        return commonHandler.submitPaymentReturnParameters(request);
×
136
    }
137

138
    private TrueLayerException buildInitializationException(String handlerName) {
139
        return new TrueLayerException(String.format(
1✔
140
                "%s handler not initialized."
141
                        + " Make sure you specified the required signing options while initializing the library",
142
                handlerName));
143
    }
144
}
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