ClearCacheService extends CacheServiceImpl { public ClearCacheService withIgnoreUnsupported(Boolean s) { setIgnoreUnsupported(s); return this; }  @Override void doService(AdaptrisMessage msg); Boolean getIgnoreUnsupported(); void setIgnoreUnsupported(Boolean b); ClearCacheService withIgnoreUnsupported(Boolean s);  }
@Test public void testDoService_Quietly() throws Exception { Cache mockCache = Mockito.mock(Cache.class); Mockito.doThrow(new UnsupportedOperationException()).when(mockCache).clear(); CacheConnection cache = new CacheConnection(mockCache); ClearCacheService service = new ClearCacheService().withIgnoreUnsupported(true).withConnection(cache); ExampleServiceCase.execute(service, AdaptrisMessageFactory.getDefaultInstance().newMessage()); }
@Test(expected = ServiceException.class) public void testDoService_Exception() throws Exception { Cache mockCache = Mockito.mock(Cache.class); Mockito.doThrow(new CoreException()).when(mockCache).clear(); CacheConnection cache = new CacheConnection(mockCache); ClearCacheService service = new ClearCacheService().withIgnoreUnsupported(true).withConnection(cache); ExampleServiceCase.execute(service, AdaptrisMessageFactory.getDefaultInstance().newMessage()); }