### Question:
InformOwnerThatProjectHasBeenDeletedNotificationService { @UseCaseAdministratorDeleteProject(@Step(number = 4, name = "Inform project owner that the project has been deleted")) public void notify(ProjectMessage projectMessage, String baseUrl) { requireNonNull(projectMessage); String projectOwnerEmailAddress = projectMessage.getProjectOwnerEmailAddress(); if (projectOwnerEmailAddress == null) { LOG.warn("No project owner email message set - can not inform owner about delete of project {}",projectMessage.getProjectId()); return; } SimpleMailMessage message = factory.createMessage("A SecHub project you were the owner was deleted: " + projectMessage.getProjectId()); StringBuilder emailContent = new StringBuilder(); emailContent.append("Your project '"); emailContent.append(projectMessage.getProjectId()); emailContent.append("' in environment "); emailContent.append(baseUrl); emailContent.append("\n"); emailContent.append("has been deleted.\n\n"); emailContent.append("This means that all report data has been deleted, and thus sechub scans for this project are no longer accessible.\n"); message.setTo(projectOwnerEmailAddress); message.setText(emailContent.toString()); emailService.send(message); }  @UseCaseAdministratorDeleteProject(@Step(number = 4, name = "Inform project owner that the project has been deleted")) void notify(ProjectMessage projectMessage, String baseUrl);  }### Answer:
@Test public void sends_email_to_former_project_owner_containing_projectid() throws Exception { SimpleMailMessage mockedMailMessage = mock(SimpleMailMessage.class); when(mockedMailMessageFactory.createMessage(any())).thenReturn(mockedMailMessage); ProjectMessage message = mock(ProjectMessage.class); when(message.getProjectId()).thenReturn("projectId1"); when(message.getProjectOwnerEmailAddress()).thenReturn("owner1@example.org"); serviceToTest.notify(message,"base1"); ArgumentCaptor<SimpleMailMessage> mailMessageCaptor = ArgumentCaptor.forClass(SimpleMailMessage.class); verify(mockedEmailService).send(mailMessageCaptor.capture()); assertSame(mockedMailMessage, mailMessageCaptor.getValue()); verify(mockedMailMessage).setTo("owner1@example.org"); ArgumentCaptor<String> stringMessageCaptor = ArgumentCaptor.forClass(String.class); verify(mockedMailMessage).setText(stringMessageCaptor.capture()); String textInMessageBody = stringMessageCaptor.getValue(); assertTrue(textInMessageBody.contains("projectId1")); assertTrue(textInMessageBody.contains("deleted")); }