Search in sources :

Example 16 with JoynrIllegalStateException

use of io.joynr.exceptions.JoynrIllegalStateException in project joynr by bmwcarit.

the class ConnectorTest method unsubscriptionMethodCall.

@Test
public void unsubscriptionMethodCall() throws JoynrIllegalStateException {
    ConnectorInvocationHandler connector = createConnector();
    assertNotNull(connector);
    try {
        Future<String> future = new Future<String>();
        String subscriptionId = "subscriptionId";
        Object[] args = new Object[] { subscriptionId };
        Method method = LocalisationSubscriptionInterface.class.getDeclaredMethod("unsubscribeFromGPSPosition", String.class);
        UnsubscribeInvocation unsubscribeInvocation = new UnsubscribeInvocation(method, args, future);
        connector.executeSubscriptionMethod(unsubscribeInvocation);
        verify(subscriptionManager, times(1)).unregisterSubscription(eq(fromParticipantId), eq(Sets.newHashSet(toDiscoveryEntry)), eq(subscriptionId), any(MessagingQos.class));
    } catch (Exception e) {
        // This is what is supposed to happen -> no error handling
        fail("Calling a subscription method with no expiry date throws an exception.");
    }
}
Also used : UnsubscribeInvocation(io.joynr.proxy.invocation.UnsubscribeInvocation) MessagingQos(io.joynr.messaging.MessagingQos) Method(java.lang.reflect.Method) SubscriptionException(io.joynr.exceptions.SubscriptionException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JoynrIllegalStateException(io.joynr.exceptions.JoynrIllegalStateException) Test(org.junit.Test)

Example 17 with JoynrIllegalStateException

use of io.joynr.exceptions.JoynrIllegalStateException in project joynr by bmwcarit.

the class SerializationTest method serializeReplyWithJoynrIllegalStateException.

@Test
public void serializeReplyWithJoynrIllegalStateException() throws IOException {
    JoynrIllegalStateException error = new JoynrIllegalStateException("detail message: JoynrIllegalStateException");
    Reply reply = new Reply(UUID.randomUUID().toString(), error);
    String writeValueAsString = objectMapper.writeValueAsString(reply);
    System.out.println(writeValueAsString);
    Reply receivedReply = objectMapper.readValue(writeValueAsString, Reply.class);
    Assert.assertEquals(reply, receivedReply);
}
Also used : Reply(joynr.Reply) JoynrIllegalStateException(io.joynr.exceptions.JoynrIllegalStateException) Test(org.junit.Test)

Example 18 with JoynrIllegalStateException

use of io.joynr.exceptions.JoynrIllegalStateException in project joynr by bmwcarit.

the class MasterRegistrationControlEntryManager method findByUserIdDomainInterfaceNameOperationAndType.

private MasterRegistrationControlEntryEntity findByUserIdDomainInterfaceNameOperationAndType(String userId, String domain, String interfaceName, ControlEntryType type) {
    Query query = entityManager.createQuery("select mrce from MasterRegistrationControlEntryEntity mrce " + "where mrce.userId = :userId and mrce.domain = :domain and mrce.interfaceName = :interfaceName and mrce.type = :type", MasterRegistrationControlEntryEntity.class);
    query.setParameter("userId", userId);
    query.setParameter("domain", domain);
    query.setParameter("interfaceName", interfaceName);
    query.setParameter("type", type);
    List<MasterRegistrationControlEntryEntity> resultList = query.getResultList();
    MasterRegistrationControlEntryEntity entity = null;
    if (resultList.size() == 1) {
        entity = resultList.get(0);
    } else if (resultList.size() > 1) {
        throw new JoynrIllegalStateException(String.format("Too many results found for %s with userId / domain / interfaceName / type: %s / %s / %s / %s", MasterRegistrationControlEntryEntity.class.getSimpleName(), userId, domain, interfaceName, type));
    }
    return entity;
}
Also used : Query(javax.persistence.Query) MasterRegistrationControlEntryEntity(io.joynr.accesscontrol.global.jee.persistence.MasterRegistrationControlEntryEntity) JoynrIllegalStateException(io.joynr.exceptions.JoynrIllegalStateException)

Example 19 with JoynrIllegalStateException

use of io.joynr.exceptions.JoynrIllegalStateException in project joynr by bmwcarit.

the class MasterAccessControlEntryManager method findByUserIdDomainInterfaceNameOperationAndType.

private MasterAccessControlEntryEntity findByUserIdDomainInterfaceNameOperationAndType(String userId, String domain, String interfaceName, String operation, ControlEntryType type) {
    Query query = entityManager.createQuery("select mace from MasterAccessControlEntryEntity mace " + "where mace.userId = :userId and mace.domain = :domain and mace.interfaceName = :interfaceName " + "and mace.operation = :operation and mace.type = :type", MasterAccessControlEntryEntity.class);
    query.setParameter("userId", userId);
    query.setParameter("domain", domain);
    query.setParameter("interfaceName", interfaceName);
    query.setParameter("operation", operation);
    query.setParameter("type", type);
    List<MasterAccessControlEntryEntity> resultList = query.getResultList();
    MasterAccessControlEntryEntity entity = null;
    if (resultList.size() == 1) {
        entity = resultList.get(0);
    } else if (resultList.size() > 1) {
        throw new JoynrIllegalStateException(format("Too many master access control entries for unique key uid / domain / interfaceName /operation: %s / %s / %s / %s", userId, domain, interfaceName, operation));
    }
    return entity;
}
Also used : MasterAccessControlEntryEntity(io.joynr.accesscontrol.global.jee.persistence.MasterAccessControlEntryEntity) Query(javax.persistence.Query) JoynrIllegalStateException(io.joynr.exceptions.JoynrIllegalStateException)

Aggregations

JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)19 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)5 JoynrDelayMessageException (io.joynr.exceptions.JoynrDelayMessageException)4 Query (javax.persistence.Query)4 OneWayRequest (joynr.OneWayRequest)3 ApplicationException (joynr.exceptions.ApplicationException)3 Test (org.junit.Test)3 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)2 ExpiryDate (io.joynr.common.ExpiryDate)2 DiscoveryException (io.joynr.exceptions.DiscoveryException)2 JoynrMessageNotSentException (io.joynr.exceptions.JoynrMessageNotSentException)2 SubscriptionException (io.joynr.exceptions.SubscriptionException)2 MessagingQos (io.joynr.messaging.MessagingQos)2 Method (java.lang.reflect.Method)2 URISyntaxException (java.net.URISyntaxException)2 CheckForNull (javax.annotation.CheckForNull)2 SSLHandshakeException (javax.net.ssl.SSLHandshakeException)2 MethodMetaInformation (joynr.MethodMetaInformation)2 PeriodicSubscriptionQos (joynr.PeriodicSubscriptionQos)2 Reply (joynr.Reply)2