Пример #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())));
  }
Пример #3
0
  @Test
  public void updateService() throws Exception {
    ObjectId dashboardId = ObjectId.get();
    ObjectId serviceId = ObjectId.get();
    Service service = new Service();
    ServiceRequest request = makeServiceRequest(ServiceStatus.Ok, "Ok now");

    when(serviceService.get(serviceId)).thenReturn(service);

    mockMvc
        .perform(
            put("/dashboard/" + dashboardId.toString() + "/service/" + serviceId.toString())
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(request)))
        .andExpect(status().isOk());

    verify(serviceService).update(dashboardId, service);
    assertThat(service.getStatus(), is(ServiceStatus.Ok));
    assertThat(service.getMessage(), is("Ok now"));
  }