@TimedResource @PUT @Path("/{childAccountId:" + UUID_PATTERN + "}/" + TRANSFER_CREDIT) @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Move a given child credit to the parent level") @ApiResponses(value = {@ApiResponse(code = 204, message = "Successful operation"), @ApiResponse(code = 400, message = "Account does not have credit"), @ApiResponse(code = 404, message = "Account not found")}) public Response transferChildCreditToParent(@PathParam("childAccountId") final UUID childAccountId, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final HttpServletRequest request, @javax.ws.rs.core.Context final UriInfo uriInfo) throws InvoiceApiException { final CallContext callContext = context.createCallContextWithAccountId(childAccountId, createdBy, reason, comment, request); invoiceApi.transferChildCreditToParent(childAccountId, callContext); return Response.status(Status.NO_CONTENT).build(); }
@Test(groups = "slow", expectedExceptions = InvoiceApiException.class, expectedExceptionsMessageRegExp = ".* does not have a Parent Account associated") public void testParentInvoiceTransferCreditAccountNoParent() throws Exception { final int billingDay = 14; final DateTime initialCreationDate = new DateTime(2014, 5, 15, 0, 0, 0, 0, testTimeZone); // set clock to the initial start date clock.setTime(initialCreationDate); final Account account = createAccountWithNonOsgiPaymentMethod(getChildAccountData(billingDay, null, true)); BigDecimal childAccountCBA = invoiceUserApi.getAccountCBA(account.getId(), callContext); assertEquals(childAccountCBA.compareTo(BigDecimal.ZERO), 0); invoiceUserApi.transferChildCreditToParent(account.getId(), callContext); }
@Test(groups = "slow", expectedExceptions = InvoiceApiException.class, expectedExceptionsMessageRegExp = ".* does not have credit") public void testParentInvoiceTransferCreditAccountWithoutCredit() throws Exception { final int billingDay = 14; final DateTime initialCreationDate = new DateTime(2014, 5, 15, 0, 0, 0, 0, testTimeZone); // set clock to the initial start date clock.setTime(initialCreationDate); final Account parentAccount = createAccountWithNonOsgiPaymentMethod(getAccountData(billingDay)); final Account childAccount = createAccountWithNonOsgiPaymentMethod(getChildAccountData(billingDay, parentAccount.getId(), true)); BigDecimal childAccountCBA = invoiceUserApi.getAccountCBA(childAccount.getId(), callContext); assertEquals(childAccountCBA.compareTo(BigDecimal.ZERO), 0); BigDecimal parentAccountCBA = invoiceUserApi.getAccountCBA(parentAccount.getId(), callContext); assertEquals(parentAccountCBA.compareTo(BigDecimal.ZERO), 0); invoiceUserApi.transferChildCreditToParent(childAccount.getId(), callContext); }
invoiceUserApi.transferChildCreditToParent(childAccount.getId(), callContext); assertListenerStatus();