Search in sources :

Example 41 with BlockingState

use of org.killbill.billing.entitlement.api.BlockingState in project killbill by killbill.

the class TestBlockingChecker method setStateAccount.

private void setStateAccount(final boolean bC, final boolean bE, final boolean bB) {
    final BlockingState accountState = new DefaultBlockingState(account.getId(), BlockingStateType.ACCOUNT, "state", "test-service", bC, bE, bB, clock.getUTCNow());
    blockingStateDao.setBlockingStatesAndPostBlockingTransitionEvent(ImmutableMap.<BlockingState, Optional<UUID>>of(accountState, Optional.<UUID>absent()), internalCallContext);
}
Also used : DefaultBlockingState(org.killbill.billing.junction.DefaultBlockingState) BlockingState(org.killbill.billing.entitlement.api.BlockingState) UUID(java.util.UUID) DefaultBlockingState(org.killbill.billing.junction.DefaultBlockingState)

Example 42 with BlockingState

use of org.killbill.billing.entitlement.api.BlockingState in project killbill by killbill.

the class TestBlockingChecker method setStateBundle.

private void setStateBundle(final boolean bC, final boolean bE, final boolean bB) {
    final BlockingState bundleState = new DefaultBlockingState(bundle.getId(), BlockingStateType.SUBSCRIPTION_BUNDLE, "state", "test-service", bC, bE, bB, clock.getUTCNow());
    blockingStateDao.setBlockingStatesAndPostBlockingTransitionEvent(ImmutableMap.<BlockingState, Optional<UUID>>of(bundleState, Optional.<UUID>absent()), internalCallContext);
}
Also used : DefaultBlockingState(org.killbill.billing.junction.DefaultBlockingState) BlockingState(org.killbill.billing.entitlement.api.BlockingState) UUID(java.util.UUID) DefaultBlockingState(org.killbill.billing.junction.DefaultBlockingState)

Example 43 with BlockingState

use of org.killbill.billing.entitlement.api.BlockingState in project killbill by killbill.

the class JaxRsResourceBase method addBlockingState.

public Response addBlockingState(final BlockingStateJson json, final String id, final BlockingStateType type, final String requestedDate, final List<String> pluginPropertiesString, final String createdBy, final String reason, final String comment, final HttpServletRequest request) throws SubscriptionApiException, EntitlementApiException, AccountApiException {
    final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString);
    final CallContext callContext = context.createContext(createdBy, reason, comment, request);
    final UUID blockableId = UUID.fromString(id);
    final boolean isBlockBilling = (json.isBlockBilling() != null && json.isBlockBilling());
    final boolean isBlockEntitlement = (json.isBlockEntitlement() != null && json.isBlockEntitlement());
    final boolean isBlockChange = (json.isBlockChange() != null && json.isBlockChange());
    final LocalDate resolvedRequestedDate = toLocalDate(requestedDate);
    final BlockingState input = new DefaultBlockingState(blockableId, type, json.getStateName(), json.getService(), isBlockChange, isBlockEntitlement, isBlockBilling, null);
    subscriptionApi.addBlockingState(input, resolvedRequestedDate, pluginProperties, callContext);
    return Response.status(Status.OK).build();
}
Also used : PluginProperty(org.killbill.billing.payment.api.PluginProperty) DefaultBlockingState(org.killbill.billing.junction.DefaultBlockingState) BlockingState(org.killbill.billing.entitlement.api.BlockingState) UUID(java.util.UUID) CallContext(org.killbill.billing.util.callcontext.CallContext) LocalDate(org.joda.time.LocalDate) DefaultBlockingState(org.killbill.billing.junction.DefaultBlockingState)

Example 44 with BlockingState

use of org.killbill.billing.entitlement.api.BlockingState in project killbill by killbill.

the class AccountResource method getBlockingStates.

/*
     * *************************      BLOCKING STATE     *****************************
     */
@TimedResource
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + BLOCK)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve blocking states for account", response = BlockingStateJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied") })
public Response getBlockingStates(@PathParam(ID_PARAM_NAME) final String id, @QueryParam(QUERY_BLOCKING_STATE_TYPES) final List<BlockingStateType> typeFilter, @QueryParam(QUERY_BLOCKING_STATE_SVCS) final List<String> svcsFilter, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws EntitlementApiException {
    final TenantContext tenantContext = this.context.createContext(request);
    final UUID accountId = UUID.fromString(id);
    final Iterable<BlockingState> blockingStates = subscriptionApi.getBlockingStates(accountId, typeFilter, svcsFilter, OrderingType.ASCENDING, SubscriptionApi.ALL_EVENTS, tenantContext);
    final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(accountId, auditMode.getLevel(), tenantContext);
    final List<BlockingStateJson> result = ImmutableList.copyOf(Iterables.transform(blockingStates, new Function<BlockingState, BlockingStateJson>() {

        @Override
        public BlockingStateJson apply(final BlockingState input) {
            return new BlockingStateJson(input, accountAuditLogs);
        }
    }));
    return Response.status(Status.OK).entity(result).build();
}
Also used : Function(com.google.common.base.Function) TenantContext(org.killbill.billing.util.callcontext.TenantContext) BlockingState(org.killbill.billing.entitlement.api.BlockingState) UUID(java.util.UUID) AccountAuditLogs(org.killbill.billing.util.audit.AccountAuditLogs) BlockingStateJson(org.killbill.billing.jaxrs.json.BlockingStateJson) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 45 with BlockingState

use of org.killbill.billing.entitlement.api.BlockingState in project killbill by killbill.

the class MockEntitlementModuleForPayment method installBlockingApi.

@Override
public void installBlockingApi() {
    super.installBlockingApi();
    final BlockingState blockingState = new DefaultBlockingState(null, BlockingStateType.ACCOUNT, "CLEAR_STATE_NAME", "test", false, false, false, new DateTime(DateTimeZone.UTC));
    Mockito.when(blockingApi.getBlockingAllForAccount(Mockito.<InternalTenantContext>any())).thenReturn(ImmutableList.<BlockingState>of(blockingState));
    Mockito.when(blockingApi.getBlockingStateForService(Mockito.<UUID>any(), Mockito.<BlockingStateType>any(), Mockito.anyString(), Mockito.<InternalTenantContext>any())).thenReturn(blockingState);
}
Also used : DefaultBlockingState(org.killbill.billing.junction.DefaultBlockingState) BlockingState(org.killbill.billing.entitlement.api.BlockingState) DefaultBlockingState(org.killbill.billing.junction.DefaultBlockingState) DateTime(org.joda.time.DateTime)

Aggregations

BlockingState (org.killbill.billing.entitlement.api.BlockingState)46 UUID (java.util.UUID)24 DefaultBlockingState (org.killbill.billing.junction.DefaultBlockingState)22 Test (org.testng.annotations.Test)15 DateTime (org.joda.time.DateTime)13 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)6 SubscriptionBase (org.killbill.billing.subscription.api.SubscriptionBase)6 LocalDate (org.joda.time.LocalDate)5 ImmutableList (com.google.common.collect.ImmutableList)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4 Account (org.killbill.billing.account.api.Account)4 BillingEvent (org.killbill.billing.junction.BillingEvent)4 Optional (com.google.common.base.Optional)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 TreeSet (java.util.TreeSet)3 AccountApiException (org.killbill.billing.account.api.AccountApiException)3 PlanPhaseSpecifier (org.killbill.billing.catalog.api.PlanPhaseSpecifier)3 BlockingStateType (org.killbill.billing.entitlement.api.BlockingStateType)3