Assert.assertNull(parentAccount.getParentAccountId()); Assert.assertFalse(parentAccount.isPaymentDelegatedToParent()); List<Account> childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); Assert.assertEquals(childrenAccounts.size(), 0); Assert.assertEquals(childAccount1.getParentAccountId(), parentAccount.getId()); Assert.assertTrue(childAccount1.isPaymentDelegatedToParent()); childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); Assert.assertEquals(childrenAccounts.size(), 1); Assert.assertEquals(childrenAccounts.get(0).getId(), childAccount1.getId()); Assert.assertNull(childAccount1.getParentAccountId()); Assert.assertFalse(childAccount1.isPaymentDelegatedToParent()); childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); Assert.assertEquals(childrenAccounts.size(), 0); Assert.assertEquals(childAccount2.getParentAccountId(), parentAccount.getId()); Assert.assertTrue(childAccount2.isPaymentDelegatedToParent()); childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); Assert.assertEquals(childrenAccounts.size(), 1); Assert.assertEquals(childrenAccounts.get(0).getId(), childAccount2.getId());
@TimedResource @GET @Path("/{accountId:" + UUID_PATTERN + "}/" + CHILDREN) @Produces(APPLICATION_JSON) @ApiOperation(value = "List children accounts", response = AccountJson.class, responseContainer = "List") @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid parent account id supplied"), @ApiResponse(code = 404, message = "Parent Account not found")}) public Response getChildrenAccounts(@PathParam("accountId") final UUID parentAccountId, @QueryParam(QUERY_ACCOUNT_WITH_BALANCE) @DefaultValue("false") final Boolean accountWithBalance, @QueryParam(QUERY_ACCOUNT_WITH_BALANCE_AND_CBA) @DefaultValue("false") final Boolean accountWithBalanceAndCBA, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException { final TenantContext tenantContext = context.createTenantContextWithAccountId(parentAccountId, request); final List<Account> accounts = accountUserApi.getChildrenAccounts(parentAccountId, tenantContext); final List<AccountJson> accountJson = new ArrayList<AccountJson>(); for (final Account account : accounts) { final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(account.getId(), auditMode.getLevel(), tenantContext); accountJson.add(getAccount(account, accountWithBalance, accountWithBalanceAndCBA, accountAuditLogs, tenantContext)); } return Response.status(Status.OK).entity(accountJson).build(); }
assertNull(childAccount.getParentAccountId()); assertFalse(childAccount.isPaymentDelegatedToParent()); List<Account> childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); assertEquals(childrenAccounts.size(), 0); assertEquals(childAccount.getParentAccountId(), parentAccount.getId()); assertFalse(childAccount.isPaymentDelegatedToParent()); childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); assertEquals(childrenAccounts.size(), 1); assertEquals(childrenAccounts.get(0).getId(), childAccount.getId()); assertEquals(childAccount.getParentAccountId(), parentAccount.getId()); assertTrue(childAccount.isPaymentDelegatedToParent()); childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); assertEquals(childrenAccounts.size(), 1); assertEquals(childrenAccounts.get(0).getId(), childAccount.getId());
assertEquals(childAccount.getParentAccountId(), parentAccount.getId()); assertTrue(childAccount.isPaymentDelegatedToParent()); List<Account> childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); assertEquals(childrenAccounts.size(), 1); assertEquals(childrenAccounts.get(0).getId(), childAccount.getId()); assertNull(childAccount.getParentAccountId()); assertFalse(childAccount.isPaymentDelegatedToParent()); childrenAccounts = accountUserApi.getChildrenAccounts(parentAccount.getId(), callContext); assertEquals(childrenAccounts.size(), 0);