TEST_F(CapabilitiesAggregatorTest, lookup_byInterface_addsInProcessAddress){
    EXPECT_CALL(*mockDispatcher, containsRequestCaller(participantId))
            .Times(1)
            .WillOnce(Return(true));
    EXPECT_CALL(*mockDispatcher, lookupRequestCaller(participantId))
            .Times(1)
            .WillOnce(Return(requestCaller));
    EXPECT_CALL(*mockCapabilitiesStub, lookup(domain, interfaceName, _, _))
            .Times(1)
            .WillOnce(Return(mockLookupResults));

    QList<CapabilityEntry> results = capAggregator->lookup(domain, interfaceName, types::ProviderQosRequirements(), discoveryQos);
    ASSERT_EQ(1, results.size());
    CapabilityEntry firstEntry = results.first();
    ASSERT_EQ(1, firstEntry.getEndpointAddresses().size());
    QSharedPointer<joynr::system::Address> firstAddress = firstEntry.getEndpointAddresses().first();
    ASSERT_STREQ(InProcessEndpointAddress::ENDPOINTADDRESSTYPE.toLatin1(), firstAddress->metaObject()->className());
    QSharedPointer<InProcessEndpointAddress> inProcessAddress = firstAddress.dynamicCast<InProcessEndpointAddress>();
    EXPECT_EQ(requestCaller, inProcessAddress->getRequestCaller());
}
TEST_F(CapabilitiesAggregatorTest, async_lookup_byId_addsInProcessAddress){
    EXPECT_CALL(*mockDispatcher, containsRequestCaller(participantId))
            .Times(1)
            .WillOnce(Return(true));
    EXPECT_CALL(*mockDispatcher, lookupRequestCaller(participantId))
            .Times(1)
            .WillOnce(Return(requestCaller));
    EXPECT_CALL(*mockCapabilitiesStub, lookup(participantId, _))
            .Times(1)
            .WillOnce(InvokeWithoutArgs(this, &CapabilitiesAggregatorTest::fakeLookupBlocking));

    QSharedPointer<MockLocalCapabilitiesDirectoryCallback> callback(new MockLocalCapabilitiesDirectoryCallback());
    capAggregator->lookup(participantId, discoveryQos, callback);
    QList<CapabilityEntry> results(callback->getResults(3000));

    ASSERT_EQ(1, results.size());
    CapabilityEntry firstEntry = results.first();
    ASSERT_EQ(1, firstEntry.getEndpointAddresses().size());
    QSharedPointer<joynr::system::Address> firstAddress = firstEntry.getEndpointAddresses().first();
    ASSERT_STREQ(InProcessEndpointAddress::ENDPOINTADDRESSTYPE.toLatin1(), firstAddress->metaObject()->className());
    QSharedPointer<InProcessEndpointAddress> inProcessAddress = firstAddress.dynamicCast<InProcessEndpointAddress>();
    EXPECT_EQ(requestCaller, inProcessAddress->getRequestCaller());
}
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);
}