use of com.redhat.cloud.notifications.templates.Blank in project notifications-backend by RedHatInsights.
the class LifecycleITest method setupEmailMock.
private void setupEmailMock(String accountId, String orgId, String username) {
Mockito.when(emailTemplateFactory.get(anyString(), anyString())).thenReturn(new Blank());
User user = new User();
user.setUsername(username);
user.setAdmin(true);
user.setActive(true);
user.setEmail("user email");
user.setFirstName("user firstname");
user.setLastName("user lastname");
Mockito.when(rbacRecipientUsersProvider.getUsers(eq(accountId), eq(orgId), eq(true))).thenReturn(List.of(user));
updateField(emailSender, "bopUrl", getMockServerUrl() + EMAIL_SENDER_MOCK_PATH, EmailSender.class);
}
use of com.redhat.cloud.notifications.templates.Blank in project notifications-backend by RedHatInsights.
the class EmailSubscriptionTypeProcessorTest method shouldSuccessfullySendEmail.
@Test
void shouldSuccessfullySendEmail() {
micrometerAssertionHelper.saveCounterValuesBeforeTest(AGGREGATION_COMMAND_REJECTED_COUNTER_NAME, AGGREGATION_COMMAND_PROCESSED_COUNTER_NAME, AGGREGATION_COMMAND_ERROR_COUNTER_NAME);
AggregationCommand aggregationCommand1 = new AggregationCommand(new EmailAggregationKey("account-1", "org-1", "bundle-1", "app-1"), LocalDateTime.now(), LocalDateTime.now().plusDays(1), DAILY);
AggregationCommand aggregationCommand2 = new AggregationCommand(new EmailAggregationKey("account-2", "org-2", "bundle-2", "app-2"), LocalDateTime.now(ZoneOffset.UTC).plusDays(1), LocalDateTime.now(ZoneOffset.UTC).plusDays(2), DAILY);
when(emailTemplateFactory.get(anyString(), anyString())).thenReturn(new Blank());
inMemoryConnector.source(AGGREGATION_CHANNEL).send(Json.encode(aggregationCommand1));
inMemoryConnector.source(AGGREGATION_CHANNEL).send(Json.encode(aggregationCommand2));
micrometerAssertionHelper.awaitAndAssertCounterIncrement(AGGREGATION_COMMAND_PROCESSED_COUNTER_NAME, 2);
micrometerAssertionHelper.assertCounterIncrement(AGGREGATION_COMMAND_REJECTED_COUNTER_NAME, 0);
micrometerAssertionHelper.assertCounterIncrement(AGGREGATION_COMMAND_ERROR_COUNTER_NAME, 0);
// Let's check that EndpointEmailSubscriptionResources#sendEmail was called for each aggregation.
verify(emailAggregationRepository, times(1)).getEmailAggregation(eq(aggregationCommand1.getAggregationKey()), eq(aggregationCommand1.getStart()), eq(aggregationCommand1.getEnd()));
verify(emailAggregationRepository, times(1)).purgeOldAggregation(eq(aggregationCommand1.getAggregationKey()), eq(aggregationCommand1.getEnd()));
verify(emailAggregationRepository, times(1)).getEmailAggregation(eq(aggregationCommand2.getAggregationKey()), eq(aggregationCommand2.getStart()), eq(aggregationCommand2.getEnd()));
verify(emailAggregationRepository, times(1)).purgeOldAggregation(eq(aggregationCommand2.getAggregationKey()), eq(aggregationCommand2.getEnd()));
verifyNoMoreInteractions(emailAggregationRepository);
micrometerAssertionHelper.clearSavedValues();
}
Aggregations