Search in sources :

Example 11 with GlobalDiscoveryEntry

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

the class GlobalCapabilitiesDirectoryEjbTest method testAddAndLookupSingleDiscoveryEntryByParticipantId.

@Test
public void testAddAndLookupSingleDiscoveryEntryByParticipantId() {
    GlobalDiscoveryEntry resultBeforeAdd = subject.lookup(testParticpantId);
    assertNull(resultBeforeAdd);
    subject.add(testGlobalDiscoveryEntry);
    entityManager.flush();
    entityManager.clear();
    GlobalDiscoveryEntry result = subject.lookup(testParticpantId);
    assertNotNull(result);
    assertTrue(result instanceof GlobalDiscoveryEntry);
    assertFalse(result instanceof GlobalDiscoveryEntryPersisted);
    GlobalDiscoveryEntry persisted = (GlobalDiscoveryEntry) result;
    assertEquals(testGlobalDiscoveryEntry.getInterfaceName(), persisted.getInterfaceName());
    assertEquals(testGlobalDiscoveryEntry.getDomain(), persisted.getDomain());
}
Also used : GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) GlobalDiscoveryEntryPersisted(io.joynr.capabilities.GlobalDiscoveryEntryPersisted) Test(org.junit.Test)

Example 12 with GlobalDiscoveryEntry

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

the class GlobalCapabilitiesDirectoryEjbTest method testAddAndRemoveSingleDiscoveryEntry.

@Test
public void testAddAndRemoveSingleDiscoveryEntry() {
    GlobalDiscoveryEntry resultBeforeRemove = subject.lookup(testParticpantId);
    assertNull(resultBeforeRemove);
    subject.add(testGlobalDiscoveryEntry);
    entityManager.flush();
    entityManager.clear();
    GlobalDiscoveryEntry result = subject.lookup(testParticpantId);
    assertNotNull(result);
    GlobalDiscoveryEntry persisted = (GlobalDiscoveryEntry) result;
    assertEquals(testGlobalDiscoveryEntry, persisted);
    subject.remove(testParticpantId);
    entityManager.flush();
    entityManager.clear();
    GlobalDiscoveryEntry resultAfterRemove = subject.lookup(testParticpantId);
    assertNull(resultAfterRemove);
}
Also used : GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) Test(org.junit.Test)

Example 13 with GlobalDiscoveryEntry

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

the class CapabilitiesDirectoryImpl method lookup.

@Override
public Promise<Lookup2Deferred> lookup(String forParticipantId) {
    Lookup2Deferred deferred = new Lookup2Deferred();
    logger.debug("Searching discovery entries for participantId: {}", forParticipantId);
    DiscoveryEntry discoveryEntry = discoveryEntryStore.lookup(forParticipantId, DiscoveryQos.NO_FILTER.getCacheMaxAgeMs());
    if (discoveryEntry == null) {
        deferred.resolve(null);
    } else {
        deferred.resolve((GlobalDiscoveryEntry) discoveryEntry);
    }
    return new Promise<Lookup2Deferred>(deferred);
}
Also used : Promise(io.joynr.provider.Promise) DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry)

Example 14 with GlobalDiscoveryEntry

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

the class CapabilitiesDirectoryImpl method add.

@Override
public Promise<DeferredVoid> add(GlobalDiscoveryEntry[] globalDiscoveryEntries) {
    DeferredVoid deferred = new DeferredVoid();
    for (GlobalDiscoveryEntry globalDiscoveryEntry : globalDiscoveryEntries) {
        add(globalDiscoveryEntry);
    }
    deferred.resolve();
    return new Promise<DeferredVoid>(deferred);
}
Also used : Promise(io.joynr.provider.Promise) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) DeferredVoid(io.joynr.provider.DeferredVoid)

Example 15 with GlobalDiscoveryEntry

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

the class GlobalCapabilitiesDirectoryClientTest method testLookupDomainsOnFailure.

@Test
public void testLookupDomainsOnFailure() {
    @SuppressWarnings("unchecked") Callback<List<GlobalDiscoveryEntry>> callbackListOfGlobalDiscoveryEntriesMock = (Callback<List<GlobalDiscoveryEntry>>) mock(Callback.class);
    Callback<GlobalDiscoveryEntry[]> callback = lookupDomainsHelper(callbackListOfGlobalDiscoveryEntriesMock);
    JoynrRuntimeException error = new JoynrRuntimeException();
    callback.onFailure(error);
    verify(callbackListOfGlobalDiscoveryEntriesMock).onFailure(eq(error));
    verify(callbackListOfGlobalDiscoveryEntriesMock, times(0)).onSuccess(anyListOf(GlobalDiscoveryEntry.class));
}
Also used : Callback(io.joynr.proxy.Callback) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ArrayList(java.util.ArrayList) List(java.util.List) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

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