use of io.gravitee.management.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.management.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");
}
use of io.gravitee.management.model.notification.PortalNotificationConfigEntity in project gravitee-management-rest-api by gravitee-io.
the class PortalNotificationConfigService_SaveTest method shouldDelete.
@Test
public void shouldDelete() throws TechnicalException {
PortalNotificationConfigEntity cfgEntity = mock(PortalNotificationConfigEntity.class);
when(cfgEntity.getReferenceType()).thenReturn(NotificationReferenceType.API.name());
when(cfgEntity.getReferenceId()).thenReturn("123");
when(cfgEntity.getUser()).thenReturn("user");
when(cfgEntity.getHooks()).thenReturn(Collections.emptyList());
final PortalNotificationConfigEntity entity = portalNotificationConfigService.save(cfgEntity);
assertNotNull(entity);
assertEquals("referenceId", cfgEntity.getReferenceId(), entity.getReferenceId());
assertEquals("referenceType", cfgEntity.getReferenceType(), entity.getReferenceType());
assertEquals("userId", cfgEntity.getUser(), entity.getUser());
assertEquals("hooks", cfgEntity.getHooks(), entity.getHooks());
verify(portalNotificationConfigRepository, never()).findById(any(), any(), any());
verify(portalNotificationConfigRepository, times(1)).delete(any());
}
use of io.gravitee.management.model.notification.PortalNotificationConfigEntity in project gravitee-management-rest-api by gravitee-io.
the class ApplicationNotificationSettingsResource method convert.
private PortalNotificationConfigEntity convert(GenericNotificationConfigEntity generic) {
PortalNotificationConfigEntity portalNotificationConfigEntity = new PortalNotificationConfigEntity();
portalNotificationConfigEntity.setConfigType(generic.getConfigType());
portalNotificationConfigEntity.setReferenceType(generic.getReferenceType());
portalNotificationConfigEntity.setReferenceId(generic.getReferenceId());
portalNotificationConfigEntity.setUser(getAuthenticatedUser());
portalNotificationConfigEntity.setHooks(generic.getHooks());
return portalNotificationConfigEntity;
}
use of io.gravitee.management.model.notification.PortalNotificationConfigEntity in project gravitee-management-rest-api by gravitee-io.
the class PortalNotificationConfigServiceImpl method convert.
private PortalNotificationConfigEntity convert(PortalNotificationConfig portalNotificationConfig) {
PortalNotificationConfigEntity entity = new PortalNotificationConfigEntity();
entity.setConfigType(NotificationConfigType.PORTAL);
entity.setReferenceType(portalNotificationConfig.getReferenceType().name());
entity.setReferenceId(portalNotificationConfig.getReferenceId());
entity.setUser(portalNotificationConfig.getUser());
entity.setHooks(portalNotificationConfig.getHooks());
return entity;
}
Aggregations