RepairExternalCallDbImpl implements RepairExternalCallService { @Override public void repairProcessingExternalCalls() { List<ExternalCall> extCalls = findProcessingExternalCalls(); LOG.debug("Found {} external call(s) for repairing ...", extCalls.size()); int batchStartIncl = 0; int batchEndExcl; while (batchStartIncl < extCalls.size()) { batchEndExcl = min(batchStartIncl + BATCH_SIZE, extCalls.size()); updateExternalCallsInDB(extCalls.subList(batchStartIncl, batchEndExcl)); batchStartIncl = batchEndExcl; } } @Autowired  RepairExternalCallDbImpl(PlatformTransactionManager transactionManager); @Override void repairProcessingExternalCalls(); void setExternalCallDao(ExternalCallDao externalCallDao);  }
@Test public void testRepairProcessingExternalCallsMany() throws Exception { ExternalCall[] externalCalls = createAndSaveExternalCalls(119); externalCallService.repairProcessingExternalCalls(); externalCallService.repairProcessingExternalCalls(); externalCallService.repairProcessingExternalCalls(); for (ExternalCall externalCall : externalCalls) { LOG.info("Verifying external call {}", externalCall); ExternalCall found = externalCallDao.getExternalCall( externalCall.getOperationName(), externalCall.getEntityId()); assertThat(found, notNullValue()); assertThat(found.getState(), is(ExternalCallStateEnum.FAILED)); } }
@Test public void testRepairProcessingExternalCallsOne() throws Exception { ExternalCall externalCall = createAndSaveExternalCalls(1)[0]; externalCallService.repairProcessingExternalCalls(); externalCallService.repairProcessingExternalCalls(); ExternalCall found = externalCallDao.getExternalCall( externalCall.getOperationName(), externalCall.getEntityId()); assertThat(found, notNullValue()); assertThat(found.getState(), is(ExternalCallStateEnum.FAILED)); }