public DefaultCallContext(final UUID accountId, final UUID tenantId, final String userName, final CallOrigin callOrigin, final UserType userType, final String reasonCode, final String comment, final UUID userToken, final Clock clock) { super(accountId, tenantId, userName, callOrigin, userType, reasonCode, comment, userToken); this.createdDate = clock.getUTCNow(); this.updateDate = createdDate; }
public TestCallContext(final String userName) { this(userName, new DefaultClock().getUTCNow(), new DefaultClock().getUTCNow()); }
private void resetClockToStartOfTest(final ClockMock clock) { clock.resetDeltaFromReality(); // Date at which all tests start-- we create the date object here after the system properties which set the JVM in UTC have been set. final DateTime testStartDate = new DateTime(2012, 5, 7, 0, 3, 42, 0); clock.setDeltaFromReality(testStartDate.getMillis() - clock.getUTCNow().getMillis()); }
public DateTime toUTCDateTime(final LocalDate localDate) { validateContext(); return ClockUtil.toUTCDateTime(localDate, getReferenceLocalTime(), getFixedOffsetTimeZone()); }
public LocalDate toLocalDate(final DateTime dateTime) { validateContext(); return ClockUtil.toLocalDate(dateTime, getFixedOffsetTimeZone()); }
public DefaultCallContext(final UUID accountId, final UUID tenantId, final String userName, final CallOrigin callOrigin, final UserType userType, final UUID userToken, final Clock clock) { super(accountId, tenantId, userName, callOrigin, userType, userToken); this.createdDate = clock.getUTCNow(); this.updateDate = createdDate; }
@Override public List<SubscriptionBaseEvent> getPendingEventsForSubscription(final UUID subscriptionId, final InternalTenantContext context) { final Date now = clock.getUTCNow().toDate(); return transactionalSqlDao.execute(true, new EntitySqlDaoTransactionWrapper<List<SubscriptionBaseEvent>>() { @Override public List<SubscriptionBaseEvent> inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { final List<SubscriptionEventModelDao> eventModels = entitySqlDaoWrapperFactory.become(SubscriptionEventSqlDao.class).getFutureActiveEventForSubscription(subscriptionId.toString(), now, context); return toSubscriptionBaseEvents(eventModels); } }); }
@Override public void addRoleDefinition(final String role, final List<String> permissions, final String createdBy) throws SecurityApiException { final DateTime createdDate = clock.getUTCNow(); inTransactionWithExceptionHandling(new TransactionCallback<Void>() { @Override public Void inTransaction(final Handle handle, final TransactionStatus status) throws Exception { final RolesPermissionsSqlDao rolesPermissionsSqlDao = handle.attach(RolesPermissionsSqlDao.class); final List<RolesPermissionsModelDao> existingRole = rolesPermissionsSqlDao.getByRoleName(role); if (!existingRole.isEmpty()) { throw new SecurityApiException(ErrorCode.SECURITY_ROLE_ALREADY_EXISTS, role); } for (final String permission : permissions) { rolesPermissionsSqlDao.create(new RolesPermissionsModelDao(role, permission, createdDate, createdBy)); } return null; } }); }
@Override public PriceList findCurrentPricelist(final String name) throws CatalogApiException { return versionForDate(clock.getUTCNow()).findCurrentPriceList(name); }
@Override public PlanChangeResult planChange(final PlanPhaseSpecifier from, final PlanSpecifier to) throws CatalogApiException { return versionForDate(clock.getUTCNow()).planChange(from, to); }
@Override public PlanAlignmentCreate planCreateAlignment(final PlanSpecifier specifier) throws CatalogApiException { return versionForDate(clock.getUTCNow()).planCreateAlignment(specifier); }
@Override public BillingActionPolicy planCancelPolicy(final PlanPhaseSpecifier planPhase) throws CatalogApiException { return versionForDate(clock.getUTCNow()).planCancelPolicy(planPhase); }
@Override public BillingAlignment billingAlignment(final PlanPhaseSpecifier planPhase) throws CatalogApiException { return versionForDate(clock.getUTCNow()).billingAlignment(planPhase); }
@Override public Date getEffectiveDate() throws CatalogApiException { return versionForDate(clock.getUTCNow()).getEffectiveDate(); }
@Override public Currency[] getCurrentSupportedCurrencies() throws CatalogApiException { return versionForDate(clock.getUTCNow()).getCurrentSupportedCurrencies(); }
@Override public Collection<Plan> getCurrentPlans() throws CatalogApiException { return versionForDate(clock.getUTCNow()).getCurrentPlans(); }
@Override public PlanPhase findCurrentPhase(final String name) throws CatalogApiException { return versionForDate(clock.getUTCNow()).findCurrentPhase(name); }
@Override public Collection<Product> getCurrentProducts() throws CatalogApiException { return versionForDate(clock.getUTCNow()).getCurrentProducts(); }
@Override public Unit[] getCurrentUnits() throws CatalogApiException { return versionForDate(clock.getUTCNow()).getCurrentUnits(); }
public SubscriptionBaseBundle initBundle(final UUID accountId, final SubscriptionBaseInternalApi subscriptionApi, final Clock clock, final InternalCallContext callContext) throws Exception { final DateTime utcNow = clock.getUTCNow(); return new DefaultSubscriptionBaseBundle(DEFAULT_BUNDLE_KEY, accountId, utcNow, utcNow, utcNow, utcNow); }