@Test void updatePayload() { when(restClient.getUser()).thenReturn(ResponseEntity.ok(getBranch())); DataPayload data = getData(false, false, false); data.setPayments(Collections.emptyList()); data.updatePayload(service::generateIbanForNisp, "DE_12345678", EUR, false); assertNotNull(data); assertEquals("DE87123456780000000002", data.getAccounts().get(0).getIban()); assertEquals(EUR, data.getAccounts().get(0).getCurrency()); assertEquals("DE87123456780000000002", data.getUsers().get(0).getAccountAccesses().get(0).getIban()); assertEquals(EUR, data.getUsers().get(0).getAccountAccesses().get(0).getCurrency()); assertEquals("DE87123456780000000002", data.getBalancesList().get(0).getIban()); assertEquals(EUR, data.getBalancesList().get(0).getCurrency()); }
@JsonIgnore public DataPayload updatePayload(BiFunction<DataPayload, String, String> ibanGenerator, String branch, Currency currency, boolean generatePayments) { this.branch = branch; this.generatePayments = generatePayments; this.accounts.forEach(a -> { a.setIban(ibanGenerator.apply(this, a.getIban())); a.setCurrency(currency); }); this.balancesList.forEach(b -> { b.setIban(ibanGenerator.apply(this, b.getIban())); b.setCurrency(currency); }); this.users.forEach(u -> updateUserAndAccesses(ibanGenerator, u, branch, currency)); return this; }
DataPayload { @JsonIgnore public DataPayload updatePayload(BiFunction<DataPayload, String, String> ibanGenerator, String branch, Currency currency, boolean generatePayments) { this.branch = branch; this.generatePayments = generatePayments; this.accounts.forEach(a -> { a.setIban(ibanGenerator.apply(this, a.getIban())); a.setCurrency(currency); }); this.balancesList.forEach(b -> { b.setIban(ibanGenerator.apply(this, b.getIban())); b.setCurrency(currency); }); this.users.forEach(u -> updateUserAndAccesses(ibanGenerator, u, branch, currency)); return this; } }
DataPayload { @JsonIgnore public DataPayload updatePayload(BiFunction<DataPayload, String, String> ibanGenerator, String branch, Currency currency, boolean generatePayments) { this.branch = branch; this.generatePayments = generatePayments; this.accounts.forEach(a -> { a.setIban(ibanGenerator.apply(this, a.getIban())); a.setCurrency(currency); }); this.balancesList.forEach(b -> { b.setIban(ibanGenerator.apply(this, b.getIban())); b.setCurrency(currency); }); this.users.forEach(u -> updateUserAndAccesses(ibanGenerator, u, branch, currency)); return this; }  }
DataPayload { @JsonIgnore public DataPayload updatePayload(BiFunction<DataPayload, String, String> ibanGenerator, String branch, Currency currency, boolean generatePayments) { this.branch = branch; this.generatePayments = generatePayments; this.accounts.forEach(a -> { a.setIban(ibanGenerator.apply(this, a.getIban())); a.setCurrency(currency); }); this.balancesList.forEach(b -> { b.setIban(ibanGenerator.apply(this, b.getIban())); b.setCurrency(currency); }); this.users.forEach(u -> updateUserAndAccesses(ibanGenerator, u, branch, currency)); return this; }  @JsonIgnore boolean isValidPayload(); @JsonIgnore Map<String, AccountDetailsTO> getAccountByIban(); @JsonIgnore Map<String, AccountBalance> getBalancesByIban(); @JsonIgnore DataPayload updatePayload(BiFunction<DataPayload, String, String> ibanGenerator, String branch, Currency currency, boolean generatePayments); }
DataPayload { @JsonIgnore public DataPayload updatePayload(BiFunction<DataPayload, String, String> ibanGenerator, String branch, Currency currency, boolean generatePayments) { this.branch = branch; this.generatePayments = generatePayments; this.accounts.forEach(a -> { a.setIban(ibanGenerator.apply(this, a.getIban())); a.setCurrency(currency); }); this.balancesList.forEach(b -> { b.setIban(ibanGenerator.apply(this, b.getIban())); b.setCurrency(currency); }); this.users.forEach(u -> updateUserAndAccesses(ibanGenerator, u, branch, currency)); return this; }  @JsonIgnore boolean isValidPayload(); @JsonIgnore Map<String, AccountDetailsTO> getAccountByIban(); @JsonIgnore Map<String, AccountBalance> getBalancesByIban(); @JsonIgnore DataPayload updatePayload(BiFunction<DataPayload, String, String> ibanGenerator, String branch, Currency currency, boolean generatePayments);  }