SyncJobOperatorImpl implements JobOperator { @Override public int start(String[] args) { BatchJobData batchJobData = convertBatchJobData(args); BLogicParam blogicParam = blogicParamConverter.convertBLogicParam( batchJobData); ApplicationContext blogicContext = applicationContextResolver.resolveApplicationContext( batchJobData); try { BLogic blogic = blogicResolver.resolveBLogic(blogicContext, blogicParam.getJobAppCd()); ExceptionHandler exceptionHandler = null; try { exceptionHandler = blogicExceptionHandlerResolver .resolveExceptionHandler(blogicContext, blogicParam .getJobAppCd()); } catch (Exception e) { } if (exceptionHandler == null) { LOGGER.warn(LogId.WAL025010); } BLogicResult result = blogicExecutor.execute(blogicContext, blogic, blogicParam, exceptionHandler); return result.getBlogicStatus(); } finally { applicationContextResolver.closeApplicationContext(blogicContext); } } SyncJobOperatorImpl(
            ApplicationContextResolver applicationContextResolver,
            BLogicParamConverter blogicParamConverter,
            BLogicExceptionHandlerResolver blogicExceptionHandlerResolver,
            BLogicResolver blogicResolver, BLogicExecutor blogicExecutor); @Override int start(String[] args);  }
@Test public void testStart01() throws Exception { BLogicResult blogicResult = new BLogicResult(); blogicResult.setBlogicStatus(234); BLogicParam blogicParam = new BLogicParam(); doReturn(blogicParam).when(blogicParamConverter).convertBLogicParam(any(BatchJobData.class)); doReturn(blogicResult).when(blogicExecutor).execute(blogicContext, blogic, blogicParam, exceptionHandler); int status = target.start(new String[] { "jobAppCd" }); assertThat(status, is(234)); verify(blogicExecutor).execute(blogicContext, blogic, blogicParam, exceptionHandler); verify(applicationContextResolver).closeApplicationContext(blogicContext); }
@Test public void testStart02() throws Exception { BLogicResult blogicResult = new BLogicResult(); blogicResult.setBlogicStatus(234); BLogicParam blogicParam = new BLogicParam(); doReturn(blogicParam).when(blogicParamConverter).convertBLogicParam(any(BatchJobData.class)); doReturn(blogicResult).when(blogicExecutor).execute(blogicContext, blogic, blogicParam, null); when(blogicExceptionHandlerResolver.resolveExceptionHandler(any( ApplicationContext.class), anyString())).thenReturn(null); int status = target.start(new String[] { "jobAppCd" }); assertThat(status, is(234)); verify(blogicExecutor).execute(blogicContext, blogic, blogicParam, null); verify(applicationContextResolver).closeApplicationContext(blogicContext); assertThat(logger.getLoggingEvents(), is(asList(warn( "[WAL025010] The BLogic execution continues without an ExceptionHandler.")))); }
@Test public void testStart03() throws Exception { BLogicResult blogicResult = new BLogicResult(); blogicResult.setBlogicStatus(234); BLogicParam blogicParam = new BLogicParam(); doReturn(blogicParam).when(blogicParamConverter).convertBLogicParam(any(BatchJobData.class)); doReturn(blogicResult).when(blogicExecutor).execute(blogicContext, blogic, blogicParam, null); when(blogicExceptionHandlerResolver.resolveExceptionHandler(any( ApplicationContext.class), anyString())).thenThrow(new NoSuchBeanDefinitionException("test.")); int status = target.start(new String[] { "jobAppCd" }); assertThat(status, is(234)); verify(blogicExecutor).execute(blogicContext, blogic, blogicParam, null); verify(applicationContextResolver).closeApplicationContext(blogicContext); assertThat(logger.getLoggingEvents(), is(asList(warn( "[WAL025010] The BLogic execution continues without an ExceptionHandler.")))); }