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