Search in sources :

Example 11 with PortalNotificationConfigEntity

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");
}
Also used : PortalNotificationConfig(io.gravitee.repository.management.model.PortalNotificationConfig) PortalNotificationConfigEntity(io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity) Test(org.junit.Test)

Example 12 with PortalNotificationConfigEntity

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");
}
Also used : PortalNotificationConfigEntity(io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity) Test(org.junit.Test)

Aggregations

PortalNotificationConfigEntity (io.gravitee.rest.api.model.notification.PortalNotificationConfigEntity)12 Test (org.junit.Test)5 PortalNotificationConfig (io.gravitee.repository.management.model.PortalNotificationConfig)3 Permissions (io.gravitee.rest.api.portal.rest.security.Permissions)2 HashSet (java.util.HashSet)1