Search in sources :

Example 21 with DiscoveryEntryWithMetaInfo

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

the class DiscoveryEntryVersionFilterTest method testOnlyIncompatibleVersionsFilteredOut.

@Test
public void testOnlyIncompatibleVersionsFilteredOut() {
    Version callerVersion = new Version(0, 0);
    DiscoveryEntryWithMetaInfo compatibleEntry = mock(DiscoveryEntryWithMetaInfo.class);
    Version compatibleVersion = new Version(0, 1);
    when(compatibleEntry.getProviderVersion()).thenReturn(compatibleVersion);
    when(versionCompatibilityChecker.check(eq(callerVersion), eq(compatibleVersion))).thenReturn(true);
    DiscoveryEntryWithMetaInfo incompatibleEntry = mock(DiscoveryEntryWithMetaInfo.class);
    Version incompatibleVersion = new Version(2, 2);
    when(incompatibleEntry.getProviderVersion()).thenReturn(incompatibleVersion);
    when(versionCompatibilityChecker.check(callerVersion, incompatibleVersion)).thenReturn(false);
    Set<DiscoveryEntryWithMetaInfo> discoveryEntries = Sets.newHashSet(compatibleEntry, incompatibleEntry);
    Set<DiscoveryEntryWithMetaInfo> result = subject.filter(callerVersion, discoveryEntries, null);
    assertNotNull(result);
    assertEquals(1, result.size());
    assertEquals(compatibleEntry, result.iterator().next());
}
Also used : Version(joynr.types.Version) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) Test(org.junit.Test)

Example 22 with DiscoveryEntryWithMetaInfo

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

the class DiscoveryEntryVersionFilterTest method testVersionsCollectedByDomain.

@Test
public void testVersionsCollectedByDomain() {
    Version callerVersion = new Version(1, 0);
    DiscoveryEntryWithMetaInfo discoveryEntry = mock(DiscoveryEntryWithMetaInfo.class);
    Version providerVersion = new Version(2, 0);
    when(discoveryEntry.getProviderVersion()).thenReturn(providerVersion);
    when(discoveryEntry.getDomain()).thenReturn("domain-1");
    DiscoveryEntryWithMetaInfo otherDiscoveryEntry = mock(DiscoveryEntryWithMetaInfo.class);
    Version otherProviderVersion = new Version(4, 10);
    when(otherDiscoveryEntry.getProviderVersion()).thenReturn(otherProviderVersion);
    when(otherDiscoveryEntry.getDomain()).thenReturn("domain-2");
    Set<DiscoveryEntryWithMetaInfo> discoveryEntries = Sets.newHashSet(discoveryEntry, otherDiscoveryEntry);
    Map<String, Set<Version>> filteredOutVersions = new HashMap<>();
    Set<DiscoveryEntryWithMetaInfo> result = subject.filter(callerVersion, discoveryEntries, filteredOutVersions);
    assertNotNull(result);
    assertTrue(result.isEmpty());
    assertFalse(filteredOutVersions.isEmpty());
    assertTrue(filteredOutVersions.containsKey("domain-1"));
    Set<Version> versions = filteredOutVersions.get("domain-1");
    assertNotNull(versions);
    assertTrue(versions.containsAll(Sets.newHashSet(providerVersion)));
    assertTrue(filteredOutVersions.containsKey("domain-2"));
    versions = filteredOutVersions.get("domain-2");
    assertNotNull(versions);
    assertTrue(versions.containsAll(Sets.newHashSet(otherProviderVersion)));
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Version(joynr.types.Version) HashMap(java.util.HashMap) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) Test(org.junit.Test)

Example 23 with DiscoveryEntryWithMetaInfo

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

the class DiscoveryEntryVersionFilterTest method testFilteredOutVersionsCollected.

@Test
public void testFilteredOutVersionsCollected() {
    Version callerVersion = new Version(1, 0);
    DiscoveryEntryWithMetaInfo discoveryEntry = mock(DiscoveryEntryWithMetaInfo.class);
    Version providerVersion = new Version(2, 0);
    when(discoveryEntry.getProviderVersion()).thenReturn(providerVersion);
    when(discoveryEntry.getDomain()).thenReturn("domain");
    DiscoveryEntryWithMetaInfo otherDiscoveryEntry = mock(DiscoveryEntryWithMetaInfo.class);
    Version otherProviderVersion = new Version(4, 10);
    when(otherDiscoveryEntry.getProviderVersion()).thenReturn(otherProviderVersion);
    when(otherDiscoveryEntry.getDomain()).thenReturn("domain");
    Set<DiscoveryEntryWithMetaInfo> discoveryEntries = Sets.newHashSet(discoveryEntry, otherDiscoveryEntry);
    Map<String, Set<Version>> filteredOutVersions = new HashMap<>();
    Set<DiscoveryEntryWithMetaInfo> result = subject.filter(callerVersion, discoveryEntries, filteredOutVersions);
    assertNotNull(result);
    assertTrue(result.isEmpty());
    assertFalse(filteredOutVersions.isEmpty());
    assertTrue(filteredOutVersions.containsKey("domain"));
    Set<Version> versions = filteredOutVersions.get("domain");
    assertTrue(versions.containsAll(Sets.newHashSet(providerVersion, otherProviderVersion)));
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Version(joynr.types.Version) HashMap(java.util.HashMap) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) Test(org.junit.Test)

Example 24 with DiscoveryEntryWithMetaInfo

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

the class CapabilitiesUtilsTest method createCollectionOfDiscoveryEntriesWithMetaInfo.

private Collection<DiscoveryEntryWithMetaInfo> createCollectionOfDiscoveryEntriesWithMetaInfo() {
    Collection<DiscoveryEntryWithMetaInfo> discoveryEntries = new ArrayList<>(2);
    discoveryEntries.add(new DiscoveryEntryWithMetaInfo(new Version(42, 23), "testDomain1", "testInterfaceName", "testParticipantId1", new ProviderQos(), 4711l, 4712l, "testPublicKeyId1", true));
    discoveryEntries.add(new DiscoveryEntryWithMetaInfo(new Version(42, 23), "testDomain2", "testInterfaceName", "testParticipantId2", new ProviderQos(), 4721l, 4722l, "testPublicKeyId2", false));
    return discoveryEntries;
}
Also used : Version(joynr.types.Version) ArrayList(java.util.ArrayList) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) ProviderQos(joynr.types.ProviderQos)

Example 25 with DiscoveryEntryWithMetaInfo

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

the class DummyCapabilitiesDirectory method lookup.

@Override
@CheckForNull
public DiscoveryEntryWithMetaInfo lookup(String participantId, DiscoveryQos discoveryQos) {
    logger.info("!!!!!!!!!!!!!!!getCapabilitiesForParticipantId");
    DiscoveryEntryWithMetaInfo retrievedDiscoveryEntry = null;
    for (DiscoveryEntryWithMetaInfo entry : registeredCapabilities) {
        if (entry.getParticipantId().equals(participantId)) {
            retrievedDiscoveryEntry = entry;
            break;
        }
    }
    return retrievedDiscoveryEntry;
}
Also used : DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) CheckForNull(javax.annotation.CheckForNull)

Aggregations

DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)66 Test (org.junit.Test)32 Version (joynr.types.Version)29 ProviderQos (joynr.types.ProviderQos)24 DiscoveryEntry (joynr.types.DiscoveryEntry)16 HashSet (java.util.HashSet)14 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)13 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)11 Matchers.anyString (org.mockito.Matchers.anyString)10 InvocationOnMock (org.mockito.invocation.InvocationOnMock)10 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)9 Before (org.junit.Before)9 DiscoveryException (io.joynr.exceptions.DiscoveryException)7 MessagingQos (io.joynr.messaging.MessagingQos)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 Set (java.util.Set)7 Callback (io.joynr.proxy.Callback)6 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)5 Collection (java.util.Collection)5