Search in sources :

Example 1 with ObjectDoesNotExistException

use of org.mule.runtime.api.store.ObjectDoesNotExistException in project mule by mulesoft.

the class ObjectStoreProducerTestCase method setUp.

@Before
public void setUp() throws Exception {
    this.values = new HashMap<>();
    this.values.put("fruit", "banana");
    this.values.put("icecream", "chocolate");
    this.values.put("drink", "coke");
    when(this.objectStore.retrieve(Mockito.anyString())).thenAnswer(invocation -> {
        Serializable value = values.get(invocation.getArguments()[0]);
        if (value == null) {
            throw new ObjectDoesNotExistException();
        }
        return value;
    });
    when(this.objectStore.allKeys()).thenReturn(new ArrayList<>(this.values.keySet()));
    this.producer = new ObjectStoreProducer<>(this.objectStore);
}
Also used : Serializable(java.io.Serializable) ObjectDoesNotExistException(org.mule.runtime.api.store.ObjectDoesNotExistException) Before(org.junit.Before)

Example 2 with ObjectDoesNotExistException

use of org.mule.runtime.api.store.ObjectDoesNotExistException in project mule by mulesoft.

the class ManagedStoresTestCase method testObjectStore.

private void testObjectStore(ObjectStore<String> store) throws ObjectStoreException {
    ObjectStoreException e = null;
    store.store("key1", "value1");
    assertEquals("value1", store.retrieve("key1"));
    assertTrue(store.contains("key1"));
    store.clear();
    assertFalse(store.contains("key1"));
    store.store("key1", "value1");
    try {
        store.store("key1", "value1");
    } catch (ObjectAlreadyExistsException e1) {
        e = e1;
    }
    assertNotNull(e);
    e = null;
    assertEquals(1, store.allKeys().size());
    assertEquals("key1", store.allKeys().get(0));
    assertEquals("value1", store.remove("key1"));
    assertFalse(store.contains("key1"));
    try {
        store.retrieve("key1");
    } catch (ObjectDoesNotExistException e1) {
        e = e1;
    }
    assertNotNull(e);
    e = null;
    try {
        store.remove("key1");
    } catch (ObjectDoesNotExistException e1) {
        e = e1;
    }
    assertNotNull(e);
}
Also used : ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) ObjectDoesNotExistException(org.mule.runtime.api.store.ObjectDoesNotExistException) ObjectAlreadyExistsException(org.mule.runtime.api.store.ObjectAlreadyExistsException)

Example 3 with ObjectDoesNotExistException

use of org.mule.runtime.api.store.ObjectDoesNotExistException in project mule by mulesoft.

the class EventCorrelator method getEventGroup.

protected EventGroup getEventGroup(String groupId) throws ObjectStoreException {
    try {
        EventGroup eventGroup = (EventGroup) correlatorStore.retrieve(groupId, getEventGroupsPartitionKey());
        if (!eventGroup.isInitialised()) {
            try {
                DeserializationPostInitialisable.Implementation.init(eventGroup, muleContext);
            } catch (Exception e) {
                throw new ObjectStoreException(e);
            }
        }
        eventGroup.initEventsStore(correlatorStore);
        return eventGroup;
    } catch (ObjectDoesNotExistException e) {
        return null;
    }
}
Also used : ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) ObjectDoesNotExistException(org.mule.runtime.api.store.ObjectDoesNotExistException) EventGroup(org.mule.runtime.core.internal.routing.EventGroup) ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) ObjectDoesNotExistException(org.mule.runtime.api.store.ObjectDoesNotExistException) MuleException(org.mule.runtime.api.exception.MuleException) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) RegistrationException(org.mule.runtime.core.privileged.registry.RegistrationException) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) RoutingException(org.mule.runtime.core.privileged.routing.RoutingException) ObjectAlreadyExistsException(org.mule.runtime.api.store.ObjectAlreadyExistsException)

Aggregations

ObjectDoesNotExistException (org.mule.runtime.api.store.ObjectDoesNotExistException)3 ObjectAlreadyExistsException (org.mule.runtime.api.store.ObjectAlreadyExistsException)2 ObjectStoreException (org.mule.runtime.api.store.ObjectStoreException)2 Serializable (java.io.Serializable)1 Before (org.junit.Before)1 DefaultMuleException (org.mule.runtime.api.exception.DefaultMuleException)1 MuleException (org.mule.runtime.api.exception.MuleException)1 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)1 MessagingException (org.mule.runtime.core.internal.exception.MessagingException)1 EventGroup (org.mule.runtime.core.internal.routing.EventGroup)1 RegistrationException (org.mule.runtime.core.privileged.registry.RegistrationException)1 RoutingException (org.mule.runtime.core.privileged.routing.RoutingException)1