Search in sources :

Example 21 with Version

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)));
}
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 22 with Version

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)));
}
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 Version

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);
}
Also used : Version(joynr.types.Version) Test(org.junit.Test)

Example 24 with Version

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));
}
Also used : RequestCaller(io.joynr.dispatching.RequestCaller) DiscoveryEntry(joynr.types.DiscoveryEntry) Callback(io.joynr.proxy.Callback) JoynrVersion(io.joynr.JoynrVersion) JoynrVersion(io.joynr.JoynrVersion) Version(joynr.types.Version) Test(org.junit.Test)

Example 25 with Version

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());
}
Also used : MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) Version(joynr.types.Version) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ProviderQos(joynr.types.ProviderQos) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Test(org.junit.Test)

Aggregations

Version (joynr.types.Version)65 Test (org.junit.Test)47 ProviderQos (joynr.types.ProviderQos)43 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)29 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)24 DiscoveryEntry (joynr.types.DiscoveryEntry)22 ArrayList (java.util.ArrayList)13 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)13 Matchers.anyString (org.mockito.Matchers.anyString)12 Callback (io.joynr.proxy.Callback)11 HashSet (java.util.HashSet)11 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)10 InvocationOnMock (org.mockito.invocation.InvocationOnMock)10 JoynrVersion (io.joynr.JoynrVersion)9 Address (joynr.system.RoutingTypes.Address)9 HashMap (java.util.HashMap)8 MqttAddress (joynr.system.RoutingTypes.MqttAddress)8 DiscoveryException (io.joynr.exceptions.DiscoveryException)7 Set (java.util.Set)7 DeferredVoid (io.joynr.provider.DeferredVoid)6