use of io.gravitee.repository.management.model.NotificationTemplate in project gravitee-management-rest-api by gravitee-io.
the class NotificationTemplateServiceImpl method findById.
@Override
public NotificationTemplateEntity findById(String id) {
try {
LOGGER.debug("Find notificationTemplate by ID: {}", id);
Optional<NotificationTemplate> notificationTemplate = notificationTemplateRepository.findById(id);
if (notificationTemplate.isPresent()) {
return convert(notificationTemplate.get());
}
throw new NotificationTemplateNotFoundException(id);
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to delete a notificationTemplate using its ID {}", id, ex);
throw new TechnicalManagementException("An error occurs while trying to delete a notificationTemplate using its ID " + id, ex);
}
}
use of io.gravitee.repository.management.model.NotificationTemplate in project gravitee-management-rest-api by gravitee-io.
the class NotificationTemplateServiceTest method shouldUpdateNotificationTemplate.
@Test
public void shouldUpdateNotificationTemplate() throws TechnicalException {
NotificationTemplateEntity updatingNotificationTemplateEntity = new NotificationTemplateEntity();
updatingNotificationTemplateEntity.setId(NOTIFICATION_TEMPLATE_ID);
updatingNotificationTemplateEntity.setName("New Name");
updatingNotificationTemplateEntity.setType(io.gravitee.rest.api.model.notification.NotificationTemplateType.valueOf(NOTIFICATION_TEMPLATE_TYPE.name()));
updatingNotificationTemplateEntity.setEnabled(NOTIFICATION_TEMPLATE_ENABLED);
final NotificationTemplate toUpdate = mock(NotificationTemplate.class);
when(notificationTemplateRepository.findById(NOTIFICATION_TEMPLATE_ID)).thenReturn(Optional.of(toUpdate));
when(notificationTemplateRepository.update(any())).thenReturn(notificationTemplate);
notificationTemplateService.update(updatingNotificationTemplateEntity);
verify(notificationTemplateRepository, times(1)).update(any());
verify(auditService, times(1)).createOrganizationAuditLog(any(), eq(NotificationTemplate.AuditEvent.NOTIFICATION_TEMPLATE_UPDATED), any(), eq(toUpdate), eq(notificationTemplate));
}
use of io.gravitee.repository.management.model.NotificationTemplate in project gravitee-management-rest-api by gravitee-io.
the class NotificationTemplateServiceTest method init.
@Before
public void init() {
notificationTemplate = new NotificationTemplate();
notificationTemplate.setId(NOTIFICATION_TEMPLATE_ID);
notificationTemplate.setHook(NOTIFICATION_TEMPLATE_HOOK);
notificationTemplate.setScope(NOTIFICATION_TEMPLATE_SCOPE);
notificationTemplate.setReferenceId(NOTIFICATION_TEMPLATE_REFERENCE_ID);
notificationTemplate.setReferenceType(NOTIFICATION_TEMPLATE_REFERENCE_TYPE);
notificationTemplate.setName(NOTIFICATION_TEMPLATE_NAME);
notificationTemplate.setDescription(NOTIFICATION_TEMPLATE_DESCRIPTION);
notificationTemplate.setTitle(NOTIFICATION_TEMPLATE_TITLE);
notificationTemplate.setContent(NOTIFICATION_TEMPLATE_CONTENT);
notificationTemplate.setType(NOTIFICATION_TEMPLATE_TYPE);
notificationTemplate.setCreatedAt(NOTIFICATION_TEMPLATE_CREATED_AT);
notificationTemplate.setUpdatedAt(NOTIFICATION_TEMPLATE_UPDATED_AT);
notificationTemplate.setEnabled(NOTIFICATION_TEMPLATE_ENABLED);
}
Aggregations