Search in sources :

Example 26 with GlobalDiscoveryEntry

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

the class SerializationTest method serializeReplyWithCapabilityInfoArray.

@Test
public void serializeReplyWithCapabilityInfoArray() throws JsonGenerationException, JsonMappingException, IOException {
    Object response = new GlobalDiscoveryEntry[] { new GlobalDiscoveryEntry(new Version(47, 11), "domain", "interface", "participantId", new ProviderQos(), System.currentTimeMillis(), expiryDateMs, publicKeyId, "channelId") };
    Reply reply = new Reply(UUID.randomUUID().toString(), response);
    String writeValueAsString = objectMapper.writeValueAsString(reply);
    Reply receivedReply = objectMapper.readValue(writeValueAsString, Reply.class);
    GlobalDiscoveryEntry[] convertValue = objectMapper.convertValue(receivedReply.getResponse()[0], GlobalDiscoveryEntry[].class);
    Assert.assertArrayEquals((GlobalDiscoveryEntry[]) reply.getResponse()[0], convertValue);
    ComplexTestType2[] complexTestType2Array = { new ComplexTestType2(3, 4), new ComplexTestType2(5, 6) };
    ArrayList<ComplexTestType2> customListParam2List = new ArrayList<ComplexTestType2>();
    customListParam2List.add(new ComplexTestType2(3, 4));
    customListParam2List.add(new ComplexTestType2(5, 6));
    ComplexTestType2[] convertValue2 = objectMapper.convertValue(customListParam2List, ComplexTestType2[].class);
    Assert.assertArrayEquals(complexTestType2Array, convertValue2);
}
Also used : Version(joynr.types.Version) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ArrayList(java.util.ArrayList) Reply(joynr.Reply) ComplexTestType2(joynr.tests.testTypes.ComplexTestType2) ProviderQos(joynr.types.ProviderQos) Test(org.junit.Test)

Example 27 with GlobalDiscoveryEntry

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

the class GlobalCapabilitiesDirectoryClientTest method testAddWithCustomTTL.

@Test
public void testAddWithCustomTTL() {
    GlobalCapabilitiesDirectoryClient subjectInject = getClientWithCustomTTL(CUSTOM_TTL);
    messagingQos.setTtl_ms(CUSTOM_TTL);
    GlobalDiscoveryEntry capabilitiesDirectoryEntryMock = mock(GlobalDiscoveryEntry.class);
    subjectInject.add(callbackMock, capabilitiesDirectoryEntryMock);
    verify(capabilitiesProxyBuilderMock).setMessagingQos(eq(messagingQos));
    verify(globalCapabilitiesDirectoryProxyMock).add(eq(callbackMock), eq(capabilitiesDirectoryEntryMock));
}
Also used : GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) Test(org.junit.Test)

Example 28 with GlobalDiscoveryEntry

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

the class GlobalCapabilitiesDirectoryClientTest method testAdd.

@Test
public void testAdd() {
    messagingQos.setTtl_ms(DEFAULT_TTL_ADD_AND_REMOVE);
    GlobalDiscoveryEntry capabilitiesDirectoryEntryMock = mock(GlobalDiscoveryEntry.class);
    subject.add(callbackMock, capabilitiesDirectoryEntryMock);
    verify(capabilitiesProxyBuilderMock).setMessagingQos(eq(messagingQos));
    verify(globalCapabilitiesDirectoryProxyMock).add(eq(callbackMock), eq(capabilitiesDirectoryEntryMock));
}
Also used : GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) Test(org.junit.Test)

Example 29 with GlobalDiscoveryEntry

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

the class StaticCapabilitiesProvisioning method addAddressesToRoutingTable.

private void addAddressesToRoutingTable(RoutingTable routingTable) {
    for (DiscoveryEntry discoveryEntry : discoveryEntries) {
        if (discoveryEntry instanceof GlobalDiscoveryEntry) {
            GlobalDiscoveryEntry globalDiscoveryEntry = (GlobalDiscoveryEntry) discoveryEntry;
            boolean isGloballyVisible = (globalDiscoveryEntry.getQos().getScope() == ProviderScope.GLOBAL);
            final long expiryDateMs = Long.MAX_VALUE;
            final boolean isSticky = true;
            final boolean allowUpdate = false;
            routingTable.put(globalDiscoveryEntry.getParticipantId(), CapabilityUtils.getAddressFromGlobalDiscoveryEntry(globalDiscoveryEntry), isGloballyVisible, expiryDateMs, isSticky, allowUpdate);
        }
    }
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry)

Example 30 with GlobalDiscoveryEntry

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

the class StaticCapabilitiesProvisioning method addEntriesFromJson.

private void addEntriesFromJson(String provisionedCapabilitiesJsonFilename, ObjectMapper objectMapper, String localChannelId) {
    String provisionedCapabilitiesJsonString = resourceContentProvider.readFromFileOrResourceOrUrl(provisionedCapabilitiesJsonFilename);
    logger.trace("Statically provisioned capabilities JSON read: {}", provisionedCapabilitiesJsonString);
    List<GlobalDiscoveryEntry> newEntries = null;
    try {
        newEntries = objectMapper.readValue(provisionedCapabilitiesJsonString, new TypeReference<List<GlobalDiscoveryEntry>>() {
        });
        for (GlobalDiscoveryEntry globalDiscoveryEntry : newEntries) {
            globalDiscoveryEntry.setLastSeenDateMs(System.currentTimeMillis());
            Address address = CapabilityUtils.getAddressFromGlobalDiscoveryEntry(globalDiscoveryEntry);
            substituteInProcessAddressIfLocal(objectMapper, localChannelId, globalDiscoveryEntry, address);
            discoveryEntries.add(globalDiscoveryEntry);
        }
    } catch (IOException e) {
        String message = format("Unable to load provisioned capabilities. Invalid JSON value: %s", provisionedCapabilitiesJsonString);
        throw new JoynrRuntimeException(message, e);
    }
}
Also used : ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) InProcessAddress(io.joynr.messaging.inprocess.InProcessAddress) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) TypeReference(com.fasterxml.jackson.core.type.TypeReference) IOException(java.io.IOException) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException)

Aggregations

GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)45 Test (org.junit.Test)28 DiscoveryEntry (joynr.types.DiscoveryEntry)21 ProviderQos (joynr.types.ProviderQos)20 Version (joynr.types.Version)19 Callback (io.joynr.proxy.Callback)15 Matchers.anyString (org.mockito.Matchers.anyString)14 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)12 ArrayList (java.util.ArrayList)12 MqttAddress (joynr.system.RoutingTypes.MqttAddress)9 DeferredVoid (io.joynr.provider.DeferredVoid)8 Address (joynr.system.RoutingTypes.Address)6 InvocationOnMock (org.mockito.invocation.InvocationOnMock)6 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)5 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)5 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)5 List (java.util.List)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 MessagingQos (io.joynr.messaging.MessagingQos)3 Promise (io.joynr.provider.Promise)3