예제 #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())));
  }
예제 #2
0
  @Test
  public void services() throws Exception {
    Service s = makeService("serviceName", "http://abc123456.com", "message", ServiceStatus.Ok);
    when(serviceService.all()).thenReturn(Arrays.asList(s));

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