Source:
<code>public void shouldSendRefundIssuedEmailIfEmailNotifyIsEnabled() throws Exception { when(mockConfig.getNotifyConfiguration().isEmailNotifyEnabled()).thenReturn(true); when(mockNotifyClientFactoryProvider.clientFactory()).thenReturn(mockNotifyClientFactory); when(mockNotifyClientFactory.getInstance()).thenReturn(mockNotifyClient); <START> when(mockNotifyClient.sendEmail(any(), any(), any(), any())).thenReturn(mockNotificationCreatedResponse); <END> when(mockNotificationCreatedResponse.getNotificationId()).thenReturn(randomUUID()); when(mockMetricRegistry.histogram(anyString())).thenReturn(mockHistogram); when(mockMetricRegistry.counter(anyString())).thenReturn(mockCounter); ChargeEntity charge = ChargeEntityFixture.aValidChargeEntity() .withCreatedDate(ZonedDateTime.of(2016, 1, 1, 10, 23, 12, 0, ZoneId.of("UTC"))) .build(); RefundEntity refundEntity = RefundEntityFixture.aValidRefundEntity() .withAmount(100L) .withCreatedDate(ZonedDateTime.of(2017, 1, 1, 10, 23, 12, 0, ZoneId.of("UTC"))) .withCharge(charge).build(); userNotificationService = new UserNotificationService(mockNotifyClientFactoryProvider, mockConfig, mockEnvironment); Future<Optional<String>> idF = userNotificationService.sendRefundIssuedEmail(refundEntity); idF.get(1000, TimeUnit.SECONDS); HashMap<String, String> map = new HashMap<>(); map.put("serviceReference", "This is a reference"); map.put("date", "1 January 2017 - 10:23:12"); map.put("description", "This is a description"); map.put("amount", "1.00"); verify(mockNotifyClient).sendEmail( mockNotifyConfiguration.getRefundIssuedEmailTemplateId(), charge.getEmail(), map, null ); }</code><technical_language>I this is copied existing test do a bunch of any()s</technical_language>

Target:
public void shouldSendRefundIssuedEmailIfEmailNotifyIsEnabled() throws Exception { UUID notificationId = randomUUID(); when(mockConfig.getNotifyConfiguration().isEmailNotifyEnabled()).thenReturn(true); when(mockNotifyClientFactoryProvider.clientFactory()).thenReturn(mockNotifyClientFactory); when(mockNotifyClientFactory.getInstance()).thenReturn(mockNotifyClient); when(mockNotificationCreatedResponse.getNotificationId()).thenReturn(notificationId); when(mockMetricRegistry.histogram(anyString())).thenReturn(mockHistogram); when(mockMetricRegistry.counter(anyString())).thenReturn(mockCounter); ChargeEntity charge = ChargeEntityFixture.aValidChargeEntity() .withCreatedDate(ZonedDateTime.of(2016, 1, 1, 10, 23, 12, 0, ZoneId.of("UTC"))) .build(); RefundEntity refundEntity = RefundEntityFixture.aValidRefundEntity() .withAmount(100L) .withCreatedDate(ZonedDateTime.of(2017, 1, 1, 10, 23, 12, 0, ZoneId.of("UTC"))) .withCharge(charge).build(); HashMap<String, String> personalisation = new HashMap<>(); personalisation.put("serviceReference", "This is a reference"); personalisation.put("date", "1 January 2017 - 10:23:12"); personalisation.put("description", "This is a description"); personalisation.put("amount", "1.00"); when(mockNotifyClient.sendEmail(mockNotifyConfiguration.getRefundIssuedEmailTemplateId(), charge.getEmail(), personalisation, null)).thenReturn(mockNotificationCreatedResponse); userNotificationService = new UserNotificationService(mockNotifyClientFactoryProvider, mockConfig, mockEnvironment); Optional<String> maybeNotificationId = userNotificationService.sendRefundIssuedEmail(refundEntity).get(1000, TimeUnit.SECONDS); assertThat(maybeNotificationId.get(), is(notificationId.toString())); }