### Question:
ResponseFolderService { public AcmFolder getResponseFolder(Long requestId) throws AcmFolderException, AcmUserActionFailedException, AcmObjectNotFoundException { CaseFile request = caseFileDao.find(requestId); return getResponseFolder(request); }  AcmFolder getResponseFolder(Long requestId); AcmFolder getResponseFolder(CaseFile request); AcmFolderService getFolderService(); void setFolderService(AcmFolderService folderService); String getResponseFolderName(); void setResponseFolderName(String responseFolderName); CaseFileDao getCaseFileDao(); void setCaseFileDao(CaseFileDao caseFileDao);  }### Answer:
@Test public void testGetResponseFolder() throws Exception { AcmFolder rootFolder = new AcmFolder(); rootFolder.setId(102l); AcmFolder childFolder1 = new AcmFolder(); childFolder1.setName("Request"); childFolder1.setParentFolder(rootFolder); AcmFolder childFolder2 = new AcmFolder(); childFolder2.setName("Working"); childFolder2.setParentFolder(rootFolder); AcmFolder childFolder3 = new AcmFolder(); childFolder3.setName("Response"); childFolder3.setParentFolder(rootFolder); AcmContainer container = new AcmContainer(); container.setFolder(rootFolder); CaseFile caseFile = new CaseFile(); caseFile.setContainer(container); expect(mockedCaseFile.getContainer()).andReturn(mockedContainer); expect(mockedContainer.getFolder()).andReturn(mockedRootFolder); expect(mockedRootFolder.getId()).andReturn(102l); expect(mockedFolderService.getFolderChildren(102l)) .andReturn(Arrays.asList(mockedRequestFolder, mockedWorkingFolder, mockedResponseFolder)); expect(mockedRequestFolder.getObjectType()).andReturn(OBJECT_FOLDER_TYPE).times(2); expect(mockedRequestFolder.getName()).andReturn("Request"); expect(mockedWorkingFolder.getObjectType()).andReturn(OBJECT_FOLDER_TYPE).times(2); expect(mockedWorkingFolder.getName()).andReturn("Working"); expect(mockedResponseFolder.getObjectType()).andReturn(OBJECT_FOLDER_TYPE).times(2); expect(mockedResponseFolder.getName()).andReturn("Response"); replayAll(); AcmFolder responseFolder = responseFolderService.getResponseFolder(caseFile); assertNotNull(responseFolder); }
@Test public void testMissingResponseFolder() throws Exception { AcmFolder rootFolder = new AcmFolder(); rootFolder.setId(102l); AcmFolder childFolder1 = new AcmFolder(); childFolder1.setName("Request"); childFolder1.setParentFolder(rootFolder); AcmFolder childFolder2 = new AcmFolder(); childFolder2.setName("Working"); childFolder2.setParentFolder(rootFolder); AcmFolder childFolder3 = new AcmFolder(); childFolder3.setName("NoResponse"); childFolder3.setParentFolder(rootFolder); AcmContainer container = new AcmContainer(); container.setFolder(rootFolder); CaseFile caseFile = new CaseFile(); caseFile.setContainer(container); expect(mockedCaseFile.getContainer()).andReturn(mockedContainer); expect(mockedContainer.getFolder()).andReturn(mockedRootFolder); expect(mockedRootFolder.getId()).andReturn(102l); expect(mockedFolderService.getFolderChildren(102l)) .andReturn(Arrays.asList(mockedRequestFolder, mockedWorkingFolder, mockedResponseFolder)); expect(mockedRequestFolder.getObjectType()).andReturn(OBJECT_FOLDER_TYPE).times(2); expect(mockedRequestFolder.getName()).andReturn("Request").anyTimes(); expect(mockedWorkingFolder.getObjectType()).andReturn(OBJECT_FOLDER_TYPE).times(2); expect(mockedWorkingFolder.getName()).andReturn("Working"); expect(mockedResponseFolder.getObjectType()).andReturn(OBJECT_FOLDER_TYPE).times(2); expect(mockedResponseFolder.getName()).andReturn("NoResponse"); replayAll(); expectedException.expect(AcmFolderException.class); expectedException.expectMessage(is(String.format("No response folder in folder with id %d was found!", 102l))); responseFolderService.getResponseFolder(caseFile); }