Search in sources :

Example 1 with DiscoveryQos

use of joynr.types.DiscoveryQos in project joynr by bmwcarit.

the class LocalDiscoveryAggregatorTest method doesNotQueryProvisionedEntry.

@SuppressWarnings("unchecked")
@Test
public void doesNotQueryProvisionedEntry() {
    localDiscoveryAggregator.lookup(lookupCallback, new String[] { systemServicesDomain }, Discovery.INTERFACE_NAME, new DiscoveryQos());
    verify(discoveryProxyMock, never()).lookup(any(Callback.class), any(String[].class), anyString(), any(DiscoveryQos.class));
}
Also used : Callback(io.joynr.proxy.Callback) DiscoveryQos(joynr.types.DiscoveryQos) Test(org.junit.Test)

Example 2 with DiscoveryQos

use of joynr.types.DiscoveryQos in project joynr by bmwcarit.

the class LocalDiscoveryAggregatorTest method findsProvisionedEntryForMultipleDomains.

@SuppressWarnings("unchecked")
@Test
public void findsProvisionedEntryForMultipleDomains() throws Exception {
    discoveryProviderEntries = new DiscoveryEntryWithMetaInfo[] { anotherDiscoveryProviderEntry };
    allDomains = new String[] { systemServicesDomain, anotherDomain };
    String[] missingDomains = new String[] { anotherDomain };
    DiscoveryQos discoveryQos = new DiscoveryQos();
    discoveryQos.setDiscoveryScope(DiscoveryScope.LOCAL_ONLY);
    doAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) {
            Callback<DiscoveryEntryWithMetaInfo[]> callback = (Callback<DiscoveryEntryWithMetaInfo[]>) invocation.getArguments()[0];
            callback.onSuccess(discoveryProviderEntries);
            return null;
        }
    }).when(discoveryProxyMock).lookup(any(Callback.class), any(String[].class), anyString(), any(DiscoveryQos.class));
    Future<DiscoveryEntryWithMetaInfo[]> discoveryEntriesFuture = localDiscoveryAggregator.lookup(lookupCallback, allDomains, Discovery.INTERFACE_NAME, discoveryQos);
    assertNotNull(discoveryEntriesFuture);
    DiscoveryEntry[] result = discoveryEntriesFuture.get();
    logger.info("Got discovery entries: " + Arrays.toString(result));
    assertNotNull(result);
    assertEquals(2, result.length);
    assertTrue(containsByInterfaceDomain(result, discoveryProviderEntry.getInterfaceName(), discoveryProviderEntry.getDomain()));
    assertTrue(containsByInterfaceDomain(result, anotherDiscoveryProviderEntry.getInterfaceName(), anotherDiscoveryProviderEntry.getDomain()));
    verify(discoveryProxyMock).lookup(any(Callback.class), eq(missingDomains), eq(Discovery.INTERFACE_NAME), eq(discoveryQos));
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) Callback(io.joynr.proxy.Callback) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Mockito.anyString(org.mockito.Mockito.anyString) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) DiscoveryQos(joynr.types.DiscoveryQos) Test(org.junit.Test)

Example 3 with DiscoveryQos

use of joynr.types.DiscoveryQos in project joynr by bmwcarit.

the class LocalDiscoveryAggregatorTest method findsProvisionedEntryForSingleDomain.

@SuppressWarnings("unchecked")
@Test
public void findsProvisionedEntryForSingleDomain() {
    discoveryProviderEntries = new DiscoveryEntryWithMetaInfo[] { discoveryProviderEntry };
    oneDomain = new String[] { systemServicesDomain };
    // Double Decla. allDomains = new String[]{ anotherDomain, systemServicesDomain };
    DiscoveryQos discoveryQos = new DiscoveryQos();
    discoveryQos.setDiscoveryScope(DiscoveryScope.LOCAL_ONLY);
    Future<DiscoveryEntryWithMetaInfo[]> discoveryEntryFuture = localDiscoveryAggregator.lookup(lookupCallback, oneDomain, Discovery.INTERFACE_NAME, discoveryQos);
    ArgumentCaptor<DiscoveryEntry[]> discoveryEntriesCaptor = ArgumentCaptor.forClass(DiscoveryEntry[].class);
    verify(lookupCallback).resolve((Object) discoveryEntriesCaptor.capture());
    DiscoveryEntry[] discoveryEntriesPassed = discoveryEntriesCaptor.getValue();
    assertEquals(1, discoveryEntriesPassed.length);
    assertEquals(discoveryProviderEntry.getDomain(), discoveryEntriesPassed[0].getDomain());
    assertEquals(discoveryProviderEntry.getInterfaceName(), discoveryEntriesPassed[0].getInterfaceName());
    assertEquals(discoveryProviderEntry.getParticipantId(), discoveryEntriesPassed[0].getParticipantId());
    assertEquals(discoveryProviderEntry.getQos(), discoveryEntriesPassed[0].getQos());
    assertEquals(discoveryProviderEntry.getProviderVersion(), discoveryEntriesPassed[0].getProviderVersion());
    try {
        discoveryEntriesPassed = discoveryEntryFuture.get();
    } catch (Exception e) {
        Assert.fail("Got exception from future: " + e);
    }
    assertEquals(1, discoveryEntriesPassed.length);
    assertEquals(discoveryProviderEntry.getDomain(), discoveryEntriesPassed[0].getDomain());
    assertEquals(discoveryProviderEntry.getInterfaceName(), discoveryEntriesPassed[0].getInterfaceName());
    assertEquals(discoveryProviderEntry.getParticipantId(), discoveryEntriesPassed[0].getParticipantId());
    assertEquals(discoveryProviderEntry.getQos(), discoveryEntriesPassed[0].getQos());
    assertEquals(discoveryProviderEntry.getProviderVersion(), discoveryEntriesPassed[0].getProviderVersion());
    verify(discoveryProxyMock, never()).lookup(any(Callback.class), any(String[].class), anyString(), any(DiscoveryQos.class));
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) Callback(io.joynr.proxy.Callback) DiscoveryQos(joynr.types.DiscoveryQos) Test(org.junit.Test)

Aggregations

Callback (io.joynr.proxy.Callback)3 DiscoveryQos (joynr.types.DiscoveryQos)3 Test (org.junit.Test)3 DiscoveryEntry (joynr.types.DiscoveryEntry)2 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)1 Mockito.anyString (org.mockito.Mockito.anyString)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1