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