33import static com .github .tomakehurst .wiremock .client .WireMock .urlPathEqualTo ;
44import static com .truelayer .java .Constants .Scopes .SIGNUP_PLUS ;
55import static com .truelayer .java .TestUtils .assertNotError ;
6+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
7+ import static org .junit .jupiter .api .Assertions .assertTrue ;
68
79import com .truelayer .java .TestUtils .RequestStub ;
810import com .truelayer .java .http .entities .ApiResponse ;
9- import com .truelayer .java .signupplus .entities .Address ;
10- import com .truelayer .java .signupplus .entities .Sex ;
11- import com .truelayer .java .signupplus .entities .UserData ;
11+ import com .truelayer .java .signupplus .entities .*;
1212import java .util .Collections ;
1313import lombok .SneakyThrows ;
1414import org .junit .jupiter .api .Assertions ;
@@ -51,9 +51,8 @@ public void shouldGetUserDataByPaymentUk() {
5151 Assertions .assertEquals ("Holmes" , response .getData ().getLastName ().orElseThrow ());
5252 Assertions .assertEquals (
5353 "1854-01-06" , response .getData ().getDateOfBirth ().orElseThrow ());
54- Assertions .assertTrue (response .getData ().getSex ().isEmpty ());
55- Assertions .assertTrue (
56- response .getData ().getNationalIdentificationNumber ().isEmpty ());
54+ assertTrue (response .getData ().getSex ().isEmpty ());
55+ assertTrue (response .getData ().getNationalIdentificationNumber ().isEmpty ());
5756 Address address = response .getData ().getAddress ().orElseThrow ();
5857 Assertions .assertEquals ("221B Baker St" , address .getAddressLine1 ().orElseThrow ());
5958 Assertions .assertEquals ("Flat 2" , address .getAddressLine2 ().orElseThrow ());
@@ -89,7 +88,7 @@ public void shouldGetUserDataByPaymentFinland() {
8988 verifyGeneratedToken (Collections .singletonList (SIGNUP_PLUS ));
9089 assertNotError (response );
9190
92- Assertions . assertTrue (response .getData ().getTitle ().isEmpty ());
91+ assertTrue (response .getData ().getTitle ().isEmpty ());
9392 Assertions .assertEquals ("Väinö" , response .getData ().getFirstName ().orElseThrow ());
9493 Assertions .assertEquals ("Tunnistus" , response .getData ().getLastName ().orElseThrow ());
9594 Assertions .assertEquals (
@@ -100,10 +99,40 @@ public void shouldGetUserDataByPaymentFinland() {
10099 response .getData ().getNationalIdentificationNumber ().orElseThrow ());
101100 Address address = response .getData ().getAddress ().orElseThrow ();
102101 Assertions .assertEquals ("Sepänkatu 11 A 5" , address .getAddressLine1 ().orElseThrow ());
103- Assertions . assertTrue (address .getAddressLine2 ().isEmpty ());
102+ assertTrue (address .getAddressLine2 ().isEmpty ());
104103 Assertions .assertEquals ("KUOPIO" , address .getCity ().orElseThrow ());
105- Assertions . assertTrue (address .getState ().isEmpty ());
104+ assertTrue (address .getState ().isEmpty ());
106105 Assertions .assertEquals ("70100" , address .getZip ().orElseThrow ());
107106 Assertions .assertEquals ("FI" , address .getCountry ().orElseThrow ());
108107 }
108+
109+ @ Test
110+ @ DisplayName ("It should generate an auth URI for a payment in Finland" )
111+ @ SneakyThrows
112+ public void shouldGenerateAuthUriByPaymentFinland () {
113+ String jsonResponseFile = "signup_plus/200.generate_auth_uri.json" ;
114+ RequestStub .New ()
115+ .method ("post" )
116+ .path (urlPathEqualTo ("/connect/token" ))
117+ .status (200 )
118+ .bodyFile ("auth/200.access_token.json" )
119+ .build ();
120+ RequestStub .New ()
121+ .method ("post" )
122+ .path (urlPathEqualTo ("/signup-plus/authuri" ))
123+ .withAuthorization ()
124+ .status (200 )
125+ .bodyFile (jsonResponseFile )
126+ .build ();
127+
128+ ApiResponse <GenerateAuthUriResponse > response = tlClient .signupPlus ()
129+ .generateAuthUri (
130+ GenerateAuthUriRequest .builder ().paymentId (A_PAYMENT_ID ).build ())
131+ .get ();
132+
133+ verifyGeneratedToken (Collections .singletonList (SIGNUP_PLUS ));
134+ assertNotError (response );
135+ assertNotNull (response .getData ().getAuthUri ());
136+ assertTrue (response .getData ().getAuthUri ().toString ().contains ("truelayer.com" ));
137+ }
109138}
0 commit comments