@TimedResource @PUT @Path("/{subscriptionId:" + UUID_PATTERN + "}/" + UNDO_CANCEL) @Produces(APPLICATION_JSON) @ApiOperation(value = "Un-cancel an entitlement") @ApiResponses(value = {@ApiResponse(code = 204, message = "Successful operation"), @ApiResponse(code = 400, message = "Invalid subscription id supplied"), @ApiResponse(code = 404, message = "Entitlement not found")}) public Response uncancelSubscriptionPlan(@PathParam("subscriptionId") final UUID subscriptionId, @QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString, @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) throws EntitlementApiException { final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString); final Entitlement current = entitlementApi.getEntitlementForId(subscriptionId, context.createCallContextNoAccountId(createdBy, reason, comment, request)); current.uncancelEntitlement(pluginProperties, context.createCallContextNoAccountId(createdBy, reason, comment, request)); return Response.status(Status.NO_CONTENT).build(); }
assertListenerStatus(); try { entitlement.uncancelEntitlement(ImmutableList.<PluginProperty>of(), callContext); Assert.fail("Entitlement hasn't been cancelled yet"); } catch (final EntitlementApiException e) { entitlement.uncancelEntitlement(ImmutableList.<PluginProperty>of(), callContext); Assert.fail("Entitlement is already cancelled"); } catch (final EntitlementApiException e) { addOnEntitlement.uncancelEntitlement(ImmutableList.<PluginProperty>of(), callContext); Assert.fail("Add-On Entitlement is already cancelled"); } catch (final EntitlementApiException e) {
@Test(groups = "slow") public void testUncancel() throws AccountApiException, EntitlementApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null); // Create entitlement and check each field testListener.pushExpectedEvents(NextEvent.CREATE, NextEvent.BLOCK); final UUID entitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), account.getExternalKey(), null, null, false, true, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); final Entitlement entitlement = entitlementApi.getEntitlementForId(entitlementId, callContext); assertEquals(entitlement.getState(), EntitlementState.ACTIVE); clock.addDays(5); final LocalDate cancelDate = new LocalDate(clock.getUTCToday().plusDays(1)); entitlement.cancelEntitlementWithDate(cancelDate, true, ImmutableList.<PluginProperty>of(), callContext); final Entitlement entitlement2 = entitlementApi.getEntitlementForId(entitlement.getId(), callContext); assertEquals(entitlement2.getState(), EntitlementState.ACTIVE); assertEquals(entitlement2.getEffectiveEndDate(), cancelDate); testListener.pushExpectedEvents(NextEvent.UNCANCEL); entitlement2.uncancelEntitlement(ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); clock.addDays(1); final Entitlement entitlement3 = entitlementApi.getEntitlementForId(entitlement.getId(), callContext); assertEquals(entitlement3.getState(), EntitlementState.ACTIVE); }
@Test(groups = "slow", description = "https://github.com/killbill/killbill/issues/840") public void testUncancelEntitlementFor_STANDALONE_Product() throws AccountApiException, EntitlementApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Knife", BillingPeriod.MONTHLY, "notrial", null); // Create entitlement and check each field testListener.pushExpectedEvents(NextEvent.CREATE, NextEvent.BLOCK); final UUID entitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), account.getExternalKey(), null, null, false, false, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); final Entitlement entitlement = entitlementApi.getEntitlementForId(entitlementId, callContext); assertEquals(entitlement.getState(), EntitlementState.ACTIVE); clock.addDays(5); final LocalDate cancelDate = new LocalDate(clock.getUTCToday().plusDays(1)); entitlement.cancelEntitlementWithDate(cancelDate, true, ImmutableList.<PluginProperty>of(), callContext); final Entitlement entitlement2 = entitlementApi.getEntitlementForId(entitlement.getId(), callContext); assertEquals(entitlement2.getState(), EntitlementState.ACTIVE); assertEquals(entitlement2.getEffectiveEndDate(), cancelDate); testListener.pushExpectedEvents(NextEvent.UNCANCEL); entitlement2.uncancelEntitlement(ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); clock.addDays(1); final Entitlement entitlement3 = entitlementApi.getEntitlementForId(entitlement.getId(), callContext); assertEquals(entitlement3.getState(), EntitlementState.ACTIVE); }
bpEntitlement.uncancelEntitlement(ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus();
@Test(groups = "slow") public void testUncancelEffectiveCancelledEntitlement() throws AccountApiException, EntitlementApiException, SubscriptionBaseApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null); // Keep the same object for the whole test, to make sure we refresh its state before r/w calls testListener.pushExpectedEvents(NextEvent.CREATE, NextEvent.BLOCK); final UUID entitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), account.getExternalKey(), null, null, false, true, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); final Entitlement entitlement = entitlementApi.getEntitlementForId(entitlementId, callContext); testListener.pushExpectedEvent(NextEvent.PHASE); clock.addDays(30); assertListenerStatus(); subscriptionInternalApi.setChargedThroughDate(entitlement.getId(), clock.getUTCNow().plusMonths(1), internalCallContext); final LocalDate entitlementCancelledDate = clock.getToday(account.getTimeZone()); testListener.pushExpectedEvent(NextEvent.BLOCK); final Entitlement cancelledEntitlement = entitlement.cancelEntitlementWithDateOverrideBillingPolicy(clock.getToday(account.getTimeZone()), BillingActionPolicy.END_OF_TERM, ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); Assert.assertEquals(cancelledEntitlement.getEffectiveEndDate(), entitlementCancelledDate); testListener.pushExpectedEvent(NextEvent.UNCANCEL); cancelledEntitlement.uncancelEntitlement(ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus(); final Entitlement reactivatedEntitlement = entitlementApi.getEntitlementForId(cancelledEntitlement.getId(), callContext); Assert.assertNull(reactivatedEntitlement.getEffectiveEndDate()); }
bpEntitlement.uncancelEntitlement(ImmutableList.<PluginProperty>of(), callContext); assertListenerStatus();