@Test(expected = UpsertCacheItemException.class)
public void ShouldSetPreviousActiveValue_When_ExecuteExceptionIsThrown() throws Exception {

    IObject query = mock(IObject.class);
    IObject upsertQuery = mock(IObject.class);
    IKey keyIObject = mock(IKey.class);
    when(Keys.getOrAdd("info.smart_tools.smartactors.iobject.iobject.IObject")).thenReturn(keyIObject);
    when(IOC.resolve(keyIObject)).thenReturn(upsertQuery);
    when(specificKeyNameField.in(query)).thenReturn("key");
    IDatabaseTask upsertTask = mock(IDatabaseTask.class);
    IKey keyTask = mock(IKey.class);
    when(Keys.getOrAdd("db.cached_collection.upsert")).thenReturn(keyTask);
    when(IOC.resolve(eq(keyTask), any(), eq(collectionName), eq(query))).thenReturn(upsertTask);
    doThrow(new TaskExecutionException("")).when(upsertTask).execute();
    try {
        collection.upsert(query);
    } catch (UpsertCacheItemException e) {
        verify(upsertTask).execute();
        verify(specificKeyNameField, never()).in(eq(query));
        verify(isActiveField, times(1)).out(eq(query), eq(true));
        verify(isActiveField, times(1)).out(eq(query), eq(true));
        throw e;
    }
    fail();
}