### Question:
MethodInvokingTaskletAdapter extends AbstractMethodInvokingDelegator<Object> implements Tasklet { @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { if (getArguments() == null) { setArguments(new Object[]{contribution, chunkContext}); } contribution.setExitStatus(mapResult(invokeDelegateMethod())); return RepeatStatus.FINISHED; }  @Override RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext);  }### Answer:
@Test public void testExactlySameSignature() throws Exception { adapter.setTargetMethod("execute"); RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext); assertEquals(RepeatStatus.FINISHED, repeatStatus); assertEquals(tasklet.getStepContribution(), stepContribution); assertEquals(tasklet.getChunkContext(), chunkContext); }
@Test(expected = IllegalArgumentException.class) public void testIncorrectSignatureWithExtraParameter() throws Exception { adapter.setTargetMethod("execute10"); adapter.execute(stepContribution, chunkContext); }
@Test public void testExitStatusReturnType() throws Exception { adapter.setTargetMethod("execute11"); adapter.execute(stepContribution, chunkContext); assertEquals(new ExitStatus("DONE"), stepContribution.getExitStatus()); }
@Test public void testNonExitStatusReturnType() throws Exception { adapter.setTargetMethod("execute12"); RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext); assertEquals(RepeatStatus.FINISHED, repeatStatus); assertEquals(ExitStatus.COMPLETED, stepContribution.getExitStatus()); }
@Test public void testSameSignatureWithDifferentMethodName() throws Exception { adapter.setTargetMethod("execute1"); RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext); assertEquals(RepeatStatus.FINISHED, repeatStatus); assertEquals(tasklet.getStepContribution(), stepContribution); assertEquals(tasklet.getChunkContext(), chunkContext); }
@Test public void testDifferentParametersOrder() throws Exception { adapter.setTargetMethod("execute2"); RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext); assertEquals(RepeatStatus.FINISHED, repeatStatus); assertEquals(tasklet.getStepContribution(), stepContribution); assertEquals(tasklet.getChunkContext(), chunkContext); }
@Test public void testArgumentSubsetWithOnlyChunkContext() throws Exception { adapter.setTargetMethod("execute3"); RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext); assertEquals(RepeatStatus.FINISHED, repeatStatus); assertEquals(tasklet.getChunkContext(), chunkContext); }
@Test public void testArgumentSubsetWithOnlyStepContribution() throws Exception { adapter.setTargetMethod("execute4"); RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext); assertEquals(RepeatStatus.FINISHED, repeatStatus); assertEquals(tasklet.getStepContribution(), stepContribution); }
@Test public void testArgumentSubsetWithoutArguments() throws Exception { adapter.setTargetMethod("execute5"); RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext); assertEquals(RepeatStatus.FINISHED, repeatStatus); }
@Test public void testCompatibleReturnTypeWhenBoolean() throws Exception { adapter.setTargetMethod("execute6"); RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext); assertEquals(RepeatStatus.FINISHED, repeatStatus); }
@Test public void testCompatibleReturnTypeWhenVoid() throws Exception { adapter.setTargetMethod("execute7"); RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext); assertEquals(RepeatStatus.FINISHED, repeatStatus); }
@Test public void testArgumentSubsetWithOnlyStepContributionAndCompatibleReturnTypeBoolean() throws Exception { adapter.setTargetMethod("execute8"); RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext); assertEquals(RepeatStatus.FINISHED, repeatStatus); assertEquals(tasklet.getStepContribution(), stepContribution); }
@Test public void testArgumentSubsetWithOnlyChunkContextAndCompatibleReturnTypeVoid() throws Exception { adapter.setTargetMethod("execute9"); RepeatStatus repeatStatus = adapter.execute(stepContribution, chunkContext); assertEquals(RepeatStatus.FINISHED, repeatStatus); assertEquals(tasklet.getChunkContext(), chunkContext); }