javax.ejb.SessionContext Java Examples
The following examples show how to use
javax.ejb.SessionContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PermissionCheck.java From development with Apache License 2.0 | 6 votes |
/** * Checks if the provided {@link Organization} is the owner of the provided * {@link TechnicalProduct} and throws an * {@link OperationNotPermittedException} if this is not the case. * * @param tp * the {@link TechnicalProduct} to check the ownership for * @param org * the {@link Organization} to check if it is the owner * @param logger * the optional logger - if not <code>null</code> it logs the * created exception as warning to the system log * @param context * if not <code>null</code>, * {@link SessionContext#setRollbackOnly()} will called. * @throws OperationNotPermittedException */ public static void owns(TechnicalProduct tp, Organization org, Log4jLogger logger, SessionContext context) throws OperationNotPermittedException { if (tp.getOrganization() != org) { String message = String .format("Organization '%s' tried to access technical service '%s' that is owned by a different organization", org.getOrganizationId(), Long.valueOf(tp.getKey())); OperationNotPermittedException e = new OperationNotPermittedException( message); if (logger != null) { logger.logWarn( Log4jLogger.SYSTEM_LOG, e, LogMessageIdentifier.WARN_INSUFFICIENT_AUTH_BY_TECH_SERVICE_ACCESS, org.getOrganizationId(), String.valueOf(tp.getKey())); } if (context != null) { context.setRollbackOnly(); } throw e; } }
Example #2
Source File: TrackingCodeManagementServiceBeanTest.java From development with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { trackingCodeManagementServiceBean = spy(new TrackingCodeManagementServiceBean()); marketplace = new Marketplace(); marketplace.setMarketplaceId(MARKETPLACE_ID); marketplace.setTrackingCode(TRACKING_CODE); mpServiceLocal = mock(MarketplaceServiceLocal.class); doReturn(marketplace).when(mpServiceLocal).getMarketplace( eq(MARKETPLACE_ID)); doNothing().when(mpServiceLocal).updateMarketplaceTrackingCode( anyString(), anyInt(), anyString()); response = new Response(); trackingCodeManagementServiceBean.mpServiceLocal = mpServiceLocal; trackingCodeManagementServiceBean.sessionCtx = mock(SessionContext.class); }
Example #3
Source File: PermissionCheck.java From development with Apache License 2.0 | 6 votes |
/** * Checks if the provided reseller {@link Organization} is reseller of the * provided customer {@link Organization} and throws an * {@link OperationNotPermittedException} if this is not the case. * * @param reseller * the {@link Organization} to check if it is reseller of the * passed customer {@link Organization} * @param cust * the {@link Organization} to check if it is customer of the * passed reseller {@link Organization} * @param logger * the optional logger - if not <code>null</code> it logs the * created exception as warning to the system log * @param context * if not <code>null</code>, * {@link SessionContext#setRollbackOnly()} will called. * @throws OperationNotPermittedException */ public static void resellerOfCustomer(Organization reseller, Organization cust, Log4jLogger logger, SessionContext context) throws OperationNotPermittedException { List<Organization> customers = reseller.getCustomersOfReseller(); if (!customers.contains(cust)) { String message = String.format( "Organization '%s' is not reseller of customer '%s'", reseller.getOrganizationId(), cust.getOrganizationId()); OperationNotPermittedException e = new OperationNotPermittedException( message); if (logger != null) { logger.logWarn(Log4jLogger.SYSTEM_LOG, e, LogMessageIdentifier.WARN_NO_RESELLER_OF_CUSTOMER, reseller.getOrganizationId(), cust.getOrganizationId()); } if (context != null) { context.setRollbackOnly(); } throw e; } }
Example #4
Source File: SubscriptionDetailsServiceBeanTest.java From development with Apache License 2.0 | 6 votes |
@Before public void setup() { bean = new SubscriptionDetailsServiceBean(); bean.accountService = mock(AccountService.class); bean.discountService = mock(DiscountService.class); bean.ds = mock(DataService.class); bean.identityService = mock(IdentityService.class); bean.partnerService = mock(PartnerService.class); bean.serviceProvisioningService = mock(ServiceProvisioningService.class); bean.serviceProvisioningServiceInternal = mock(ServiceProvisioningServiceInternal.class); bean.sessionCtx = mock(SessionContext.class); bean.sessionService = mock(SessionService.class); bean.subscriptionService = mock(SubscriptionService.class); bean.subscriptionServiceInternal = mock(SubscriptionServiceInternal.class); PlatformUser pu = new PlatformUser(); pu.setOrganization(new Organization()); pu.getOrganization().setKey(CURRENT_ORG_KEY); when(bean.ds.getCurrentUser()).thenReturn(pu); }
Example #5
Source File: PermissionCheck.java From development with Apache License 2.0 | 6 votes |
/** * Checks if the provided supplier {@link Organization} is supplier of the * provided customer {@link Organization} and throws an * {@link OperationNotPermittedException} if this is not the case. * * @param sup * the {@link Organization} to check if it is supplier of the * passed customer {@link Organization} * @param cust * the {@link Organization} to check if it is customer of the * passed supplier {@link Organization} * @param logger * the optional logger - if not <code>null</code> it logs the * created exception as warning to the system log * @param context * if not <code>null</code>, * {@link SessionContext#setRollbackOnly()} will called. * @throws OperationNotPermittedException */ public static void supplierOfCustomer(Organization sup, Organization cust, Log4jLogger logger, SessionContext context) throws OperationNotPermittedException { List<Organization> customers = sup.getCustomersOfSupplier(); if (!customers.contains(cust)) { String message = String.format( "Organization '%s' is not supplier of customer '%s'", sup.getOrganizationId(), cust.getOrganizationId()); OperationNotPermittedException e = new OperationNotPermittedException( message); if (logger != null) { logger.logWarn(Log4jLogger.SYSTEM_LOG, e, LogMessageIdentifier.WARN_NO_SUPPLIER_OF_CUSTOMER, sup.getOrganizationId(), cust.getOrganizationId()); } if (context != null) { context.setRollbackOnly(); } throw e; } }
Example #6
Source File: ContextLookupStatelessBean.java From tomee with Apache License 2.0 | 6 votes |
public void lookupSessionContext() throws TestFailureException { try { try { final InitialContext ctx = new InitialContext(); Assert.assertNotNull("The InitialContext is null", ctx); // lookup in enc final SessionContext sctx = (SessionContext) ctx.lookup("java:comp/env/sessioncontext"); Assert.assertNotNull("The SessionContext got from java:comp/env/sessioncontext is null", sctx); // lookup using global name final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext"); Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx); // verify context was set via legacy set method Assert.assertNotNull("The SessionContext is null from setter method", ejbContext); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #7
Source File: OrdersCT.java From jeeshop with Apache License 2.0 | 6 votes |
@Before public void setup() { testOrder = TestOrder.getInstance(); testCatalog = TestCatalog.getInstance(); entityManager = emf.createEntityManager(); catalogEntityManager = catalogEmf.createEntityManager(); sessionContextMock = mock(SessionContext.class); priceEngineMock = mock(PriceEngine.class); final MailTemplateFinder mailTemplateFinder = new MailTemplateFinder(entityManager); paymentTransactionEngine = new DefaultPaymentTransactionEngine( new OrderFinder(entityManager, catalogEntityManager, new OrderConfiguration("20", "3")), mailTemplateFinder, new Mailer(), catalogEntityManager); service = new Orders(entityManager, new OrderFinder(entityManager, catalogEntityManager, new OrderConfiguration("11.0", "20.0")), new UserFinder(entityManager), mailTemplateFinder, null, sessionContextMock, priceEngineMock, paymentTransactionEngine); }
Example #8
Source File: ContextLookupSingletonBean.java From tomee with Apache License 2.0 | 6 votes |
public void lookupSessionContext() throws TestFailureException { try { try { final InitialContext ctx = new InitialContext(); Assert.assertNotNull("The InitialContext is null", ctx); // lookup in enc final SessionContext sctx = (SessionContext) ctx.lookup("java:comp/env/sessioncontext"); Assert.assertNotNull("The SessionContext got from java:comp/env/sessioncontext is null", sctx); // lookup using global name final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext"); Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx); // verify context was set via legacy set method Assert.assertNotNull("The SessionContext is null from setter method", ejbContext); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #9
Source File: ContextLookupSingletonPojoBean.java From tomee with Apache License 2.0 | 6 votes |
public void lookupSessionContext() throws TestFailureException { try { try { final InitialContext ctx = new InitialContext(); Assert.assertNotNull("The InitialContext is null", ctx); // lookup in enc final SessionContext sctx = (SessionContext) ctx.lookup("java:comp/env/sessioncontext"); Assert.assertNotNull("The SessionContext got from java:comp/env/sessioncontext is null", sctx); // lookup using global name final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext"); Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx); } catch (final Exception e) { Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage()); } } catch (final AssertionFailedError afe) { throw new TestFailureException(afe); } }
Example #10
Source File: ResourceInjector.java From testfun with Apache License 2.0 | 5 votes |
@Override public <T> void doInject(T target, Field field) { // Get field class and make sure the field is an interface Class<?> fieldClass = InjectionUtils.getFieldInterface(target, field); // Assign the DataSource to the field if (DataSource.class.equals(fieldClass)) { InjectionUtils.assignObjectToField(target, field, SingletonDataSource.getDataSource()); } // Assign SessionContext to the field else if(SessionContext.class.equals(fieldClass)){ InjectionUtils.assignObjectToField(target, field, findInstanceByClass(SessionContext.class)); } }
Example #11
Source File: EligibleDiscounts.java From jeeshop with Apache License 2.0 | 5 votes |
public EligibleDiscounts(UserFinder userFinder, DiscountFinder discountFinder, OrderFinder orderFinder, SessionContext sessionContext) { this.userFinder = userFinder; this.discountFinder = discountFinder; this.orderFinder = orderFinder; this.sessionContext = sessionContext; }
Example #12
Source File: SubscriptionServiceBeanCopyProductAndModifyParametersTest.java From development with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { bean = spy(new SubscriptionServiceBean()); ds = mock(DataService.class); as = mock(ApplicationServiceLocal.class); ls = mock(LocalizerServiceLocal.class); audit = mock(SubscriptionAuditLogCollector.class); ctx = mock(SessionContext.class); bean.dataManager = ds; bean.appManager = as; bean.localizer = ls; bean.audit = audit; bean.sessionCtx = ctx; doNothing().when(ctx).setRollbackOnly(); user = new PlatformUser(); Organization org = new Organization(); org.setKey(2L); user.setOrganization(org); when(ds.getCurrentUser()).thenReturn(user); doReturn(user).when(ds).getCurrentUser(); voParameters = givenVOParameters(); parameterSet = givenParameterSet(givenParameters()); targetProduct = givenProduct(parameterSet, ProvisioningType.ASYNCHRONOUS); initialParameters = givenInitialParameters(); initialProduct = givenProduct(givenParameterSet(initialParameters), ProvisioningType.ASYNCHRONOUS); }
Example #13
Source File: AccountServicePartnerOrgUdaTest.java From development with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { ds = mock(DataService.class); as = new AccountServiceBean() { @Override public List<VOUda> getUdas(String targetType, long targetObjectKey, boolean checkSeller) throws OrganizationAuthoritiesException { throw (new OrganizationAuthoritiesException()); } }; as.sessionCtx = mock(SessionContext.class); as.subscriptionAuditLogCollector = mock(SubscriptionAuditLogCollector.class); as.dm = ds; organization = new Organization(); organization.setKey(1L); PlatformUser user = new PlatformUser(); user.setOrganization(organization); when(ds.getCurrentUser()).thenReturn(user); Subscription subscription = new Subscription(); subscription.setKey(1000); when(ds.getReference(eq(Subscription.class), eq(1000))).thenReturn( subscription); otherOrganization = new Organization(); otherOrganization.setKey(10L); }
Example #14
Source File: ModifyAndUpgradeSubscriptionBeanTest.java From development with Apache License 2.0 | 5 votes |
private List<Class<?>> givenSpyClasses() { List<Class<?>> spys = new ArrayList<>(); spys.add(DataService.class); spys.add(CommunicationServiceLocal.class); spys.add(SessionContext.class); spys.add(SubscriptionUtilBean.class); return spys; }
Example #15
Source File: UdaDefinitionAccessTest.java From development with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { ds = mock(DataService.class); ctx = mock(SessionContext.class); supplier = new Organization(); OrganizationToRole role = new OrganizationToRole(); role.setOrganization(supplier); role.setOrganizationRole(new OrganizationRole( OrganizationRoleType.SUPPLIER)); supplier.getGrantedRoles().add(role); defSupplier = new UdaDefinition(); defSupplier.setTargetType(UdaTargetType.CUSTOMER); defSupplier.setConfigurationType(UdaConfigurationType.SUPPLIER); defSupplier.setKey(1234); defSupplier.setOrganization(supplier); definitions = new ArrayList<UdaDefinition>(Arrays.asList(defSupplier)); supplier.setUdaDefinitions(definitions); voDef = new VOUdaDefinition(); voDef.setConfigurationType(UdaConfigurationType.SUPPLIER); voDef.setTargetType(UdaTargetType.CUSTOMER.name()); voDef.setUdaId("some id"); voDef.setDefaultValue("defaultValue"); when(ds.getReference(UdaDefinition.class, defSupplier.getKey())) .thenReturn(defSupplier); when(ds.find(UdaDefinition.class, defSupplier.getKey())).thenReturn( defSupplier); uda = new UdaDefinitionAccess(ds, ctx); }
Example #16
Source File: Users.java From jeeshop with Apache License 2.0 | 5 votes |
public Users(EntityManager entityManager, UserFinder userFinder, RoleFinder roleFinder, CountryChecker countryChecker, MailTemplateFinder mailTemplateFinder, Mailer mailer, SessionContext sessionContext) { this.entityManager = entityManager; this.userFinder = userFinder; this.roleFinder = roleFinder; this.countryChecker = countryChecker; this.mailTemplateFinder = mailTemplateFinder; this.mailer = mailer; this.sessionContext = sessionContext; }
Example #17
Source File: UsersCT.java From jeeshop with Apache License 2.0 | 5 votes |
@Before public void setup() { testUser = TestUser.getInstance(); testMailTemplate = TestMailTemplate.getInstance(); entityManager = entityManagerFactory.createEntityManager(); mailerMock = mock(Mailer.class); sessionContextMock = mock(SessionContext.class); service = new Users(entityManager, new UserFinder(entityManager), new RoleFinder(entityManager), new CountryChecker("FRA,GBR"), new MailTemplateFinder(entityManager), mailerMock, sessionContextMock); }
Example #18
Source File: OperatorServiceBean2Test.java From development with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { operatorServiceBean = new OperatorServiceBean(); sessionCtxMock = Mockito.mock(SessionContext.class); operatorServiceBean.sessionCtx = sessionCtxMock; accountServiceMock = Mockito.mock(AccountServiceLocal.class); operatorServiceBean.accMgmt = accountServiceMock; ds = mock(DataService.class); operatorServiceBean.dm = ds; configurationServiceLocal = mock(ConfigurationServiceLocal.class); operatorServiceBean.configService = configurationServiceLocal; }
Example #19
Source File: EjbProcessApplication.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * lookup a proxy object representing the invoked business view of this component. */ protected ProcessApplicationInterface lookupSelfReference() { try { InitialContext ic = new InitialContext(); SessionContext sctxLookup = (SessionContext) ic.lookup(EJB_CONTEXT_PATH); return sctxLookup.getBusinessObject(getBusinessInterface()); } catch (NamingException e) { throw LOG.ejbPaCannotLookupSelfReference(e); } }
Example #20
Source File: UdaAccessValidatorTest.java From development with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { ds = mock(DataService.class); uav = new UdaAccessValidator(ds, mock(SessionContext.class)); uav.mandatoryValidator = mock(MandatoryUdaValidator.class); customer = new Organization(); customer.setKey(1234); supplier = new Organization(); supplier.setKey(4321); OrganizationReferences.addSupplierReference(supplier, customer); OrganizationReferences.addSupplierReference(supplier, supplier); def = new UdaDefinition(); def.setOrganization(supplier); def.setTargetType(UdaTargetType.CUSTOMER); def.setConfigurationType(UdaConfigurationType.SUPPLIER); uda = new Uda(); uda.setUdaDefinition(def); uda.setTargetObjectKey(customer); sub = new Subscription(); sub.setKey(5678); sub.setOrganization(customer); when(ds.getReference(eq(Organization.class), eq(customer.getKey()))) .thenReturn(customer); when(ds.getReference(eq(Subscription.class), eq(sub.getKey()))) .thenReturn(sub); when(ds.find(eq(Organization.class), eq(customer.getKey()))) .thenReturn(customer); when(ds.find(eq(Subscription.class), eq(sub.getKey()))).thenReturn(sub); }
Example #21
Source File: LandingpageConfigurationServiceBeanIT.java From development with Apache License 2.0 | 5 votes |
@Override protected void setup(TestContainer container) throws Exception { container.enableInterfaceMocking(true); configureLandingpageServiceBean = new LandingpageConfigurationServiceBean(); container.addBean(configureLandingpageServiceBean); landingpageService = mock(LandingpageServiceLocal.class); container.addBean(landingpageService); configureLandingpageService = container .get(LandingpageConfigurationService.class); configureLandingpageServiceBean.sessionCtx = mock(SessionContext.class); }
Example #22
Source File: IdentityServiceBeanUserDeletionTest.java From development with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { MockitoAnnotations.initMocks(this); idMgmt = new IdentityServiceBean(); dm = mock(DataService.class); idMgmt.dm = dm; sm = mock(SubscriptionServiceLocal.class); idMgmt.sm = sm; sessionService = mock(SessionServiceLocal.class); idMgmt.sessionService = sessionService; rvs = mock(ReviewServiceLocalBean.class); idMgmt.rvs = rvs; principal = mock(Principal.class); sessionCtx = mock(SessionContext.class); doReturn(principal).when(sessionCtx).getCallerPrincipal(); idMgmt.sessionCtx = sessionCtx; cm = mock(CommunicationServiceLocal.class); idMgmt.cm = cm; setupUsers(); doReturn(new ArrayList<Subscription>()).when(sm) .getSubscriptionsForUserInt(userToBeDeleted); doReturn("Test").when(principal).getName(); userSessions = new ArrayList<Session>(); doReturn(userSessions).when(sessionService).getSessionsForUserKey( user.getKey()); }
Example #23
Source File: IdentityServiceBeanLdapTest.java From development with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { bean = spy(new IdentityServiceBean()); user = new PlatformUser(); Organization ldapManagedOrg = new Organization(); ldapManagedOrg.setRemoteLdapActive(true); user.setOrganization(ldapManagedOrg); DataService ds = mock(DataService.class); when(ds.getCurrentUser()).thenReturn(user); bean.dm = ds; bean.ldapAccess = mock(LdapAccessServiceLocal.class); bean.cm = mock(CommunicationServiceLocal.class); bean.sessionCtx = mock(SessionContext.class); bean.ldapSettingsMS = mock(LdapSettingsManagementServiceLocal.class); ConfigurationServiceLocal cs = mock(ConfigurationServiceLocal.class); doReturn( new ConfigurationSetting(ConfigurationKey.AUTH_MODE, Configuration.GLOBAL_CONTEXT, "INTERNAL")).when(cs) .getConfigurationSetting(any(ConfigurationKey.class), anyString()); bean.cs = cs; doNothing().when(bean).syncUserWithLdap(any(PlatformUser.class)); userGroupServiceLocalBean = mock(UserGroupServiceLocalBean.class); bean.userGroupService = userGroupServiceLocalBean; }
Example #24
Source File: PartnerServiceBeanTest.java From development with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { query = mock(Query.class); service = spy(new PartnerServiceBean()); service.localizer = mock(LocalizerServiceLocal.class); sps = mock(ServiceProvisioningServiceBean.class); service.sps = sps; service.spsLocal = mock(ServiceProvisioningServiceLocal.class); service.ds = mock(DataService.class); doReturn(query).when(service.ds).createNamedQuery( "Product.getSpecificCustomerProduct"); service.spsLocalizer = mock(ServiceProvisioningServiceLocalizationLocal.class); service.sessionCtx = mock(SessionContext.class); service.slService = mock(SubscriptionListServiceLocal.class); when(service.ds.getCurrentUser()).thenReturn(new PlatformUser()); product = new Product(); product.setStatus(ServiceStatus.INACTIVE); doReturn(product).when(service.ds).getReference(eq(Product.class), anyLong()); PlatformUser u = new PlatformUser(); u.setLocale("locale"); doReturn(u).when(service.ds).getCurrentUser(); doReturn(Boolean.FALSE).when(service.slService) .isUsableSubscriptionExistForTemplate(any(PlatformUser.class), eq(Subscription.ASSIGNABLE_SUBSCRIPTION_STATUS), any(Product.class)); }
Example #25
Source File: ManageSubscriptionBeanTest.java From development with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { bean = new ManageSubscriptionBean(); bean.appManager = mock(ApplicationServiceLocal.class); bean.dataManager = mock(DataService.class); bean.sessionCtx = mock(SessionContext.class); TechnicalProduct technicalProduct = new TechnicalProduct(); Product product = new Product(); product.setTechnicalProduct(technicalProduct); currentUser = new PlatformUser(); currentUser.setUserId(USER_ID); UsageLicense license = new UsageLicense(); license.setUser(currentUser); license.setApplicationUserId(APPLICATION_USER_ID); subscription = new Subscription(); subscription.setProduct(product); license.setSubscription(subscription); subscription.getUsageLicenses().add(license); subscription.setProductInstanceId(INSTANCE_ID); operation = new TechnicalProductOperation(); operation.setTechnicalProduct(technicalProduct); operation.setOperationId(OPERATION_ID); parameterValues = new HashMap<String, List<String>>(); parameterValues.put("1", Arrays.asList("A", "B", "C")); parameterValues.put("A", Arrays.asList("1", "2", "3")); when(bean.dataManager.getCurrentUser()).thenReturn(currentUser); when( bean.appManager.getOperationParameterValues(anyString(), any(TechnicalProductOperation.class), any(Subscription.class))).thenReturn(parameterValues); }
Example #26
Source File: OperationRecordServiceLocalBeanIT.java From development with Apache License 2.0 | 5 votes |
@Override protected void setup(TestContainer container) throws Exception { container.addBean(new ConfigurationServiceStub()); container.addBean(new DataServiceBean()); ds = container.get(DataService.class); container.addBean(new OperationRecordDao()); container.addBean(new LocalizerServiceBean()); operationRecordDao = container.get(OperationRecordDao.class); localizer = container.get(LocalizerServiceLocal.class); orslb = new OperationRecordServiceLocalBean(); orslb.dm = ds; orslb.operationRecordDao = operationRecordDao; orslb.localizer = localizer; orslb.sessionCtx = mock(SessionContext.class); org = createOrg("org1", OrganizationRoleType.SUPPLIER, OrganizationRoleType.TECHNOLOGY_PROVIDER); createUser(org, true, "orgAdmin"); subManager = createUser(org, false, "subManager"); grantSubscriptionManagerRole(subManager, UserRoleType.SUBSCRIPTION_MANAGER); user = createUser(org, false, "user"); tp = createTechnicalProduct(); op = createOperation(tp); pro1 = createProduct(org, tp.getTechnicalProductId(), false, "productId1", "priceModelId1"); sub1 = createSubscription(org.getOrganizationId(), pro1.getProductId(), "subscriptionId1", org, null); sub2 = createSubscription(org.getOrganizationId(), pro1.getProductId(), "subscriptionId2", org, subManager); recordForUserSub1 = createOperationRecord(user, sub1, op, "transactionId1"); recordForUserSub2 = createOperationRecord(user, sub2, op, "transactionId2"); }
Example #27
Source File: StatelessSessionBeanInterfaceTest.java From tomee with Apache License 2.0 | 4 votes |
@Override public void setSessionContext(SessionContext ctx) throws EJBException, RemoteException { lifecycle.add("setSessionContext"); }
Example #28
Source File: SubscriptionServiceBeanModifyAndUpgradeTest.java From development with Apache License 2.0 | 4 votes |
@Before public void setup() throws Exception { AESEncrypter.generateKey(); bean = spy(new SubscriptionServiceBean()); ds = mock(DataService.class); as = mock(ApplicationServiceLocal.class); audit = mock(SubscriptionAuditLogCollector.class); ctx = mock(SessionContext.class); udaAccess = mock(UdaAccess.class); localizer = mock(LocalizerServiceLocal.class); modifiedEntityDao = mock(ModifiedEntityDao.class); trigger = mock(TriggerQueueServiceLocal.class); manageBean = spy(new ManageSubscriptionBean()); manageBean.dataManager = ds; commService = mock(CommunicationServiceLocal.class); stateValidator = mock(ValidateSubscriptionStateBean.class); modifyAndUpgradeBean = spy(new ModifyAndUpgradeSubscriptionBean()); modifyAndUpgradeBean.dataManager = ds; modifyAndUpgradeBean.commService = commService; bean.dataManager = ds; bean.appManager = as; bean.audit = audit; bean.sessionCtx = ctx; bean.localizer = localizer; bean.triggerQS = trigger; bean.manageBean = manageBean; bean.stateValidator = stateValidator; bean.modUpgBean = modifyAndUpgradeBean; doNothing().when(ctx).setRollbackOnly(); technologyProvider = givenOrganization(); user = new PlatformUser(); user.setOrganization(technologyProvider); when(ds.getCurrentUser()).thenReturn(user); paymentInfo = mock(PaymentInfo.class); billingContact = mock(BillingContact.class); voParameters = givenVOParameters(); voUdas = new ArrayList<>(); voPaymentInfo = new VOPaymentInfo(); voBillingContact = new VOBillingContact(); voService = new VOService(); voService.setKey(1L); doReturn(modifiedEntityDao).when(bean).getModifiedEntityDao(); doReturn(Boolean.TRUE).when(bean).checkIfParametersAreModified( any(Subscription.class), any(Subscription.class), any(Product.class), any(Product.class), anyListOf(VOParameter.class), anyBoolean()); doReturn(udaAccess).when(manageBean).getUdaAccess(); doReturn(new ArrayList<Uda>()).when(udaAccess) .getExistingUdas(anyLong(), anyLong(), any(Organization.class)); doReturn(paymentInfo).when(ds).getReference(eq(PaymentInfo.class), anyLong()); doReturn(billingContact).when(ds).getReference(eq(BillingContact.class), anyLong()); doNothing().when(bean).saveUdasForSubscription(anyListOf(VOUda.class), any(Subscription.class)); doNothing().when(bean).validateSettingsForUpgrading( any(VOSubscription.class), any(VOService.class), any(VOPaymentInfo.class), any(VOBillingContact.class)); doNothing().when(bean).copyProductAndModifyParametersForUpgrade( eq(subscription), eq(targetProduct), eq(user), anyListOf(VOParameter.class)); givenAsynchronousProvisiong(); }
Example #29
Source File: CheckNoBusinessMethodTest.java From tomee with Apache License 2.0 | 4 votes |
@Override public void setSessionContext(final SessionContext arg0) throws EJBException, RemoteException { }
Example #30
Source File: SetterInjectionStatefulBean.java From tomee with Apache License 2.0 | 4 votes |
public void setSessionContext(final SessionContext sessionContext) throws EJBException, RemoteException { }