-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #284 from Backbase/CB-10685-add-user-profile-data-…
…for-transaction-signing-2 CB-10685 Add user profile data for TX2
- Loading branch information
Showing
5 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/main/java/com/backbase/ct/bbfuel/client/user/UserMockRestClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.backbase.ct.bbfuel.client.user; | ||
|
||
import static org.apache.http.HttpStatus.SC_CREATED; | ||
import static org.apache.http.HttpStatus.SC_NO_CONTENT; | ||
|
||
import com.backbase.ct.bbfuel.client.common.RestClient; | ||
import com.backbase.ct.bbfuel.config.BbFuelConfiguration; | ||
import com.backbase.ct.bbfuel.data.UserProfileData; | ||
import io.restassured.http.ContentType; | ||
import io.restassured.response.Response; | ||
import javax.annotation.PostConstruct; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class UserMockRestClient extends RestClient { | ||
|
||
private final BbFuelConfiguration config; | ||
private static final String SERVICE_VERSION = "v2"; | ||
private static final String ENDPOINT_ADD_USER_PROFILE_DATA = "/users/profile/mock/%s"; | ||
|
||
@PostConstruct | ||
public void init() { | ||
setBaseUri(config.getDbs().getUsermock()); | ||
setVersion(SERVICE_VERSION); | ||
} | ||
|
||
public void addUserProfileData(String userId) { | ||
Response response = addPhoneAndElectronicAddressesData(userId); | ||
if (response.statusCode() == SC_NO_CONTENT) { | ||
log.info("User profile data is updated for user [{}]", userId); | ||
} else if (response.statusCode() == SC_CREATED) { | ||
log.info("User profile data is added for user [{}]", userId); | ||
} else { | ||
log.info("User profile data could not be added for user [{}]", userId); | ||
} | ||
} | ||
|
||
private Response addPhoneAndElectronicAddressesData(String userId) { | ||
return requestSpec() | ||
.given() | ||
.contentType(ContentType.JSON) | ||
.body(UserProfileData.getPhoneAndElectronicAddressData()) | ||
.put(String.format(getPath(ENDPOINT_ADD_USER_PROFILE_DATA), userId)) | ||
.andReturn(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,15 @@ public class UserProfileData { | |
private static final String USER_PROFILE_POST_REQUEST_STRING = | ||
"{ \"userId\": \"%s\", \"externalId\": \"%s\", \"userName\": \"%s\", \"name\": { \"formatted\": \"Mr. Account Statement Tester, Senior\", \"familyName\": \"Tester\", \"givenName\": \"Account\", \"middleName\": \"Statement\", \"honorificPrefix\": \"Mr.\", \"honorificSuffix\": \"Senior\" }, \"displayName\": \"AS Tester\", \"nickName\": \"AST\", \"profileUrl\": \"https://facebook.com/astester\", \"personalInformation\": { \"gender\": \"Male\", \"dateOfBirth\": \"01/01/1990\", \"countryOfBirth\": \"PL\", \"countryOfResidence\": \"PL\", \"nationalities\": [ \"PL, NL\" ], \"maritalStatus\": \"married\", \"educationLevel\": null, \"employer\": \"Backbase Poland\", \"employmentStatus\": \"Contractor\" }, \"identificationDetails\": [ { \"value\": \"9001010101011\", \"type\": \"PESEL\", \"issueDate\": null, \"expiryDate\": null, \"issueCountryCode\": \"PL\" } ], \"title\": \"QA Engineer\", \"userType\": \"Contractor\", \"preferredLanguage\": \"pl-PL\", \"locale\": \"pl-PL\", \"timezone\": \"America/Los_Angeles\", \"active\": true, \"emails\": [ { \"value\": \"[email protected]\", \"display\": null, \"type\": \"work\", \"primary\": true } ], \"phoneNumbers\": [ { \"value\": \"604604604\", \"display\": null, \"type\": \"work\", \"primary\": true } ], \"ims\": [ { \"value\": \"slack/backbase\", \"display\": null, \"type\": \"aim\", \"primary\": true } ], \"photos\": [ { \"value\": \"http://imgagestock/12345\", \"display\": null, \"type\": \"photo\", \"primary\": null } ], \"addresses\": [ { \"formatted\": \"Pawia 100, 31111 Cracow, Poland\", \"streetAddress\": \"Pawia 100\", \"locality\": \"Cracow\", \"region\": \"Lesser Poland\", \"postalCode\": \"31111\", \"country\": \"Poland\", \"type\": \"work\", \"primary\": true } ], \"x509Certificates\": [ { \"value\": \"MIIDQzCCAqygAwIBAgICEAAwDQYJKoZIhvcNAQEFBQAwTjELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFDASBgNVBAoMC2V4YW1wbGUuY29tMRQwEgYDVQQDDAtleGFtcGxlLmNvbTAeFw0xMTEwMjIwNjI0MzFaFw0xMjEwMDQwNjI0MzFaMH8xCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRQwEgYDVQQKDAtleGFtcGxlLmNvbTEhMB8GA1UEAwwYTXMuIEJhcmJhcmEgSiBKZW5zZW4gSUlJMSIwIAYJKoZIhvcNAQkBFhNiamVuc2VuQGV4YW1wbGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7Kr\", \"display\": null, \"type\": null, \"primary\": null } ], \"extended\": { \"my-custom-reference-id\": \"Banky-McBankFace\" } }"; | ||
|
||
private static final String USER_PROFILE_PHONE_AND_ELECTRONIC_ADDRESSES_STRING = | ||
"{ \"phone-addresses\": [ { \"key\": \"1\", \"type\": \"work\", \"primary\": true, \"number\": \"+441115556667\" }, { \"key\": \"2\", \"type\": \"home\", \"primary\": false, \"number\": \"022222222\" } ], \"electronic-addresses\": [ { \"key\": \"3\", \"type\": \"work\", \"primary\": true, \"address\": \"[email protected]\" }, { \"key\": \"4\", \"type\": \"home\", \"primary\": false, \"address\": \"test.test\" } ], \"postal-addresses\": [ ] }"; | ||
|
||
|
||
public static String getUserProfileData(String userId, String externalId) { | ||
return String.format(USER_PROFILE_POST_REQUEST_STRING, userId, externalId, externalId); | ||
} | ||
|
||
public static String getPhoneAndElectronicAddressData() { | ||
return USER_PROFILE_PHONE_AND_ELECTRONIC_ADDRESSES_STRING; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters