SyncJobOperatorImpl implements JobOperator { protected BatchJobData convertBatchJobData(String[] args) { BatchJobData jobRecord = new BatchJobData(); int arrayLength = (ENV_JOB_ARG_MAX + 1 < args.length) ? ENV_JOB_ARG_MAX + 1 : args.length; String[] fixArgs = new String[arrayLength]; System.arraycopy(args, 0, fixArgs, 0, arrayLength); try { new CmdLineParser(jobRecord).parseArgument(fixArgs); } catch (CmdLineException e) { throw new BatchException(e); } if (jobRecord.getJobAppCd() == null || jobRecord.getJobAppCd().length() == 0) { jobRecord.setJobAppCd(getenv(ENV_JOB_APP_CD)); } StringBuilder envName = new StringBuilder(); StringBuilder paramName = new StringBuilder(); for (int i = 1; i <= ENV_JOB_ARG_MAX; i++) { if (i < fixArgs.length && fixArgs[i] != null && fixArgs[i].length() > 0) { continue; } envName.setLength(0); envName.append(ENV_JOB_ARG_NM); envName.append(i); String envParam = getenv(envName.toString()); if (envParam.length() == 0) { continue; } paramName.setLength(0); paramName.append(JOB_ARG_PARAM_BASE); paramName.append(i); try { BeanUtils.setProperty(jobRecord, paramName.toString(), envParam); } catch (IllegalAccessException | InvocationTargetException e) { throw new BatchException(e); } } jobRecord.setJobSequenceId(getenv(ENV_JOB_SEQ_ID)); jobRecord.setErrAppStatus(getenv(ENV_BLOGIC_APP_STATUS)); jobRecord.setCurAppStatus(getenv(ENV_CUR_APP_STATUS)); return jobRecord; } SyncJobOperatorImpl(
            ApplicationContextResolver applicationContextResolver,
            BLogicParamConverter blogicParamConverter,
            BLogicExceptionHandlerResolver blogicExceptionHandlerResolver,
            BLogicResolver blogicResolver, BLogicExecutor blogicExecutor); @Override int start(String[] args);  }
@Test public void testConvertBatchJobData01() throws Exception { BatchJobData batchJobData = target.convertBatchJobData(new String[0]); assertThat(batchJobData.getJobAppCd(), is("")); assertThat(batchJobData.getJobArgNm1(), is(nullValue())); assertThat(batchJobData.getJobArgNm2(), is(nullValue())); assertThat(batchJobData.getJobArgNm3(), is(nullValue())); assertThat(batchJobData.getJobArgNm4(), is(nullValue())); assertThat(batchJobData.getJobArgNm5(), is(nullValue())); assertThat(batchJobData.getJobArgNm6(), is(nullValue())); assertThat(batchJobData.getJobArgNm7(), is(nullValue())); assertThat(batchJobData.getJobArgNm8(), is(nullValue())); assertThat(batchJobData.getJobArgNm9(), is(nullValue())); assertThat(batchJobData.getJobArgNm10(), is(nullValue())); assertThat(batchJobData.getJobArgNm11(), is(nullValue())); assertThat(batchJobData.getJobArgNm12(), is(nullValue())); assertThat(batchJobData.getJobArgNm13(), is(nullValue())); assertThat(batchJobData.getJobArgNm14(), is(nullValue())); assertThat(batchJobData.getJobArgNm15(), is(nullValue())); assertThat(batchJobData.getJobArgNm16(), is(nullValue())); assertThat(batchJobData.getJobArgNm17(), is(nullValue())); assertThat(batchJobData.getJobArgNm18(), is(nullValue())); assertThat(batchJobData.getJobArgNm19(), is(nullValue())); assertThat(batchJobData.getJobArgNm20(), is(nullValue())); assertThat(batchJobData.getAddDateTime(), is(nullValue())); assertThat(batchJobData.getBLogicAppStatus(), is("")); assertThat(batchJobData.getCurAppStatus(), is("")); assertThat(batchJobData.getJobSequenceId(), is("")); assertThat(batchJobData.getUpdDateTime(), is(nullValue())); }
@Test public void testConvertBatchJobData02() throws Exception { BatchJobData batchJobData = target.convertBatchJobData( new String[] { "jobAppCd" }); assertThat(batchJobData.getJobAppCd(), is("jobAppCd")); assertThat(batchJobData.getJobArgNm1(), is(nullValue())); assertThat(batchJobData.getJobArgNm2(), is(nullValue())); assertThat(batchJobData.getJobArgNm3(), is(nullValue())); assertThat(batchJobData.getJobArgNm4(), is(nullValue())); assertThat(batchJobData.getJobArgNm5(), is(nullValue())); assertThat(batchJobData.getJobArgNm6(), is(nullValue())); assertThat(batchJobData.getJobArgNm7(), is(nullValue())); assertThat(batchJobData.getJobArgNm8(), is(nullValue())); assertThat(batchJobData.getJobArgNm9(), is(nullValue())); assertThat(batchJobData.getJobArgNm10(), is(nullValue())); assertThat(batchJobData.getJobArgNm11(), is(nullValue())); assertThat(batchJobData.getJobArgNm12(), is(nullValue())); assertThat(batchJobData.getJobArgNm13(), is(nullValue())); assertThat(batchJobData.getJobArgNm14(), is(nullValue())); assertThat(batchJobData.getJobArgNm15(), is(nullValue())); assertThat(batchJobData.getJobArgNm16(), is(nullValue())); assertThat(batchJobData.getJobArgNm17(), is(nullValue())); assertThat(batchJobData.getJobArgNm18(), is(nullValue())); assertThat(batchJobData.getJobArgNm19(), is(nullValue())); assertThat(batchJobData.getJobArgNm20(), is(nullValue())); assertThat(batchJobData.getAddDateTime(), is(nullValue())); assertThat(batchJobData.getBLogicAppStatus(), is("")); assertThat(batchJobData.getCurAppStatus(), is("")); assertThat(batchJobData.getJobSequenceId(), is("")); assertThat(batchJobData.getUpdDateTime(), is(nullValue())); }
@Test public void testConvertBatchJobData03() throws Exception { BatchJobData batchJobData = target.convertBatchJobData( new String[] { "jobAppCd", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19" }); assertThat(batchJobData.getJobAppCd(), is("jobAppCd")); assertThat(batchJobData.getJobArgNm1(), is("1")); assertThat(batchJobData.getJobArgNm2(), is("2")); assertThat(batchJobData.getJobArgNm3(), is("3")); assertThat(batchJobData.getJobArgNm4(), is("4")); assertThat(batchJobData.getJobArgNm5(), is("5")); assertThat(batchJobData.getJobArgNm6(), is("6")); assertThat(batchJobData.getJobArgNm7(), is("7")); assertThat(batchJobData.getJobArgNm8(), is("8")); assertThat(batchJobData.getJobArgNm9(), is("9")); assertThat(batchJobData.getJobArgNm10(), is("10")); assertThat(batchJobData.getJobArgNm11(), is("11")); assertThat(batchJobData.getJobArgNm12(), is("12")); assertThat(batchJobData.getJobArgNm13(), is("13")); assertThat(batchJobData.getJobArgNm14(), is("14")); assertThat(batchJobData.getJobArgNm15(), is("15")); assertThat(batchJobData.getJobArgNm16(), is("16")); assertThat(batchJobData.getJobArgNm17(), is("17")); assertThat(batchJobData.getJobArgNm18(), is("18")); assertThat(batchJobData.getJobArgNm19(), is("19")); assertThat(batchJobData.getJobArgNm20(), is(nullValue())); assertThat(batchJobData.getAddDateTime(), is(nullValue())); assertThat(batchJobData.getBLogicAppStatus(), is("")); assertThat(batchJobData.getCurAppStatus(), is("")); assertThat(batchJobData.getJobSequenceId(), is("")); assertThat(batchJobData.getUpdDateTime(), is(nullValue())); }
@Test public void testConvertBatchJobData04() throws Exception { BatchJobData batchJobData = target.convertBatchJobData( new String[] { "jobAppCd", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20" }); assertThat(batchJobData.getJobAppCd(), is("jobAppCd")); assertThat(batchJobData.getJobArgNm1(), is("1")); assertThat(batchJobData.getJobArgNm2(), is("2")); assertThat(batchJobData.getJobArgNm3(), is("3")); assertThat(batchJobData.getJobArgNm4(), is("4")); assertThat(batchJobData.getJobArgNm5(), is("5")); assertThat(batchJobData.getJobArgNm6(), is("6")); assertThat(batchJobData.getJobArgNm7(), is("7")); assertThat(batchJobData.getJobArgNm8(), is("8")); assertThat(batchJobData.getJobArgNm9(), is("9")); assertThat(batchJobData.getJobArgNm10(), is("10")); assertThat(batchJobData.getJobArgNm11(), is("11")); assertThat(batchJobData.getJobArgNm12(), is("12")); assertThat(batchJobData.getJobArgNm13(), is("13")); assertThat(batchJobData.getJobArgNm14(), is("14")); assertThat(batchJobData.getJobArgNm15(), is("15")); assertThat(batchJobData.getJobArgNm16(), is("16")); assertThat(batchJobData.getJobArgNm17(), is("17")); assertThat(batchJobData.getJobArgNm18(), is("18")); assertThat(batchJobData.getJobArgNm19(), is("19")); assertThat(batchJobData.getJobArgNm20(), is("20")); assertThat(batchJobData.getAddDateTime(), is(nullValue())); assertThat(batchJobData.getBLogicAppStatus(), is("")); assertThat(batchJobData.getCurAppStatus(), is("")); assertThat(batchJobData.getJobSequenceId(), is("")); assertThat(batchJobData.getUpdDateTime(), is(nullValue())); }
@Test public void testConvertBatchJobData05() throws Exception { BatchJobData batchJobData = target.convertBatchJobData( new String[] { "jobAppCd", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21" }); assertThat(batchJobData.getJobAppCd(), is("jobAppCd")); assertThat(batchJobData.getJobArgNm1(), is("1")); assertThat(batchJobData.getJobArgNm2(), is("2")); assertThat(batchJobData.getJobArgNm3(), is("3")); assertThat(batchJobData.getJobArgNm4(), is("4")); assertThat(batchJobData.getJobArgNm5(), is("5")); assertThat(batchJobData.getJobArgNm6(), is("6")); assertThat(batchJobData.getJobArgNm7(), is("7")); assertThat(batchJobData.getJobArgNm8(), is("8")); assertThat(batchJobData.getJobArgNm9(), is("9")); assertThat(batchJobData.getJobArgNm10(), is("10")); assertThat(batchJobData.getJobArgNm11(), is("11")); assertThat(batchJobData.getJobArgNm12(), is("12")); assertThat(batchJobData.getJobArgNm13(), is("13")); assertThat(batchJobData.getJobArgNm14(), is("14")); assertThat(batchJobData.getJobArgNm15(), is("15")); assertThat(batchJobData.getJobArgNm16(), is("16")); assertThat(batchJobData.getJobArgNm17(), is("17")); assertThat(batchJobData.getJobArgNm18(), is("18")); assertThat(batchJobData.getJobArgNm19(), is("19")); assertThat(batchJobData.getJobArgNm20(), is("20")); assertThat(batchJobData.getAddDateTime(), is(nullValue())); assertThat(batchJobData.getBLogicAppStatus(), is("")); assertThat(batchJobData.getCurAppStatus(), is("")); assertThat(batchJobData.getJobSequenceId(), is("")); assertThat(batchJobData.getUpdDateTime(), is(nullValue())); }
@Test public void testConvertBatchJobData06() throws Exception { try { SystemEnvUtils.setEnv("JOB_APP_CD", "envJobAppCd"); SystemEnvUtils.setEnv("BLOGIC_APP_STATUS", "blogicAppStatus"); SystemEnvUtils.setEnv("CUR_APP_STATUS", "curAppStatus"); SystemEnvUtils.setEnv("JOB_SEQ_ID", "jobSequenceId"); BatchJobData batchJobData = target.convertBatchJobData( new String[] { "jobAppCd" }); assertThat(batchJobData.getJobAppCd(), is("jobAppCd")); assertThat(batchJobData.getBLogicAppStatus(), is("blogicAppStatus")); assertThat(batchJobData.getCurAppStatus(), is("curAppStatus")); assertThat(batchJobData.getJobSequenceId(), is("jobSequenceId")); } finally { SystemEnvUtils.restoreEnv(); } }
@Test public void testConvertBatchJobData07() throws Exception { BatchJobData batchJobData; try { SystemEnvUtils.setEnv("JOB_APP_CD", "envJobAppCd"); SystemEnvUtils.setEnv("JOB_ARG_NM1", "env1"); SystemEnvUtils.setEnv("JOB_ARG_NM2", "env2"); SystemEnvUtils.setEnv("JOB_ARG_NM3", "env3"); SystemEnvUtils.setEnv("JOB_ARG_NM4", "env4"); SystemEnvUtils.setEnv("JOB_ARG_NM5", "env5"); SystemEnvUtils.setEnv("JOB_ARG_NM6", "env6"); SystemEnvUtils.setEnv("JOB_ARG_NM7", "env7"); SystemEnvUtils.setEnv("JOB_ARG_NM8", "env8"); SystemEnvUtils.setEnv("JOB_ARG_NM9", "env9"); SystemEnvUtils.setEnv("JOB_ARG_NM10", "env10"); SystemEnvUtils.setEnv("JOB_ARG_NM11", "env11"); SystemEnvUtils.setEnv("JOB_ARG_NM12", "env12"); SystemEnvUtils.setEnv("JOB_ARG_NM13", "env13"); SystemEnvUtils.setEnv("JOB_ARG_NM14", "env14"); SystemEnvUtils.setEnv("JOB_ARG_NM15", "env15"); SystemEnvUtils.setEnv("JOB_ARG_NM16", "env16"); SystemEnvUtils.setEnv("JOB_ARG_NM17", "env17"); SystemEnvUtils.setEnv("JOB_ARG_NM18", "env18"); SystemEnvUtils.setEnv("JOB_ARG_NM19", "env19"); SystemEnvUtils.setEnv("JOB_ARG_NM20", "env20"); batchJobData = target.convertBatchJobData(new String[] {}); } finally { SystemEnvUtils.restoreEnv(); } assertThat(batchJobData.getJobAppCd(), is("envJobAppCd")); assertThat(batchJobData.getJobArgNm1(), is("env1")); assertThat(batchJobData.getJobArgNm2(), is("env2")); assertThat(batchJobData.getJobArgNm3(), is("env3")); assertThat(batchJobData.getJobArgNm4(), is("env4")); assertThat(batchJobData.getJobArgNm5(), is("env5")); assertThat(batchJobData.getJobArgNm6(), is("env6")); assertThat(batchJobData.getJobArgNm7(), is("env7")); assertThat(batchJobData.getJobArgNm8(), is("env8")); assertThat(batchJobData.getJobArgNm9(), is("env9")); assertThat(batchJobData.getJobArgNm10(), is("env10")); assertThat(batchJobData.getJobArgNm11(), is("env11")); assertThat(batchJobData.getJobArgNm12(), is("env12")); assertThat(batchJobData.getJobArgNm13(), is("env13")); assertThat(batchJobData.getJobArgNm14(), is("env14")); assertThat(batchJobData.getJobArgNm15(), is("env15")); assertThat(batchJobData.getJobArgNm16(), is("env16")); assertThat(batchJobData.getJobArgNm17(), is("env17")); assertThat(batchJobData.getJobArgNm18(), is("env18")); assertThat(batchJobData.getJobArgNm19(), is("env19")); assertThat(batchJobData.getJobArgNm20(), is("env20")); assertThat(batchJobData.getAddDateTime(), is(nullValue())); assertThat(batchJobData.getBLogicAppStatus(), is("")); assertThat(batchJobData.getCurAppStatus(), is("")); assertThat(batchJobData.getJobSequenceId(), is("")); assertThat(batchJobData.getUpdDateTime(), is(nullValue())); }
@Test public void testConvertBatchJobData08() throws Exception { BatchJobData batchJobData; try { SystemEnvUtils.setEnv("JOB_APP_CD", "envJobAppCd"); SystemEnvUtils.setEnv("JOB_ARG_NM1", "env1"); SystemEnvUtils.setEnv("JOB_ARG_NM2", "env2"); SystemEnvUtils.setEnv("JOB_ARG_NM3", "env3"); SystemEnvUtils.setEnv("JOB_ARG_NM4", "env4"); SystemEnvUtils.setEnv("JOB_ARG_NM5", "env5"); SystemEnvUtils.setEnv("JOB_ARG_NM6", "env6"); SystemEnvUtils.setEnv("JOB_ARG_NM7", "env7"); SystemEnvUtils.setEnv("JOB_ARG_NM8", "env8"); SystemEnvUtils.setEnv("JOB_ARG_NM9", "env9"); SystemEnvUtils.setEnv("JOB_ARG_NM10", "env10"); SystemEnvUtils.setEnv("JOB_ARG_NM11", "env11"); SystemEnvUtils.setEnv("JOB_ARG_NM12", "env12"); SystemEnvUtils.setEnv("JOB_ARG_NM13", "env13"); SystemEnvUtils.setEnv("JOB_ARG_NM14", "env14"); SystemEnvUtils.setEnv("JOB_ARG_NM15", "env15"); SystemEnvUtils.setEnv("JOB_ARG_NM16", "env16"); SystemEnvUtils.setEnv("JOB_ARG_NM17", "env17"); SystemEnvUtils.setEnv("JOB_ARG_NM18", "env18"); SystemEnvUtils.setEnv("JOB_ARG_NM19", "env19"); SystemEnvUtils.setEnv("JOB_ARG_NM20", "env20"); batchJobData = target.convertBatchJobData( new String[] { "jobAppCd", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }); } finally { SystemEnvUtils.restoreEnv(); } assertThat(batchJobData.getJobAppCd(), is("jobAppCd")); assertThat(batchJobData.getJobArgNm1(), is("1")); assertThat(batchJobData.getJobArgNm2(), is("2")); assertThat(batchJobData.getJobArgNm3(), is("3")); assertThat(batchJobData.getJobArgNm4(), is("4")); assertThat(batchJobData.getJobArgNm5(), is("5")); assertThat(batchJobData.getJobArgNm6(), is("6")); assertThat(batchJobData.getJobArgNm7(), is("7")); assertThat(batchJobData.getJobArgNm8(), is("8")); assertThat(batchJobData.getJobArgNm9(), is("9")); assertThat(batchJobData.getJobArgNm10(), is("10")); assertThat(batchJobData.getJobArgNm11(), is("env11")); assertThat(batchJobData.getJobArgNm12(), is("env12")); assertThat(batchJobData.getJobArgNm13(), is("env13")); assertThat(batchJobData.getJobArgNm14(), is("env14")); assertThat(batchJobData.getJobArgNm15(), is("env15")); assertThat(batchJobData.getJobArgNm16(), is("env16")); assertThat(batchJobData.getJobArgNm17(), is("env17")); assertThat(batchJobData.getJobArgNm18(), is("env18")); assertThat(batchJobData.getJobArgNm19(), is("env19")); assertThat(batchJobData.getJobArgNm20(), is("env20")); assertThat(batchJobData.getAddDateTime(), is(nullValue())); assertThat(batchJobData.getBLogicAppStatus(), is("")); assertThat(batchJobData.getCurAppStatus(), is("")); assertThat(batchJobData.getJobSequenceId(), is("")); assertThat(batchJobData.getUpdDateTime(), is(nullValue())); }
@Test public void testConvertBatchJobData09() throws Exception { BatchJobData batchJobData; try { SystemEnvUtils.setEnv("JOB_APP_CD", "envJobAppCd"); SystemEnvUtils.setEnv("JOB_ARG_NM12", "env12"); SystemEnvUtils.setEnv("JOB_ARG_NM13", "env13"); SystemEnvUtils.setEnv("JOB_ARG_NM14", "env14"); SystemEnvUtils.setEnv("JOB_ARG_NM15", "env15"); SystemEnvUtils.setEnv("JOB_ARG_NM16", "env16"); SystemEnvUtils.setEnv("JOB_ARG_NM17", "env17"); SystemEnvUtils.setEnv("JOB_ARG_NM18", "env18"); SystemEnvUtils.setEnv("JOB_ARG_NM19", "env19"); batchJobData = target.convertBatchJobData( new String[] { "jobAppCd", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }); } finally { SystemEnvUtils.restoreEnv(); } assertThat(batchJobData.getJobAppCd(), is("jobAppCd")); assertThat(batchJobData.getJobArgNm1(), is("1")); assertThat(batchJobData.getJobArgNm2(), is("2")); assertThat(batchJobData.getJobArgNm3(), is("3")); assertThat(batchJobData.getJobArgNm4(), is("4")); assertThat(batchJobData.getJobArgNm5(), is("5")); assertThat(batchJobData.getJobArgNm6(), is("6")); assertThat(batchJobData.getJobArgNm7(), is("7")); assertThat(batchJobData.getJobArgNm8(), is("8")); assertThat(batchJobData.getJobArgNm9(), is("9")); assertThat(batchJobData.getJobArgNm10(), is("10")); assertThat(batchJobData.getJobArgNm11(), is(nullValue())); assertThat(batchJobData.getJobArgNm12(), is("env12")); assertThat(batchJobData.getJobArgNm13(), is("env13")); assertThat(batchJobData.getJobArgNm14(), is("env14")); assertThat(batchJobData.getJobArgNm15(), is("env15")); assertThat(batchJobData.getJobArgNm16(), is("env16")); assertThat(batchJobData.getJobArgNm17(), is("env17")); assertThat(batchJobData.getJobArgNm18(), is("env18")); assertThat(batchJobData.getJobArgNm19(), is("env19")); assertThat(batchJobData.getJobArgNm20(), is(nullValue())); assertThat(batchJobData.getAddDateTime(), is(nullValue())); assertThat(batchJobData.getBLogicAppStatus(), is("")); assertThat(batchJobData.getCurAppStatus(), is("")); assertThat(batchJobData.getJobSequenceId(), is("")); assertThat(batchJobData.getUpdDateTime(), is(nullValue())); }