예제 #1
0
  @Test
  public void dashboardServices() throws Exception {
    ObjectId dashboardId = ObjectId.get();
    Service s =
        makeService("serviceName", "http://abc123456.com", "message", ServiceStatus.Warning);
    Service dep =
        makeService("depServiceName", "http://abc123456.com", "depMessage", ServiceStatus.Alert);

    when(serviceService.dashboardServices(dashboardId)).thenReturn(Arrays.asList(s));
    when(serviceService.dashboardDependentServices(dashboardId)).thenReturn(Arrays.asList(dep));

    mockMvc
        .perform(get("/dashboard/" + dashboardId.toString() + "/service"))
        .andExpect(status().isOk())
        .andExpect(jsonPath("$.result.services", hasSize(1)))
        .andExpect(jsonPath("$.result.services[0].id", is(s.getId().toString())))
        .andExpect(jsonPath("$.result.services[0].dashboardId", is(s.getDashboardId().toString())))
        .andExpect(jsonPath("$.result.services[0].lastUpdated", is(s.getLastUpdated())))
        .andExpect(jsonPath("$.result.services[0].applicationName", is(s.getApplicationName())))
        .andExpect(jsonPath("$.result.services[0].name", is(s.getName())))
        .andExpect(jsonPath("$.result.services[0].message", is(s.getMessage())))
        .andExpect(jsonPath("$.result.services[0].status", is(s.getStatus().toString())))
        .andExpect(jsonPath("$.result.dependencies", hasSize(1)))
        .andExpect(jsonPath("$.result.dependencies[0].id", is(dep.getId().toString())))
        .andExpect(
            jsonPath("$.result.dependencies[0].dashboardId", is(dep.getDashboardId().toString())))
        .andExpect(jsonPath("$.result.dependencies[0].lastUpdated", is(dep.getLastUpdated())))
        .andExpect(
            jsonPath("$.result.dependencies[0].applicationName", is(dep.getApplicationName())))
        .andExpect(jsonPath("$.result.dependencies[0].name", is(dep.getName())))
        .andExpect(jsonPath("$.result.dependencies[0].message", is(dep.getMessage())))
        .andExpect(jsonPath("$.result.dependencies[0].status", is(dep.getStatus().toString())));
  }