AsyncJobWorkerImpl implements AsyncJobWorker { protected void afterExecuteWorker(String jobSequenceId, BLogicResult blogicResult) { Integer blogicStatus = blogicResult == null ? null : blogicResult .getBlogicStatus(); try { boolean updated = jobStatusChanger.changeToEndStatus(jobSequenceId, blogicResult); if (!updated) { LOGGER.error(LogId.EAL025025, jobSequenceId, blogicStatus); } } catch (Exception e) { LOGGER.error(LogId.EAL025025, e, jobSequenceId, blogicStatus); } } protected  AsyncJobWorkerImpl(BLogicResolver blogicResolver,
            BLogicExceptionHandlerResolver blogicExceptionHandlerResolver,
            ApplicationContextResolver blogicApplicationContextResolver,
            JobControlFinder jobControlFinder,
            BLogicParamConverter blogicParamConverter,
            BLogicExecutor blogicExecutor, JobStatusChanger jobStatusChanger); boolean beforeExecute(final String jobSequenceId); @Override void executeWorker(final String jobSequenceId);  }
@Test public void testAfterExecuteWorker01() throws Exception { when( mockJobStatusChanger.changeToEndStatus(anyString(), any(BLogicResult.class))).thenReturn(true); BLogicResult blogicResult = new BLogicResult() { { setBlogicStatus(1); } }; AsyncJobWorkerImpl target = new AsyncJobWorkerImpl(mockBLogicResolver, mockBLogicExceptionHandlerResolver, mockBLogicApplicationContextResolver, mockJobControlFinder, mockBLogicParamConverter, mockBLogicExecutor, mockJobStatusChanger); target.afterExecuteWorker("000001", blogicResult); verify(mockJobStatusChanger).changeToEndStatus("000001", blogicResult); }
@Test public void testAfterExecuteWorker02() throws Exception { when( mockJobStatusChanger.changeToEndStatus(anyString(), any(BLogicResult.class))).thenReturn(false); BLogicResult blogicResult = new BLogicResult() { { setBlogicStatus(1); } }; AsyncJobWorkerImpl target = new AsyncJobWorkerImpl(mockBLogicResolver, mockBLogicExceptionHandlerResolver, mockBLogicApplicationContextResolver, mockJobControlFinder, mockBLogicParamConverter, mockBLogicExecutor, mockJobStatusChanger); target.afterExecuteWorker("000001", blogicResult); verify(mockJobStatusChanger).changeToEndStatus("000001", blogicResult); assertThat(logger.getLoggingEvents(), is(asList(error( "[EAL025025] Job status update error. jobSequenceId:000001 blogicStatus:1")))); }
@Test public void testAfterExecuteWorker03() throws Exception { Exception ex = new RuntimeException("for test."); when(mockJobStatusChanger.changeToEndStatus(anyString(), any( BLogicResult.class))).thenThrow(ex); BLogicResult blogicResult = new BLogicResult() { { setBlogicStatus(1); } }; AsyncJobWorkerImpl target = new AsyncJobWorkerImpl(mockBLogicResolver, mockBLogicExceptionHandlerResolver, mockBLogicApplicationContextResolver, mockJobControlFinder, mockBLogicParamConverter, mockBLogicExecutor, mockJobStatusChanger); target.afterExecuteWorker("000001", blogicResult); verify(mockJobStatusChanger).changeToEndStatus("000001", blogicResult); assertThat(logger.getLoggingEvents(), is(asList(error(ex, "[EAL025025] Job status update error. jobSequenceId:000001 blogicStatus:1")))); }
@Test public void testAfterExecuteWorker04() throws Exception { when( mockJobStatusChanger.changeToEndStatus(anyString(), any(BLogicResult.class))).thenReturn(false); AsyncJobWorkerImpl target = new AsyncJobWorkerImpl(mockBLogicResolver, mockBLogicExceptionHandlerResolver, mockBLogicApplicationContextResolver, mockJobControlFinder, mockBLogicParamConverter, mockBLogicExecutor, mockJobStatusChanger); target.afterExecuteWorker("000001", null); verify(mockJobStatusChanger) .changeToEndStatus("000001", null); assertThat(logger.getLoggingEvents(), is(asList(error( "[EAL025025] Job status update error. jobSequenceId:000001 blogicStatus:null")))); }