use of io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity in project gravitee-management-rest-api by gravitee-io.
the class PortalNotificationConfigService_FindByIdTest method shouldFindExistingConfig.
@Test
public void shouldFindExistingConfig() throws TechnicalException {
PortalNotificationConfig cfg = mock(PortalNotificationConfig.class);
when(cfg.getReferenceType()).thenReturn(NotificationReferenceType.API);
when(cfg.getReferenceId()).thenReturn("123");
when(cfg.getUser()).thenReturn("user");
when(cfg.getHooks()).thenReturn(Arrays.asList("A", "B", "C"));
when(portalNotificationConfigRepository.findById("user", NotificationReferenceType.API, "123")).thenReturn(of(cfg));
final PortalNotificationConfigEntity entity = portalNotificationConfigService.findById("user", NotificationReferenceType.API, "123");
assertNotNull(entity);
assertEquals("referenceId", cfg.getReferenceId(), entity.getReferenceId());
assertEquals("referenceType", cfg.getReferenceType().name(), entity.getReferenceType());
assertEquals("user", cfg.getUser(), entity.getUser());
assertEquals("hooks", cfg.getHooks(), entity.getHooks());
verify(portalNotificationConfigRepository, times(1)).findById("user", NotificationReferenceType.API, "123");
}
use of io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity in project gravitee-management-rest-api by gravitee-io.
the class PortalNotificationConfigService_FindByIdTest method shouldNotFindConfig.
@Test
public void shouldNotFindConfig() throws TechnicalException {
when(portalNotificationConfigRepository.findById("user", NotificationReferenceType.API, "123")).thenReturn(empty());
final PortalNotificationConfigEntity entity = portalNotificationConfigService.findById("user", NotificationReferenceType.API, "123");
assertNotNull(entity);
assertEquals("referenceId", "123", entity.getReferenceId());
assertEquals("referenceType", NotificationReferenceType.API.name(), entity.getReferenceType());
assertEquals("user", "user", entity.getUser());
assertEquals("hooks", Collections.emptyList(), entity.getHooks());
verify(portalNotificationConfigRepository, times(1)).findById("user", NotificationReferenceType.API, "123");
}
Aggregations