Search in sources :

Example 11 with Dashboard

use of io.gravitee.repository.management.model.Dashboard in project gravitee-management-rest-api by gravitee-io.

the class DashboardServiceTest method shouldFindAll.

@Test
public void shouldFindAll() throws TechnicalException {
    final Dashboard dashboard = mock(Dashboard.class);
    when(dashboard.getId()).thenReturn(DASHBOARD_ID);
    when(dashboard.getName()).thenReturn("NAME");
    when(dashboard.getDefinition()).thenReturn("DEFINITION");
    when(dashboard.getOrder()).thenReturn(1);
    when(dashboard.getReferenceId()).thenReturn("REF_ID");
    when(dashboard.getReferenceType()).thenReturn(PLATFORM.name());
    when(dashboard.getQueryFilter()).thenReturn("QUERY FILTER");
    when(dashboard.getCreatedAt()).thenReturn(new Date(1));
    when(dashboard.getUpdatedAt()).thenReturn(new Date(2));
    when(dashboardRepository.findAll()).thenReturn(singleton(dashboard));
    final List<DashboardEntity> dashboards = dashboardService.findAll();
    final DashboardEntity dashboardEntity = dashboards.iterator().next();
    assertEquals(DASHBOARD_ID, dashboardEntity.getId());
    assertEquals("NAME", dashboardEntity.getName());
    assertEquals("DEFINITION", dashboardEntity.getDefinition());
    assertEquals(1, dashboardEntity.getOrder());
    assertEquals("REF_ID", dashboardEntity.getReferenceId());
    assertEquals(PLATFORM.name(), dashboardEntity.getReferenceType());
    assertEquals("QUERY FILTER", dashboardEntity.getQueryFilter());
    assertEquals(new Date(1), dashboardEntity.getCreatedAt());
    assertEquals(new Date(2), dashboardEntity.getUpdatedAt());
}
Also used : UpdateDashboardEntity(io.gravitee.rest.api.model.UpdateDashboardEntity) DashboardEntity(io.gravitee.rest.api.model.DashboardEntity) NewDashboardEntity(io.gravitee.rest.api.model.NewDashboardEntity) Dashboard(io.gravitee.repository.management.model.Dashboard) Date(java.util.Date) Test(org.junit.Test)

Example 12 with Dashboard

use of io.gravitee.repository.management.model.Dashboard in project gravitee-management-rest-api by gravitee-io.

the class DashboardServiceTest method shouldDelete.

@Test
public void shouldDelete() throws TechnicalException {
    final Dashboard dashboard = mock(Dashboard.class);
    when(dashboardRepository.findById(DASHBOARD_ID)).thenReturn(of(dashboard));
    dashboardService.delete(DASHBOARD_ID);
    verify(dashboardRepository, times(1)).delete(DASHBOARD_ID);
    verify(auditService, times(1)).createEnvironmentAuditLog(eq(ImmutableMap.of(DASHBOARD, DASHBOARD_ID)), eq(Dashboard.AuditEvent.DASHBOARD_DELETED), any(Date.class), isNull(), eq(dashboard));
}
Also used : Dashboard(io.gravitee.repository.management.model.Dashboard) Date(java.util.Date) Test(org.junit.Test)

Example 13 with Dashboard

use of io.gravitee.repository.management.model.Dashboard in project gravitee-management-rest-api by gravitee-io.

the class DashboardServiceTest method shouldFindById.

@Test
public void shouldFindById() throws TechnicalException {
    final Dashboard dashboard = mock(Dashboard.class);
    when(dashboard.getId()).thenReturn(DASHBOARD_ID);
    when(dashboard.getName()).thenReturn("NAME");
    when(dashboard.getDefinition()).thenReturn("DEFINITION");
    when(dashboard.getOrder()).thenReturn(1);
    when(dashboard.getReferenceId()).thenReturn("REF_ID");
    when(dashboard.getReferenceType()).thenReturn(PLATFORM.name());
    when(dashboard.getQueryFilter()).thenReturn("QUERY FILTER");
    when(dashboard.getCreatedAt()).thenReturn(new Date(1));
    when(dashboard.getUpdatedAt()).thenReturn(new Date(2));
    when(dashboardRepository.findById(DASHBOARD_ID)).thenReturn(of(dashboard));
    final DashboardEntity dashboardEntity = dashboardService.findById(DASHBOARD_ID);
    assertEquals(DASHBOARD_ID, dashboardEntity.getId());
    assertEquals("NAME", dashboardEntity.getName());
    assertEquals("DEFINITION", dashboardEntity.getDefinition());
    assertEquals(1, dashboardEntity.getOrder());
    assertEquals("REF_ID", dashboardEntity.getReferenceId());
    assertEquals(PLATFORM.name(), dashboardEntity.getReferenceType());
    assertEquals("QUERY FILTER", dashboardEntity.getQueryFilter());
    assertEquals(new Date(1), dashboardEntity.getCreatedAt());
    assertEquals(new Date(2), dashboardEntity.getUpdatedAt());
}
Also used : UpdateDashboardEntity(io.gravitee.rest.api.model.UpdateDashboardEntity) DashboardEntity(io.gravitee.rest.api.model.DashboardEntity) NewDashboardEntity(io.gravitee.rest.api.model.NewDashboardEntity) Dashboard(io.gravitee.repository.management.model.Dashboard) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Dashboard (io.gravitee.repository.management.model.Dashboard)13 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)7 DashboardEntity (io.gravitee.rest.api.model.DashboardEntity)7 NewDashboardEntity (io.gravitee.rest.api.model.NewDashboardEntity)7 UpdateDashboardEntity (io.gravitee.rest.api.model.UpdateDashboardEntity)7 Date (java.util.Date)6 Test (org.junit.Test)6 UuidString (io.gravitee.rest.api.service.common.UuidString)5 DashboardNotFoundException (io.gravitee.rest.api.service.exceptions.DashboardNotFoundException)5 TechnicalManagementException (io.gravitee.rest.api.service.exceptions.TechnicalManagementException)5 DashboardRepository (io.gravitee.repository.management.api.DashboardRepository)3 DASHBOARD (io.gravitee.repository.management.model.Audit.AuditProperties.DASHBOARD)3 DashboardReferenceType (io.gravitee.repository.management.model.DashboardReferenceType)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 PLATFORM (io.gravitee.rest.api.model.DashboardReferenceType.PLATFORM)2 DashboardServiceImpl (io.gravitee.rest.api.service.impl.DashboardServiceImpl)2 Collections.singleton (java.util.Collections.singleton)2 Collections.singletonList (java.util.Collections.singletonList)2 List (java.util.List)2 Optional.empty (java.util.Optional.empty)2