AboutTextManager implements IAboutTextManager { @Transactional @Override public void saveAbout(String projectId, IAboutText abtText) throws QuadrigaStorageException { if (abtText.getId() == null) { abtText.setId(aboutTextDAO.generateUniqueID()); } abtText.setProjectId(projectId); AboutTextDTO aboutTextDTO = abtTxtMapper.aboutTextBeanToDTO(abtText); aboutTextDAO.saveOrUpdateDTO(aboutTextDTO); }  @Transactional @Override void saveAbout(String projectId, IAboutText abtText); @Transactional @Override IAboutText getAboutTextByProjectId(String projectId);  }
@Test public void test_saveAbout_newDTO() throws QuadrigaStorageException { Mockito.when(mockedAboutTextDAO.generateUniqueID()).thenReturn("UniqueId1"); aboutTextManager.saveAbout("PROJabscde", saveText); Mockito.verify(mockedAboutTextDAO).generateUniqueID(); argument = ArgumentCaptor.forClass(AboutTextDTO.class); Mockito.verify(mockedAboutTextDAO).saveOrUpdateDTO(argument.capture()); assertEquals("UniqueId1", argument.getValue().getId()); assertEquals("PROJabscde", argument.getValue().getProjectId()); assertEquals("SaveTitle", argument.getValue().getTitle()); assertEquals("Save Description", argument.getValue().getDescription()); }
@Test public void test_saveAbout_UpdateDTO() throws QuadrigaStorageException { AboutTextDTO dto = new AboutTextDTO(); dto.setId("UniqueId2"); dto.setProjectId("1st"); dto.setTitle("UpdateTitle"); dto.setDescription("Update Description"); Mockito.when(mockedAboutTextDAO.getDTOByProjectId("PROJxyzwqr")).thenReturn(dto); aboutTextManager.saveAbout("PROJxyzwqr", updateText); argument = ArgumentCaptor.forClass(AboutTextDTO.class); Mockito.verify(mockedAboutTextDAO, Mockito.times(1)).saveOrUpdateDTO(argument.capture()); assertEquals("testId1234", argument.getValue().getId()); assertEquals("PROJxyzwqr", argument.getValue().getProjectId()); assertEquals("UpdateTitle", argument.getValue().getTitle()); assertEquals("Update Description", argument.getValue().getDescription()); }