use of joynr.types.Version 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.Version 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.Version in project joynr by bmwcarit.
the class VersionCompatibilityCheckerTest method testProviderWithHigherMinorCompatible.
@Test
public void testProviderWithHigherMinorCompatible() {
Version caller = new Version(1, 1);
Version provider = new Version(1, 2);
boolean result = subject.check(caller, provider);
assertTrue(result);
}
use of joynr.types.Version in project joynr by bmwcarit.
the class CapabilitiesRegistrarTest method registerWithCapRegistrar.
@SuppressWarnings("unchecked")
@Test
public void registerWithCapRegistrar() {
JoynrVersion currentJoynrVersion = (JoynrVersion) TestProvider.class.getAnnotation(JoynrVersion.class);
Version testVersion = new Version(currentJoynrVersion.major(), currentJoynrVersion.minor());
when(providerContainer.getInterfaceName()).thenReturn(TestProvider.INTERFACE_NAME);
RequestCaller requestCallerMock = mock(RequestCaller.class);
when(providerContainer.getRequestCaller()).thenReturn(requestCallerMock);
when(providerContainer.getSubscriptionPublisher()).thenReturn(subscriptionPublisher);
when(participantIdStorage.getProviderParticipantId(eq(domain), eq(TestProvider.INTERFACE_NAME))).thenReturn(participantId);
when(providerContainerFactory.create(testProvider)).thenReturn(providerContainer);
ArgumentCaptor<DiscoveryEntry> discoveryEntryCaptor = ArgumentCaptor.forClass(DiscoveryEntry.class);
registrar.registerProvider(domain, testProvider, providerQos);
verify(localDiscoveryAggregator).add(any(Callback.class), discoveryEntryCaptor.capture());
DiscoveryEntry actual = discoveryEntryCaptor.getValue();
Assert.assertEquals(actual.getProviderVersion(), testVersion);
Assert.assertEquals(actual.getDomain(), domain);
Assert.assertEquals(actual.getInterfaceName(), TestProvider.INTERFACE_NAME);
Assert.assertEquals(actual.getParticipantId(), participantId);
Assert.assertEquals(actual.getQos(), providerQos);
Assert.assertTrue((System.currentTimeMillis() - actual.getLastSeenDateMs()) < 5000);
Assert.assertTrue((actual.getExpiryDateMs() - expiryDateMs) < 5000);
Assert.assertEquals(actual.getPublicKeyId(), publicKeyId);
verify(providerDirectory).add(eq(participantId), eq(providerContainer));
}
use of joynr.types.Version in project joynr by bmwcarit.
the class CapabilitiesUtilsTest method testGetMqttAddressFromGlobalDiscoveryEntry.
@Test
public void testGetMqttAddressFromGlobalDiscoveryEntry() {
GlobalDiscoveryEntry globalDiscoveryEntry = new GlobalDiscoveryEntry(new Version(0, 0), "domain", "interfaceName", "participantId", new ProviderQos(), 0L, 0L, "publicKeyId", "{\"_typeName\":\"joynr.system.RoutingTypes.MqttAddress\",\"brokerUri\":\"tcp://broker:1883\",\"topic\":\"topic\"}");
Address result = CapabilityUtils.getAddressFromGlobalDiscoveryEntry(globalDiscoveryEntry);
assertTrue(result instanceof MqttAddress);
assertEquals("tcp://broker:1883", ((MqttAddress) result).getBrokerUri());
assertEquals("topic", ((MqttAddress) result).getTopic());
}
Aggregations