use of io.joynr.provider.DeferredVoid in project joynr by bmwcarit.
the class LocalCapabilitiesDirectoryTest method addGlobalCapSucceeds_NextAddShallNotAddGlobalAgain.
@SuppressWarnings("unchecked")
@Test(timeout = 1000)
public void addGlobalCapSucceeds_NextAddShallNotAddGlobalAgain() throws InterruptedException {
ProviderQos providerQos = new ProviderQos();
providerQos.setScope(ProviderScope.GLOBAL);
String participantId = LocalCapabilitiesDirectoryTest.class.getName() + ".addGlobalCapSucceeds_NextAddShallNotAddGlobalAgain";
String domain = "testDomain";
final DiscoveryEntry discoveryEntry = new DiscoveryEntry(new Version(47, 11), domain, TestInterface.INTERFACE_NAME, participantId, providerQos, System.currentTimeMillis(), expiryDateMs, publicKeyId);
globalDiscoveryEntry = new GlobalDiscoveryEntry(new Version(47, 11), domain, TestInterface.INTERFACE_NAME, participantId, providerQos, System.currentTimeMillis(), expiryDateMs, publicKeyId, channelAddressSerialized);
Promise<DeferredVoid> promise = localCapabilitiesDirectory.add(discoveryEntry);
promise.then(new PromiseListener() {
@Override
public void onFulfillment(Object... values) {
Mockito.doAnswer(createAddAnswerWithSuccess()).when(globalCapabilitiesClient).add(any(Callback.class), eq(globalDiscoveryEntry));
verify(globalDiscoveryEntryCacheMock).add(eq(globalDiscoveryEntry));
verify(globalCapabilitiesClient).add(any(Callback.class), eq(globalDiscoveryEntry));
reset(globalCapabilitiesClient);
localCapabilitiesDirectory.add(discoveryEntry);
verify(globalCapabilitiesClient, timeout(200).never()).add(any(Callback.class), eq(globalDiscoveryEntry));
}
@Override
public void onRejection(JoynrException error) {
Assert.fail("adding capability failed: " + error);
}
});
}
use of io.joynr.provider.DeferredVoid in project joynr by bmwcarit.
the class LocalCapabilitiesDirectoryImpl method remove.
@Override
public io.joynr.provider.Promise<io.joynr.provider.DeferredVoid> remove(String participantId) {
DeferredVoid deferred = new DeferredVoid();
DiscoveryEntry entryToRemove = localDiscoveryEntryStore.lookup(participantId, Long.MAX_VALUE);
if (entryToRemove != null) {
remove(entryToRemove);
deferred.resolve();
} else {
deferred.reject(new ProviderRuntimeException("Failed to remove participantId: " + participantId));
}
return new Promise<>(deferred);
}
use of io.joynr.provider.DeferredVoid in project joynr by bmwcarit.
the class IltProvider method methodToFireBroadcastWithMultipleByteBufferParameters.
/*
* methodToFireBroadcastWithMultipleByteBufferParameters
*/
@Override
public Promise<DeferredVoid> methodToFireBroadcastWithMultipleByteBufferParameters(Byte[] byteBufferIn1, Byte[] byteBufferIn2, String[] partitions) {
logger.info("**************************************************************************");
logger.info("* IltProvider.methodToFireBroadcastWithMultipleByteBufferParameters called");
logger.info("**************************************************************************");
DeferredVoid deferred = new DeferredVoid();
fireBroadcastWithMultipleByteBufferParameters(byteBufferIn1, byteBufferIn2, partitions);
deferred.resolve();
return new Promise<DeferredVoid>(deferred);
}
use of io.joynr.provider.DeferredVoid in project joynr by bmwcarit.
the class IltProvider method methodToFireBroadcastWithSingleEnumerationParameter.
/*
* methodToFireBroadcastWithSingleEnumerationParameter
*/
@Override
public Promise<DeferredVoid> methodToFireBroadcastWithSingleEnumerationParameter(String[] partitions) {
logger.warn("************************************************************************");
logger.warn("* IltProvider.methodToFireBroadcastWithSingleEnumerationParameter called");
logger.warn("************************************************************************");
DeferredVoid deferred = new DeferredVoid();
ExtendedTypeCollectionEnumerationInTypeCollection enumerationOut = ExtendedTypeCollectionEnumerationInTypeCollection.ENUM_2_VALUE_EXTENSION_FOR_TYPECOLLECTION;
fireBroadcastWithSingleEnumerationParameter(enumerationOut, partitions);
deferred.resolve();
return new Promise<DeferredVoid>(deferred);
}
use of io.joynr.provider.DeferredVoid in project joynr by bmwcarit.
the class IltProvider method methodWithoutErrorEnum.
/*
* methodWithoutErrorEnum
*/
@Override
public Promise<DeferredVoid> methodWithoutErrorEnum(String wantedExceptionArg) {
logger.warn("*******************************************");
logger.warn("* IltProvider.methodWithoutErrorEnum called");
logger.warn("*******************************************");
DeferredVoid deferred = new DeferredVoid();
if (wantedExceptionArg.equals("ProviderRuntimeException")) {
deferred.reject(new ProviderRuntimeException("Exception from methodWithoutErrorEnum"));
} else {
deferred.resolve();
}
return new Promise<DeferredVoid>(deferred);
}
Aggregations