Search in sources :

Example 11 with SubscriptionPublication

use of joynr.SubscriptionPublication in project joynr by bmwcarit.

the class PublicationManagerTest method broadcastPublicationIsSent.

@SuppressWarnings("unchecked")
@Test
public void broadcastPublicationIsSent() throws Exception {
    publicationManager = new PublicationManagerImpl(attributePollInterpreter, dispatcher, providerDirectory, cleanupScheduler, Mockito.mock(SubscriptionRequestStorage.class), shutdownNotifier);
    long minInterval_ms = 0;
    long ttl = 1000;
    testBroadcastInterface.LocationUpdateWithSpeedSelectiveBroadcastFilterParameters filterParameters = new testBroadcastInterface.LocationUpdateWithSpeedSelectiveBroadcastFilterParameters();
    OnChangeSubscriptionQos qos = new OnChangeSubscriptionQos().setMinIntervalMs(minInterval_ms).setExpiryDateMs(SubscriptionQos.NO_EXPIRY_DATE).setPublicationTtlMs(ttl);
    ;
    SubscriptionRequest subscriptionRequest = new BroadcastSubscriptionRequest(SUBSCRIPTION_ID, "subscribedToName", filterParameters, qos);
    when(providerDirectory.get(eq(PROVIDER_PARTICIPANT_ID))).thenReturn(providerContainer);
    when(providerDirectory.contains(eq(PROVIDER_PARTICIPANT_ID))).thenReturn(true);
    publicationManager.addSubscriptionRequest(PROXY_PARTICIPANT_ID, PROVIDER_PARTICIPANT_ID, subscriptionRequest);
    GpsLocation location = new GpsLocation(1.0, 2.0, 3.0, GpsFixEnum.MODE2D, 4.0, 5.0, 6.0, 7.0, 9l, 10l, 11);
    double speed = 100;
    publicationManager.broadcastOccurred(subscriptionRequest.getSubscriptionId(), new ArrayList<BroadcastFilter>(), location, speed);
    ArgumentCaptor<SubscriptionPublication> publicationCaptured = ArgumentCaptor.forClass(SubscriptionPublication.class);
    ArgumentCaptor<MessagingQos> qosCaptured = ArgumentCaptor.forClass(MessagingQos.class);
    verify(dispatcher).sendSubscriptionPublication(eq(PROVIDER_PARTICIPANT_ID), (Set<String>) argThat(contains(PROXY_PARTICIPANT_ID)), publicationCaptured.capture(), qosCaptured.capture());
    List<?> response = (List<?>) publicationCaptured.getValue().getResponse();
    assertEquals(location, response.get(0));
    assertEquals(speed, response.get(1));
    assertEquals(ttl, qosCaptured.getValue().getRoundTripTtl_ms());
}
Also used : OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) GpsLocation(joynr.types.Localisation.GpsLocation) Matchers.anyString(org.mockito.Matchers.anyString) joynr.tests.testBroadcastInterface(joynr.tests.testBroadcastInterface) SubscriptionRequest(joynr.SubscriptionRequest) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) MessagingQos(io.joynr.messaging.MessagingQos) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) SubscriptionPublication(joynr.SubscriptionPublication) List(java.util.List) ArrayList(java.util.ArrayList) BroadcastFilter(io.joynr.pubsub.publication.BroadcastFilter) joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter(joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter) joynr.tests.testLocationUpdateSelectiveBroadcastFilter(joynr.tests.testLocationUpdateSelectiveBroadcastFilter) Test(org.junit.Test)

Example 12 with SubscriptionPublication

use of joynr.SubscriptionPublication in project joynr by bmwcarit.

the class PushingPublicationTest method setUp.

@Before
public void setUp() throws JoynrSendBufferFullException, JoynrMessageNotSentException, JsonGenerationException, JsonMappingException, IOException {
    provider = new SubscriptionTestsProviderImpl();
    publicationManager = new PublicationManagerImpl(attributePollInterpreter, dispatcher, providerDirectory, cleanupScheduler, Mockito.mock(SubscriptionRequestStorage.class), shutdownNotifier);
    subscriptionId = "subscriptionId";
    proxyId = "proxyId";
    providerId = "providerId";
    attributeName = "testAttribute";
    publication = new SubscriptionPublication(Arrays.asList(testAttribute), subscriptionId);
    testSubscriptionPublisherImpl testSubscriptionPublisher = new testSubscriptionPublisherImpl();
    provider.setSubscriptionPublisher(testSubscriptionPublisher);
    when(providerContainer.getProviderProxy()).thenReturn(new RequestCallerFactory().create(provider).getProxy());
    when(providerContainer.getSubscriptionPublisher()).thenReturn(testSubscriptionPublisher);
    setupMocks();
}
Also used : SubscriptionPublication(joynr.SubscriptionPublication) joynr.tests.testSubscriptionPublisherImpl(joynr.tests.testSubscriptionPublisherImpl) RequestCallerFactory(io.joynr.dispatching.RequestCallerFactory) Before(org.junit.Before)

Aggregations

SubscriptionPublication (joynr.SubscriptionPublication)12 Test (org.junit.Test)6 SubscriptionRequest (joynr.SubscriptionRequest)5 MessagingQos (io.joynr.messaging.MessagingQos)4 BroadcastFilter (io.joynr.pubsub.publication.BroadcastFilter)3 ArrayList (java.util.ArrayList)3 BroadcastSubscriptionRequest (joynr.BroadcastSubscriptionRequest)3 OnChangeSubscriptionQos (joynr.OnChangeSubscriptionQos)3 joynr.tests.testBroadcastInterface (joynr.tests.testBroadcastInterface)3 joynr.tests.testLocationUpdateSelectiveBroadcastFilter (joynr.tests.testLocationUpdateSelectiveBroadcastFilter)3 joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter (joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter)3 GpsLocation (joynr.types.Localisation.GpsLocation)3 Matchers.anyString (org.mockito.Matchers.anyString)3 List (java.util.List)2 MulticastSubscriptionRequest (joynr.MulticastSubscriptionRequest)2 MutableMessage (joynr.MutableMessage)2 Reply (joynr.Reply)2 Request (joynr.Request)2 Before (org.junit.Before)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1