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