TEST_F(LocalCapabilitiesDirectoryTest, getCapabilitiesForInterfaceAddressDelegatesToCapabilitiesClient) { //simulate global capability directory would store two entries. EXPECT_CALL(*capabilitiesClient, getCapabilitiesForInterfaceAddress(DOMAIN_1_NAME ,INTERFACE_1_NAME,_)) .Times(1) .WillOnce(Invoke(this, &LocalCapabilitiesDirectoryTest::fakeGetCapabilitiesForInterfaceAddressWithResults)); types::ProviderQosRequirements qos; localCapabilitiesDirectory->getCapabilities(DOMAIN_1_NAME ,INTERFACE_1_NAME, callback, discoveryQos, qos); QList<CapabilityEntry> capabilities = callback->getResults(TIMEOUT); EXPECT_EQ(2, capabilities.size()); // check that the results contain the two channel ids bool firstParticipantIdFound = false; bool secondParticipantIdFound = false; for (int i = 0; i < capabilities.size(); i++) { CapabilityEntry entry = capabilities.at(i); EXPECT_QSTREQ(DOMAIN_1_NAME, entry.getDomain()); EXPECT_QSTREQ(INTERFACE_1_NAME, entry.getInterfaceName()); QString participantId = entry.getParticipantId(); if (participantId == dummyParticipantId1) { firstParticipantIdFound = true; } else if (participantId == dummyParticipantId2) { secondParticipantIdFound = true; } } EXPECT_TRUE(firstParticipantIdFound); EXPECT_TRUE(secondParticipantIdFound); }
void LocalCapabilitiesDirectory::remove(const std::string& domain, const std::string& interfaceName, const types::ProviderQos& qos) { // TODO does it make sense to remove any capability for a domain/interfaceName // without knowing which provider registered the capability QMutexLocker locker(cacheLock); QList<CapabilityEntry> entries = interfaceAddress2GlobalCapabilities.lookUpAll(InterfaceAddress( QString::fromStdString(domain), QString::fromStdString(interfaceName))); std::vector<std::string> participantIdsToRemove; types::DiscoveryEntry discoveryEntry; for (int i = 0; i < entries.size(); ++i) { CapabilityEntry entry = entries.at(i); if (entry.isGlobal()) { types::CapabilityInformation capInfo(domain, interfaceName, qos, capabilitiesClient->getLocalChannelId(), entry.getParticipantId().toStdString()); while (registeredGlobalCapabilities.erase( std::remove(registeredGlobalCapabilities.begin(), registeredGlobalCapabilities.end(), capInfo), registeredGlobalCapabilities.end()) != registeredGlobalCapabilities.end()) { } participantIdsToRemove.push_back(entry.getParticipantId().toStdString()); participantId2GlobalCapabilities.remove(entry.getParticipantId(), entry); interfaceAddress2GlobalCapabilities.remove( InterfaceAddress(entry.getDomain(), entry.getInterfaceName()), entry); } participantId2LocalCapability.remove(entry.getParticipantId(), entry); interfaceAddress2LocalCapabilities.remove( InterfaceAddress( QString::fromStdString(domain), QString::fromStdString(interfaceName)), entry); convertCapabilityEntryIntoDiscoveryEntry(entry, discoveryEntry); informObserversOnRemove(discoveryEntry); } if (!participantIdsToRemove.empty()) { capabilitiesClient->remove(participantIdsToRemove); } }
void DbusCapabilitiesUtil::copyJoynrCapaEntryToDbus(const CapabilityEntry& joynrEntry, joynr::messaging::types::Types::CapabilityEntry& dbusEntry) { dbusEntry.interfaceName = joynrEntry.getInterfaceName().toStdString(); dbusEntry.domain = joynrEntry.getDomain().toStdString(); dbusEntry.participantId = joynrEntry.getParticipantId().toStdString(); dbusEntry.global = joynrEntry.isGlobal(); // copy qos joynr::messaging::types::Types::ProviderQos qos; copyJoynrProviderQosToDbus(joynrEntry.getQos(), qos); dbusEntry.qos = qos; // at the moment only joynr messaging endpoint addresses are supported copyJoynrEndPointListToDbus(joynrEntry.getEndpointAddresses(), dbusEntry.endpointAdresses); }