@Test public void testShouldRunServiceOnce() throws Exception { when(mockCondition.evaluate(message)) .thenReturn(true) .thenReturn(false); logicalExpression.doService(message); verify(mockService, times(1)).doService(message); }
@Override public void doService(AdaptrisMessage msg) throws ServiceException { int loopCount = 0; try { log.trace("Running logical test on 'WHILE', with condition class {}", this.getCondition().getClass().getSimpleName()); while(this.getCondition().evaluate(msg)) { log.trace("Logical 'IF' evaluated to true on WHILE test, running service."); getThen().getService().doService(msg); loopCount ++; if (!continueLooping(loopCount, msg)) { break; } } log.trace("Logical 'WHILE' completed, exiting."); } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } }
While extends ServiceImp { @Override public void doService(AdaptrisMessage msg) throws ServiceException { int loopCount = 0; try { log.trace("Running logical test on 'WHILE', with condition class {}", this.getCondition().getClass().getSimpleName()); while(this.getCondition().evaluate(msg)) { log.trace("Logical 'IF' evaluated to true on WHILE test, running service."); getThen().getService().doService(msg); loopCount ++; if (!continueLooping(loopCount, msg)) { break; } } log.trace("Logical 'WHILE' completed, exiting."); } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } } }
While extends ServiceImp { @Override public void doService(AdaptrisMessage msg) throws ServiceException { int loopCount = 0; try { log.trace("Running logical test on 'WHILE', with condition class {}", this.getCondition().getClass().getSimpleName()); while(this.getCondition().evaluate(msg)) { log.trace("Logical 'IF' evaluated to true on WHILE test, running service."); getThen().getService().doService(msg); loopCount ++; if (!continueLooping(loopCount, msg)) { break; } } log.trace("Logical 'WHILE' completed, exiting."); } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } } While(); }
While extends ServiceImp { @Override public void doService(AdaptrisMessage msg) throws ServiceException { int loopCount = 0; try { log.trace("Running logical test on 'WHILE', with condition class {}", this.getCondition().getClass().getSimpleName()); while(this.getCondition().evaluate(msg)) { log.trace("Logical 'IF' evaluated to true on WHILE test, running service."); getThen().getService().doService(msg); loopCount ++; if (!continueLooping(loopCount, msg)) { break; } } log.trace("Logical 'WHILE' completed, exiting."); } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } } While(); @Override void doService(AdaptrisMessage msg); @Override void prepare(); @Override void start(); @Override void stop(); Condition getCondition(); void setCondition(Condition condition); ThenService getThen(); void setThen(ThenService ifTrueService); Integer getMaxLoops(); void setMaxLoops(Integer maxLoops); MaxLoopBehaviour getOnMaxLoops(); void setOnMaxLoops(MaxLoopBehaviour onMaxLoops); @SuppressWarnings("unchecked") T withMaxLoops(Integer maxLoops); @SuppressWarnings("unchecked") T withThen(ThenService t); @SuppressWarnings("unchecked") T withCondition(Condition c); @SuppressWarnings("unchecked") T withOnMaxLoops(MaxLoopBehaviour c); }
While extends ServiceImp { @Override public void doService(AdaptrisMessage msg) throws ServiceException { int loopCount = 0; try { log.trace("Running logical test on 'WHILE', with condition class {}", this.getCondition().getClass().getSimpleName()); while(this.getCondition().evaluate(msg)) { log.trace("Logical 'IF' evaluated to true on WHILE test, running service."); getThen().getService().doService(msg); loopCount ++; if (!continueLooping(loopCount, msg)) { break; } } log.trace("Logical 'WHILE' completed, exiting."); } catch (Exception e) { throw ExceptionHelper.wrapServiceException(e); } } While(); @Override void doService(AdaptrisMessage msg); @Override void prepare(); @Override void start(); @Override void stop(); Condition getCondition(); void setCondition(Condition condition); ThenService getThen(); void setThen(ThenService ifTrueService); Integer getMaxLoops(); void setMaxLoops(Integer maxLoops); MaxLoopBehaviour getOnMaxLoops(); void setOnMaxLoops(MaxLoopBehaviour onMaxLoops); @SuppressWarnings("unchecked") T withMaxLoops(Integer maxLoops); @SuppressWarnings("unchecked") T withThen(ThenService t); @SuppressWarnings("unchecked") T withCondition(Condition c); @SuppressWarnings("unchecked") T withOnMaxLoops(MaxLoopBehaviour c);  }