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