/** Test fetch all lights by custom search. */
  @Test
  public void testFetchAllLightsByCustomSearch() {
    // Success situation
    CustomSearch customSearch = new CustomSearch();
    customSearch.setName("name1");
    customSearch.setDescription("description1");

    SearchParameter param = new SearchParameter();
    param.setPropertyEnum(PropertyEnum.GROUP_ID);
    param.setValue("5");

    customSearch.getSearchParameters().add(param);

    CustomSearchRequest request = TestBaseUtil.createCustomSearchRequest();
    request.setCustomSearch(customSearch);

    InternalResultsResponse<CustomSearch> response =
        getSmartPointUpdaterBCL().insertCustomSearch(request);
    assertResultResponse(response);

    InquiryLightRequest inquiryLightRequest =
        TestBaseUtil.createInquiryLightRequest(TestBaseUtil.createUserContext());
    inquiryLightRequest.setSearch(response.getFirstResult());

    InternalResultsResponse<Light> lightResponse =
        getSmartPointAccessorBCL().fetchAllLights(inquiryLightRequest);
    assertResultResponse(lightResponse);
  }
  /** Test fetch all lights. */
  @Test
  public void testFetchAllLights() {
    // Success situation - Process ID
    InquiryLightRequest request =
        TestBaseUtil.createInquiryLightRequest(TestBaseUtil.createUserContext());
    request.setProcessId(1);
    InternalResultsResponse<Light> response = getSmartPointAccessorBCL().fetchAllLights(request);
    assertResultResponse(response);

    resetMocksToSmartPointArea();

    // Error situation
    setSituation(
        getSmartPointAccessorBCL(), SituationsEnum.ERROR, ISmartPointDAC.class, FETCH_ALL_LIGHTS);
    response = getSmartPointAccessorBCL().fetchAllLights(request);
    assertMessages(response, ERROR_CODE);

    resetMocksToSmartPointArea();

    // Success situation - Search
    setSituation(
        getSmartPointAccessorBCL(), SituationsEnum.SUCCESS, ISmartPointDAC.class, FETCH_ALL_LIGHTS);
    request = TestBaseUtil.createInquiryLightRequest(TestBaseUtil.createUserContext());
    request.setProcessId(null);
    request.setSearch(TestBaseUtil.createCustomSearch());
    response = getSmartPointAccessorBCL().fetchAllLights(request);
    assertResultResponse(response);

    // Error situation
    setSituation(
        getSmartPointAccessorBCL(), SituationsEnum.ERROR, ISmartPointDAC.class, FETCH_ALL_LIGHTS);
    response = getSmartPointAccessorBCL().fetchAllLights(request);
    assertMessages(response, ERROR_CODE);
  }
 /** Test fetch all lights to csv. */
 @Test
 public void testFetchAllLightsToCSV() {
   InquiryLightRequest inquiryLightRequest = createInquiryLightRequest(createUserContext());
   inquiryLightRequest.setProcessId(1);
   InternalResultsResponse<HashMap<String, String>> response =
       getSmartPointAccessorBCL().fetchAllLightsToCSV(inquiryLightRequest);
   assertNotNull(response);
   assertNotNull(response.getResultsList());
 }
 /** Test generate summary file csv. */
 @Test
 public void testGenerateSummaryFileCSV() {
   // Success situation
   InquiryLightRequest inquiryLightRequest = createInquiryLightRequest(createUserContext());
   inquiryLightRequest.setProcessId(new Integer(1));
   InquiryLightResponse response =
       getSmartPointAccessorBCL().generateSummaryFileCSV(inquiryLightRequest);
   assertNotNull(response);
   assertNotNull(response.getFileName());
   assertTrue(response.isOperationSuccess());
 }
  /** Test generate light history file csv. */
  @Test
  public void testGenerateLightHistoryFileCSV() {

    // Success situation
    InquiryLightRequest inquiryLightRequest = createInquiryLightRequest(createUserContext());
    inquiryLightRequest.setProcessId(new Integer(1));
    inquiryLightRequest.setFileName(FILE_NAME + LCDateUtil.getNewDateUTC().getTime() + ".csv");
    InquiryLightResponse response =
        getSmartPointAccessorBCL().generateLightHistoryFileCSV(inquiryLightRequest);
    assertNotNull(response);
    assertNotNull(response.getFileName());
    assertTrue(response.isOperationSuccess());

    // Errors situations
    // ISmartPointDAC
    setSituation(
        getSmartPointAccessorBCL(),
        SituationsEnum.ERROR,
        ISmartPointDAC.class,
        "generateLightHistoryFileCSV");
    response = getSmartPointAccessorBCL().generateLightHistoryFileCSV(inquiryLightRequest);
    assertFalse(response.isOperationSuccess());
    assertMessages(response, ERROR_CODE);
    resetMocksToSmartPointArea();

    // IProcessBCL
    // Return operation success because is set at implementation
    setSituation(
        getSmartPointAccessorBCL(), SituationsEnum.ERROR, IProcessBCL.class, FETCH_PROCESS_BY_ID);
    response = getSmartPointAccessorBCL().generateLightHistoryFileCSV(inquiryLightRequest);
    assertNotNull(response);
    assertFalse(response.isOperationSuccess());
    assertNull(response.getFileName());
    resetMocksToSmartPointArea();

    setSituation(
        getSmartPointAccessorBCL(), SituationsEnum.ERROR, IProcessBCL.class, UPDATE_PROCESS);
    response = getSmartPointAccessorBCL().generateLightHistoryFileCSV(inquiryLightRequest);
    assertNotNull(response);
    assertFalse(response.isOperationSuccess());
    assertNull(response.getFileName());
    resetMocksToSmartPointArea();
  }
  /** Test fetch smartpoints to map. */
  @Test
  public void testFetchSmartpointsToMap() {
    // Success situation
    InquiryLightRequest request =
        TestBaseUtil.createInquiryLightRequest(TestBaseUtil.createUserContext());
    request.setGeoCodeTrunc(1);
    InternalResultsResponse<GeocodeSmartpointInfo> response =
        getSmartPointAccessorBCL().fetchSmartpointsToMap(request);
    assertResultResponse(response);

    resetMocksToSmartPointArea();

    // Error situation
    setSituation(
        getSmartPointAccessorBCL(),
        SituationsEnum.ERROR,
        ISmartPointDAC.class,
        "fetchSmartpointsToMap");
    response = getSmartPointAccessorBCL().fetchSmartpointsToMap(request);
    assertMessages(response, ERROR_CODE);
  }
  /** Test fetch light history. */
  @Test
  public void testFetchLightHistory() {
    // Success situation
    InquiryLightRequest request =
        TestBaseUtil.createInquiryLightRequest(TestBaseUtil.createUserContext());
    request.getLights().add(TestBaseUtil.createLight());
    InternalResultsResponse<LightHistory> response =
        getSmartPointAccessorBCL().fetchLightHistory(request);
    assertResultResponse(response);

    resetMocksToSmartPointArea();

    // Error situation
    setSituation(
        getSmartPointAccessorBCL(),
        SituationsEnum.ERROR,
        ISmartPointDAC.class,
        "fetchLightHistory");
    response = getSmartPointAccessorBCL().fetchLightHistory(request);
    assertMessages(response, ERROR_CODE);
  }