/**
   * Fetch demand response.
   *
   * @throws Exception the exception
   */
  @Test
  public void fetchDemandResponse() throws Exception {
    /*
     * FETCH DEMAND RESPONSE PROGRAM PARTICIPATION
     */
    setData("{\"type\" : \"demandResponseProgramParticipation\", \"id\" : \"12345\"}");

    // Success Situation
    getProcessSummaryMock().setMode(ModeEnum.MODE_SUCCESS);
    performTest(FETCH_DEMAND_RESPONSE)
        .andExpect(jsonPath("$.operationSuccess", comparesEqualTo(true)))
        .andExpect(jsonPath("$.processes", hasSize(1)));

    // Failure Situation
    getProcessSummaryMock().setMode(ModeEnum.MODE_FAILURE);
    performTest(FETCH_DEMAND_RESPONSE)
        .andExpect(jsonPath("$.operationSuccess", comparesEqualTo(false)));

    // Empty Situation
    getProcessSummaryMock().setMode(ModeEnum.MODE_EMPTY);
    performTest(FETCH_DEMAND_RESPONSE).andExpect(jsonPath("$.processes", nullValue()));

    // Exception situation
    getProcessSummaryMock().setMode(ModeEnum.MODE_EXCEPTION);
    performTest(FETCH_DEMAND_RESPONSE)
        .andExpect(
            jsonPath(
                "$.messageInfoList[0].code",
                containsString(TestMessageEnum.DEFAULT_EXCEPTION_MSG.getValue())));

    /*
     * FETCH DEMAND RESPONSE SETUP
     */
    setData("{\"type\" : \"demandResponseSetup\", \"id\" : \"12345\"}");

    // Success Situation
    getProcessSummaryMock().setMode(ModeEnum.MODE_SUCCESS);
    performTest(FETCH_DEMAND_RESPONSE)
        .andExpect(jsonPath("$.operationSuccess", comparesEqualTo(true)))
        .andExpect(jsonPath("$.processes", hasSize(1)));

    // Failure Situation
    getProcessSummaryMock().setMode(ModeEnum.MODE_FAILURE);
    performTest(FETCH_DEMAND_RESPONSE)
        .andExpect(jsonPath("$.operationSuccess", comparesEqualTo(false)));

    // Empty Situation
    getProcessSummaryMock().setMode(ModeEnum.MODE_EMPTY);
    performTest(FETCH_DEMAND_RESPONSE).andExpect(jsonPath("$.processes", nullValue()));

    // Exception situation
    getProcessSummaryMock().setMode(ModeEnum.MODE_EXCEPTION);
    performTest(FETCH_DEMAND_RESPONSE)
        .andExpect(
            jsonPath(
                "$.messageInfoList[0].code",
                containsString(TestMessageEnum.DEFAULT_EXCEPTION_MSG.getValue())));
  }
  /**
   * Fetch.
   *
   * @throws Exception the exception
   */
  @Test
  public void fetch() throws Exception {
    setData("{\"groupIds\":[1,2]}");
    // Success Situation
    getGroupMock().setMode(ModeEnum.MODE_SUCCESS);
    performTest(FETCH).andExpect(jsonPath("$.devices", hasSize(9)));

    setData("{\"premiseId\":\"1\"}");
    // Success Situation
    getDeviceMock().setMode(ModeEnum.MODE_SUCCESS);
    performTest(FETCH).andExpect(jsonPath("$.devices", hasSize(2)));

    setData("{\"id\":\"993917140\",\"type\":\"search\"}");
    // Success Situation
    getElectricMeterMock().setMode(ModeEnum.MODE_SUCCESS);
    performTest(FETCH).andExpect(jsonPath("$.devices", hasSize(4)));

    setData("{\"typeId\":\"1\",\"type\":\"manufacture\"}");
    // Success Situation
    getElectricMeterMock().setMode(ModeEnum.MODE_SUCCESS);
    performTest(FETCH).andExpect(jsonPath("$.devices", hasSize(10)));

    setData("{\"typeId\":\"2\",\"type\":\"manufacture\"}");
    // Success Situation
    getElectricMeterMock().setMode(ModeEnum.MODE_SUCCESS);
    performTest(FETCH).andExpect(jsonPath("$.devices", hasSize(10)));

    setData("{\"manufacture\":\"manufacture\",\"type\":\"model\", \"typeId\":\"1\"}");
    // Success Situation
    getElectricMeterMock().setMode(ModeEnum.MODE_SUCCESS);
    performTest(FETCH).andExpect(jsonPath("$.devices", hasSize(10)));

    setData("{\"manufacture\":\"manufacture\",\"type\":\"model\", \"typeId\":\"2\"}");
    // Success Situation
    getElectricMeterMock().setMode(ModeEnum.MODE_SUCCESS);
    performTest(FETCH).andExpect(jsonPath("$.devices", hasSize(10)));

    setData("{\"id\":\"993917140\",\"deviceType\":\"LCM\"}");
    // Success Situation
    getElectricMeterMock().setMode(ModeEnum.MODE_SUCCESS);
    performTest(FETCH).andExpect(jsonPath("$.devices", hasSize(1)));

    setData("{\"macAddress\":\"993917140\",\"deviceType\":\"LCM\"}");
    // Success Situation
    getElectricMeterMock().setMode(ModeEnum.MODE_SUCCESS);
    performTest(FETCH).andExpect(jsonPath("$.devices", hasSize(1)));

    setData("{\"deviceId\":\"1010M\",\"deviceType\":\"LCM\"}");
    // Success Situation
    getElectricMeterMock().setMode(ModeEnum.MODE_SUCCESS);
    performTest(FETCH).andExpect(jsonPath("$.devices", hasSize(1)));

    // Failure Situation
    getElectricMeterMock().setMode(ModeEnum.MODE_FAILURE);
    performTest(FETCH).andExpect(jsonPath("$.operationSuccess", comparesEqualTo(false)));

    // Empty Situation
    getElectricMeterMock().setMode(ModeEnum.MODE_EMPTY);
    performTest(FETCH).andExpect(jsonPath("$.devices", nullValue()));

    // Exception situation
    getElectricMeterMock().setMode(ModeEnum.MODE_EXCEPTION);
    performTest(FETCH)
        .andExpect(
            jsonPath(
                "$.messageInfoList[0].code",
                containsString(TestMessageEnum.DEFAULT_EXCEPTION_MSG.getValue())));
  }