Search in sources :

Example 1 with SubscriptionPublisherProducer

use of io.joynr.jeeintegration.multicast.SubscriptionPublisherProducer in project joynr by bmwcarit.

the class ProviderWrapperTest method createSubject.

@SuppressWarnings("rawtypes")
private ProviderWrapper createSubject(BeanManager beanManager) {
    Injector injector = mock(Injector.class);
    JoynrMessageCreator joynrMessageCreator = mock(JoynrMessageCreator.class);
    when(injector.getInstance(eq(JoynrMessageCreator.class))).thenReturn(joynrMessageCreator);
    when(joynrMessageCreator.getMessageCreatorId()).thenReturn(USERNAME);
    Bean<?> joynrCallingPrincipalBean = mock(Bean.class);
    when(beanManager.getBeans(JoynrCallingPrincipal.class)).thenReturn(Sets.newHashSet(joynrCallingPrincipalBean));
    when(beanManager.getReference(eq(joynrCallingPrincipalBean), eq(JoynrCallingPrincipal.class), Mockito.<CreationalContext>any())).thenReturn(joynrCallingPincipal);
    Bean<?> bean = mock(Bean.class);
    doReturn(TestServiceImpl.class).when(bean).getBeanClass();
    doReturn(new TestServiceImpl()).when(bean).create(null);
    JoynrMessageMetaInfo joynrMessageContext = mock(JoynrMessageMetaInfo.class);
    when(injector.getInstance(eq(JoynrMessageMetaInfo.class))).thenReturn(joynrMessageContext);
    when(joynrMessageContext.getMessageContext()).thenReturn(expectedMessageContext);
    Bean<?> joynrMessageContextBean = mock(Bean.class);
    when(beanManager.getBeans(JoynrJeeMessageMetaInfo.class)).thenReturn(Sets.newHashSet(joynrMessageContextBean));
    when(beanManager.getReference(eq(joynrMessageContextBean), eq(JoynrJeeMessageMetaInfo.class), Mockito.any())).thenReturn(joynrJeeMessageContext);
    // Setup mock SubscriptionPublisherProducer instance in mock bean manager
    Bean subscriptionPublisherProducerBean = mock(Bean.class);
    doReturn(Sets.newHashSet(subscriptionPublisherProducerBean)).when(beanManager).getBeans(eq(SubscriptionPublisherProducer.class));
    when(beanManager.getReference(eq(subscriptionPublisherProducerBean), eq(SubscriptionPublisherProducer.class), any())).thenReturn(subscriptionPublisherProducer);
    // Setup mock meta data so that subscription publisher can be injected
    InjectionPoint subscriptionPublisherInjectionPoint = mock(InjectionPoint.class);
    when(bean.getInjectionPoints()).thenReturn(Sets.newHashSet(subscriptionPublisherInjectionPoint));
    when(subscriptionPublisherInjectionPoint.getQualifiers()).thenReturn(Sets.newHashSet(SUBSCRIPTION_PUBLISHER_ANNOTATION_LITERAL));
    Annotated annotated = mock(Annotated.class);
    when(subscriptionPublisherInjectionPoint.getAnnotated()).thenReturn(annotated);
    when(annotated.getBaseType()).thenReturn(MySubscriptionPublisher.class);
    ProviderWrapper subject = new ProviderWrapper(bean, beanManager, injector);
    return subject;
}
Also used : Annotated(javax.enterprise.inject.spi.Annotated) JoynrMessageCreator(io.joynr.messaging.JoynrMessageCreator) JoynrMessageMetaInfo(io.joynr.messaging.JoynrMessageMetaInfo) JoynrJeeMessageMetaInfo(io.joynr.jeeintegration.JoynrJeeMessageMetaInfo) InjectionPoint(javax.enterprise.inject.spi.InjectionPoint) Injector(com.google.inject.Injector) JoynrCallingPrincipal(io.joynr.jeeintegration.api.security.JoynrCallingPrincipal) SubscriptionPublisherProducer(io.joynr.jeeintegration.multicast.SubscriptionPublisherProducer) ProviderWrapper(io.joynr.jeeintegration.ProviderWrapper) Bean(javax.enterprise.inject.spi.Bean)

Aggregations

Injector (com.google.inject.Injector)1 JoynrJeeMessageMetaInfo (io.joynr.jeeintegration.JoynrJeeMessageMetaInfo)1 ProviderWrapper (io.joynr.jeeintegration.ProviderWrapper)1 JoynrCallingPrincipal (io.joynr.jeeintegration.api.security.JoynrCallingPrincipal)1 SubscriptionPublisherProducer (io.joynr.jeeintegration.multicast.SubscriptionPublisherProducer)1 JoynrMessageCreator (io.joynr.messaging.JoynrMessageCreator)1 JoynrMessageMetaInfo (io.joynr.messaging.JoynrMessageMetaInfo)1 Annotated (javax.enterprise.inject.spi.Annotated)1 Bean (javax.enterprise.inject.spi.Bean)1 InjectionPoint (javax.enterprise.inject.spi.InjectionPoint)1