### Question:
ProcessSplitter { public List<AbbyyProcess> split(AbbyyProcess process, int splitSize) { if (process.getNumberOfImages() == 0) { throw new IllegalArgumentException("Cannot split the process, it has no images: " + process.getName()); } if (process.getNumberOfImages() <= splitSize) { List<AbbyyProcess> sp = new ArrayList<AbbyyProcess>(); sp.add(process); return sp; } else { mergingObserver.setParentProcess(process); List<AbbyyProcess> subProcesses = createSubProcesses(process, splitSize); for(AbbyyProcess subProcess : subProcesses){ subProcess.setMerger(mergingObserver); mergingObserver.addSubProcess(subProcess); } return subProcesses; } }  List<AbbyyProcess> split(AbbyyProcess process, int splitSize);  }### Answer:
@Test public void shouldNotSplitBecauseOfFewImages() { when(processMock.getNumberOfImages()).thenReturn(2); List<AbbyyProcess> splitResults = splitterSut.split(processMock, 2); assertEquals("Should not split a small process", processMock, splitResults.get(0)); }
@Test(expected=IllegalArgumentException.class) public void shouldRejectProcessWithoutImages() { when(processMock.getNumberOfImages()).thenReturn(0); splitterSut.split(processMock, 1); }
@Test public void shouldSplitOneProcessIntoTwo() throws URISyntaxException { when(processMock.getNumberOfImages()).thenReturn(2); when(processMock.getImages()).thenReturn(testImages()); when(processMock.getName()).thenReturn("testMock"); AbbyyProcess subProcessMock1 = mock(AbbyyProcess.class); AbbyyProcess subProcessMock2 = mock(AbbyyProcess.class); when(processMock.createSubProcess()).thenReturn(subProcessMock1, subProcessMock2); List<AbbyyProcess> splitResults = splitterSut.split(processMock, 1); assertEquals("Number of split subprocesses", 2, splitResults.size()); assertSame("First subprocess", subProcessMock1, splitResults.get(0)); assertSame("Second subprocess", subProcessMock2, splitResults.get(1)); verify(subProcessMock1).setName("testMock_1of2"); verify(subProcessMock2).setName("testMock_2of2"); }