use of io.joynr.messaging.JoynrMessageCreator 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;
}
use of io.joynr.messaging.JoynrMessageCreator in project joynr by bmwcarit.
the class ProviderWrapper method copyMessageCreatorInfo.
private void copyMessageCreatorInfo() {
JoynrMessageCreator joynrMessageCreator = injector.getInstance(JoynrMessageCreator.class);
JoynrCallingPrincipal reference = getUniqueBeanReference(JoynrCallingPrincipal.class);
String messageCreatorId = joynrMessageCreator.getMessageCreatorId();
LOG.trace("Setting user '{}' for message processing context.", messageCreatorId);
reference.setUsername(messageCreatorId);
}
Aggregations