use of com.forgerock.openbanking.common.model.data.FRUserData in project openbanking-aspsp by OpenBankingToolkit.
the class FakeDataApiController method generateFakeData.
@Override
public ResponseEntity generateFakeData(@RequestParam("userId") String userId, @RequestParam("username") String username, @RequestParam(name = "profile", required = false) String profile) throws OBErrorException {
log.debug("generateFakeData called for userId/username '{}:{}', with profile '{}' ", userId, username, profile);
if (RANDOM_PROFILE_ID.equals(profile)) {
log.debug("generateFakeData() generating random data");
return ResponseEntity.status(HttpStatus.CREATED).body(generateRandomData(userId, username));
} else {
log.debug("generateFakeData() generating from profile '{}'", profile);
Optional<DataConfigurationProperties.DataTemplateProfile> any = dataConfig.getProfiles().stream().filter(t -> t.getId().equals(profile)).findAny();
if (!any.isPresent()) {
throw new OBErrorException(OBRIErrorType.DATA_INVALID_REQUEST, "Profile '" + profile + "' doesn't exist.");
}
DataConfigurationProperties.DataTemplateProfile dataTemplateProfile = any.get();
FRUserData template = getTemplate(dataTemplateProfile.getTemplate(), username);
template.setUserName(username);
return dataController.importUserData(template);
}
}
use of com.forgerock.openbanking.common.model.data.FRUserData in project openbanking-aspsp by OpenBankingToolkit.
the class UserDataService method generateUserData.
public FRUserData generateUserData(String userId, String profile) {
LOGGER.debug("Generate data for user {}", userId);
HttpEntity request = new HttpEntity<>(null, new HttpHeaders());
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(rsStoreRoot + "/api/fake-data/generate");
builder.queryParam("userId", userId);
builder.queryParam("username", userId);
builder.queryParam("profile", profile);
URI uri = builder.build().encode().toUri();
return restTemplate.exchange(uri, HttpMethod.POST, request, FRUserData.class).getBody();
}
use of com.forgerock.openbanking.common.model.data.FRUserData in project openbanking-aspsp by OpenBankingToolkit.
the class UserDataService method updateUserData.
public FRUserData updateUserData(FRUserData userData) {
LOGGER.debug("Update data for w user {}", userData);
HttpEntity request = new HttpEntity<>(userData, new HttpHeaders());
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(rsStoreRoot + "/api/data/user");
URI uri = builder.build().encode().toUri();
return restTemplate.exchange(uri, HttpMethod.PUT, request, FRUserData.class).getBody();
}
use of com.forgerock.openbanking.common.model.data.FRUserData in project openbanking-aspsp by OpenBankingToolkit.
the class DataApiControllerIT method shouldCreateNewDataUsingUpdate.
@Test
public void shouldCreateNewDataUsingUpdate() throws Exception {
// Given
OBAccount6 account = new OBAccount6().accountId(UUID.randomUUID().toString());
List<FRAccountData> accountDatas = Collections.singletonList(FRAccountData.builder().account(account).balances(Collections.singletonList(new OBCashBalance1())).build());
FRAccount savedAccount = frAccountRepository.save(FRAccount.builder().id(account.getAccountId()).userID(UUID.randomUUID().toString()).build());
FRUserData userData = new FRUserData();
userData.setAccountDatas(accountDatas);
userData.setUserName(savedAccount.getUserID());
// When
mockMvc.perform(put("/api/data/user").content(mapper.writeValueAsString(userData)).contentType("application/json")).andExpect(status().isOk());
}
use of com.forgerock.openbanking.common.model.data.FRUserData in project openbanking-aspsp by OpenBankingToolkit.
the class DataApiControllerIT method shouldReturnPayloadTooLargeWhenCreatingNewData.
@Test
public void shouldReturnPayloadTooLargeWhenCreatingNewData() throws Exception {
// Given
OBAccount6 account = new OBAccount6().accountId(UUID.randomUUID().toString());
List<FRAccountData> accountDatas = Collections.singletonList(FRAccountData.builder().account(account).balances(Arrays.asList(new OBCashBalance1(), new OBCashBalance1())).build());
FRUserData userData = new FRUserData();
userData.setAccountDatas(accountDatas);
userData.setUserName(UUID.randomUUID().toString());
// When
mockMvc.perform(post("/api/data/user").content(mapper.writeValueAsString(userData)).contentType("application/json")).andExpect(status().isPayloadTooLarge());
}
Aggregations