use of io.gravitee.management.model.notification.PortalNotificationConfigEntity in project gravitee-management-rest-api by gravitee-io.
the class PortalNotificationSettingsResource 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 PortalNotificationConfigService_SaveTest method shouldUpdate.
@Test
public void shouldUpdate() 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"));
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(Arrays.asList("A", "B", "C"));
when(portalNotificationConfigRepository.findById("user", NotificationReferenceType.API, "123")).thenReturn(of(cfg));
when(portalNotificationConfigRepository.update(any(PortalNotificationConfig.class))).thenReturn(cfg);
final PortalNotificationConfigEntity entity = portalNotificationConfigService.save(cfgEntity);
assertNotNull(entity);
assertEquals("referenceId", cfgEntity.getReferenceId(), entity.getReferenceId());
assertEquals("referenceType", cfgEntity.getReferenceType(), entity.getReferenceType());
assertEquals("user", cfgEntity.getUser(), entity.getUser());
assertEquals("hooks", cfgEntity.getHooks(), entity.getHooks());
verify(portalNotificationConfigRepository, times(1)).findById("user", NotificationReferenceType.API, "123");
verify(portalNotificationConfigRepository, times(1)).update(any());
verify(portalNotificationConfigRepository, never()).delete(any());
verify(portalNotificationConfigRepository, never()).create(any());
}
use of io.gravitee.management.model.notification.PortalNotificationConfigEntity in project gravitee-management-rest-api by gravitee-io.
the class PortalNotificationConfigService_SaveTest method shouldCreate.
@Test
public void shouldCreate() 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"));
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(Arrays.asList("A", "B", "C"));
when(portalNotificationConfigRepository.findById("user", NotificationReferenceType.API, "123")).thenReturn(empty());
when(portalNotificationConfigRepository.create(any(PortalNotificationConfig.class))).thenReturn(cfg);
final PortalNotificationConfigEntity entity = portalNotificationConfigService.save(cfgEntity);
assertNotNull(entity);
assertEquals("referenceId", cfgEntity.getReferenceId(), entity.getReferenceId());
assertEquals("referenceType", cfgEntity.getReferenceType(), entity.getReferenceType());
assertEquals("user", cfgEntity.getUser(), entity.getUser());
assertEquals("hooks", cfgEntity.getHooks(), entity.getHooks());
verify(portalNotificationConfigRepository, times(1)).findById("user", NotificationReferenceType.API, "123");
verify(portalNotificationConfigRepository, times(1)).create(any());
verify(portalNotificationConfigRepository, never()).delete(any());
verify(portalNotificationConfigRepository, never()).update(any());
}
use of io.gravitee.management.model.notification.PortalNotificationConfigEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiNotificationSettingsResource 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 getDefaultEmpty.
private PortalNotificationConfigEntity getDefaultEmpty(String user, NotificationReferenceType referenceType, String referenceId) {
PortalNotificationConfigEntity portalNotificationConfigEntity = new PortalNotificationConfigEntity();
portalNotificationConfigEntity.setConfigType(NotificationConfigType.PORTAL);
portalNotificationConfigEntity.setReferenceType(referenceType.name());
portalNotificationConfigEntity.setReferenceId(referenceId);
portalNotificationConfigEntity.setUser(user);
portalNotificationConfigEntity.setHooks(Collections.emptyList());
return portalNotificationConfigEntity;
}
Aggregations