Search in sources :

Example 36 with DiscoveryEntry

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

the class CapabilitiesUtilsTest method compareCollectionOfDiscoveryEntries.

private void compareCollectionOfDiscoveryEntries(Collection<DiscoveryEntry> convertedEntries, Collection<DiscoveryEntryWithMetaInfo> discoveryEntries) {
    int numberOfValidConversions = 0;
    assertEquals(discoveryEntries.size(), convertedEntries.size());
    for (DiscoveryEntryWithMetaInfo discoveryEntry : discoveryEntries) {
        for (DiscoveryEntry convertedEntry : convertedEntries) {
            if (convertedEntry.getParticipantId().equals(discoveryEntry.getParticipantId())) {
                assertTrue(DiscoveryEntry.class.equals(convertedEntry.getClass()));
                compareDiscoveryEntries(discoveryEntry.getIsLocal(), convertedEntry, discoveryEntry);
                numberOfValidConversions++;
                break;
            }
            continue;
        }
    }
    assertEquals(discoveryEntries.size(), numberOfValidConversions);
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo)

Example 37 with DiscoveryEntry

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

the class CapabilitiesUtilsTest method compareCollectionOfDiscoveryEntriesWithMetaInfo.

private void compareCollectionOfDiscoveryEntriesWithMetaInfo(boolean isLocal, Collection<DiscoveryEntry> discoveryEntries, Collection<DiscoveryEntryWithMetaInfo> convertedEntries) {
    int numberOfValidConversions = 0;
    assertEquals(discoveryEntries.size(), convertedEntries.size());
    for (DiscoveryEntry discoveryEntry : discoveryEntries) {
        for (DiscoveryEntryWithMetaInfo convertedEntry : convertedEntries) {
            if (convertedEntry.getParticipantId().equals(discoveryEntry.getParticipantId())) {
                assertTrue(DiscoveryEntryWithMetaInfo.class.equals(convertedEntry.getClass()));
                compareDiscoveryEntries(isLocal, discoveryEntry, convertedEntry);
                numberOfValidConversions++;
                break;
            }
            continue;
        }
    }
    assertEquals(discoveryEntries.size(), numberOfValidConversions);
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo)

Example 38 with DiscoveryEntry

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

the class CapabilitiesUtilsTest method createCollectionOfDiscoveryEntries.

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

Example 39 with DiscoveryEntry

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

the class CapabilitiesUtilsTest method testConvertLocalDiscoveryEntryToDiscoveryEntryWithMetaInfo.

@Test
public void testConvertLocalDiscoveryEntryToDiscoveryEntryWithMetaInfo() {
    boolean isLocal = true;
    DiscoveryEntry discoveryEntry = new DiscoveryEntry(new Version(42, 23), "testDomain", "testInterfaceName", "testParticipantId", new ProviderQos(), 4711l, 4712l, "testPublicKeyId");
    DiscoveryEntryWithMetaInfo convertedDiscoveryEntry = CapabilityUtils.convertToDiscoveryEntryWithMetaInfo(isLocal, discoveryEntry);
    compareDiscoveryEntries(isLocal, discoveryEntry, convertedDiscoveryEntry);
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) Version(joynr.types.Version) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) ProviderQos(joynr.types.ProviderQos) Test(org.junit.Test)

Example 40 with DiscoveryEntry

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

the class StaticCapabilitiesProvisioningTest method testOverrideJsonWithLegacy.

@Test
public void testOverrideJsonWithLegacy() throws IOException {
    Set<DiscoveryEntry> discoveryEntries = createDiscoveryEntries("io.joynr", GlobalCapabilitiesDirectory.INTERFACE_NAME, GlobalDomainAccessController.INTERFACE_NAME);
    LegacyCapabilitiesProvisioning.LegacyProvisioningPropertiesHolder properties = createLegacyProvisioningPropertiesHolder();
    final String serializedDiscoveryEntries = objectMapper.writeValueAsString(discoveryEntries);
    Injector injector = createInjectorForJsonValue(serializedDiscoveryEntries, properties);
    CapabilitiesProvisioning subject = injector.getInstance(CapabilitiesProvisioning.class);
    Collection<DiscoveryEntry> provisionedDiscoveryEntries = subject.getDiscoveryEntries();
    assertEquals(2, provisionedDiscoveryEntries.size());
    assertContainsEntryFor(provisionedDiscoveryEntries, GlobalCapabilitiesDirectory.INTERFACE_NAME, properties.capabilitiesDirectoryParticipantId, properties.discoveryDirectoryUrl);
    assertContainsEntryFor(provisionedDiscoveryEntries, GlobalDomainAccessController.INTERFACE_NAME, properties.domainAccessControllerParticipantId, properties.domainAccessControllerUrl);
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) Injector(com.google.inject.Injector) Test(org.junit.Test)

Aggregations

DiscoveryEntry (joynr.types.DiscoveryEntry)60 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)43 Test (org.junit.Test)30 ProviderQos (joynr.types.ProviderQos)25 Version (joynr.types.Version)22 Callback (io.joynr.proxy.Callback)18 Matchers.anyString (org.mockito.Matchers.anyString)17 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)16 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)15 ArrayList (java.util.ArrayList)14 HashSet (java.util.HashSet)9 InvocationOnMock (org.mockito.invocation.InvocationOnMock)9 DeferredVoid (io.joynr.provider.DeferredVoid)7 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)6 MqttAddress (joynr.system.RoutingTypes.MqttAddress)6 Injector (com.google.inject.Injector)5 MessagingQos (io.joynr.messaging.MessagingQos)4 Future (io.joynr.proxy.Future)4 CheckForNull (javax.annotation.CheckForNull)4 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)4