Search in sources :

Example 1 with DeferredVoid

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);
        }
    });
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) Version(joynr.types.Version) PromiseListener(io.joynr.provider.PromiseListener) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) JoynrException(io.joynr.exceptions.JoynrException) Matchers.anyString(org.mockito.Matchers.anyString) ProviderQos(joynr.types.ProviderQos) DeferredVoid(io.joynr.provider.DeferredVoid) Test(org.junit.Test)

Example 2 with DeferredVoid

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);
}
Also used : Promise(io.joynr.provider.Promise) DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) DeferredVoid(io.joynr.provider.DeferredVoid) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException)

Example 3 with DeferredVoid

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);
}
Also used : Promise(io.joynr.provider.Promise) DeferredVoid(io.joynr.provider.DeferredVoid)

Example 4 with DeferredVoid

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);
}
Also used : Promise(io.joynr.provider.Promise) ExtendedTypeCollectionEnumerationInTypeCollection(joynr.interlanguagetest.namedTypeCollection2.ExtendedTypeCollectionEnumerationInTypeCollection) DeferredVoid(io.joynr.provider.DeferredVoid)

Example 5 with DeferredVoid

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);
}
Also used : Promise(io.joynr.provider.Promise) DeferredVoid(io.joynr.provider.DeferredVoid) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException)

Aggregations

DeferredVoid (io.joynr.provider.DeferredVoid)41 Promise (io.joynr.provider.Promise)36 ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)7 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)5 MapStringString (joynr.interlanguagetest.namedTypeCollection2.MapStringString)4 JoynrException (io.joynr.exceptions.JoynrException)3 Deferred (io.joynr.provider.Deferred)2 PromiseListener (io.joynr.provider.PromiseListener)2 ApplicationException (joynr.exceptions.ApplicationException)2 StructWithStringArray (joynr.interlanguagetest.namedTypeCollection1.StructWithStringArray)2 DiscoveryEntry (joynr.types.DiscoveryEntry)2 AbstractModule (com.google.inject.AbstractModule)1 TypeLiteral (com.google.inject.TypeLiteral)1 GlobalDiscoveryEntryPersisted (io.joynr.capabilities.GlobalDiscoveryEntryPersisted)1 JoynrPropertiesModule (io.joynr.common.JoynrPropertiesModule)1 JoynrMessageScopeModule (io.joynr.context.JoynrMessageScopeModule)1 MultiReturnValuesContainer (io.joynr.dispatcher.rpc.MultiReturnValuesContainer)1 RequestCaller (io.joynr.dispatching.RequestCaller)1 RequestCallerFactory (io.joynr.dispatching.RequestCallerFactory)1 RequestInterpreter (io.joynr.dispatching.rpc.RequestInterpreter)1