### Question:
ShellTask extends AbstractTask { @Override public void init() { logger.info("shell task params {}", taskExecutionContext.getTaskParams()); shellParameters = JSONUtils.parseObject(taskExecutionContext.getTaskParams(), ShellParameters.class); if (!shellParameters.checkParameters()) { throw new RuntimeException("shell task params is not valid"); } } ShellTask(TaskExecutionContext taskExecutionContext, Logger logger); @Override void init(); @Override void handle(); @Override void cancelApplication(boolean cancelApplication); @Override AbstractParameters getParameters();  }### Answer:
@Test public void testInitForUnix() { try { PowerMockito.when(OSUtils.isWindows()).thenReturn(false); shellTask.init(); Assert.assertTrue(true); } catch (Error | Exception e) { logger.error(e.getMessage()); } }
@Test public void testInitException() { TaskProps props = new TaskProps(); props.setTaskAppId(String.valueOf(System.currentTimeMillis())); props.setTenantCode("1"); props.setEnvFile(".dolphinscheduler_env.sh"); props.setTaskStartTime(new Date()); props.setTaskTimeout(0); props.setTaskParams("{\"rawScript\": \"\"}"); ShellTask shellTask = new ShellTask(taskExecutionContext, logger); try { shellTask.init(); } catch (Exception e) { logger.info(e.getMessage(), e); if (e.getMessage().contains("shell task params is not valid")) { Assert.assertTrue(true); } } }
@Test public void testInitForWindows() { try { PowerMockito.when(OSUtils.isWindows()).thenReturn(true); shellTask.init(); Assert.assertTrue(true); } catch (Error | Exception e) { logger.error(e.getMessage()); } }