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());
}
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));
}
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());
}
Aggregations