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());
}
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)));
}
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)));
}
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;
}
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;
}
Aggregations