/** 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 update light status. */
 @Test
 public void testFetchUpdateLightStatus() {
   // Success situation
   ProcessRequest request = TestBaseUtil.createProcessRequest();
   request.setProcess(TestBaseUtil.createProcess(TestBaseUtil.createLight(), null));
   InternalResultsResponse<Light> response =
       getSmartPointAccessorBCL().fetchUpdateLightStatus(request);
   assertResultResponse(response);
 }
  /** Test fetch property valid value by name. */
  @Test
  public void testFetchPropertyValidValueByName() {
    // Success situation
    PropertyValidValuesRequest request = TestBaseUtil.createPropertyValidValuesRequest();

    List<PropertyEnum> properties = new ArrayList<PropertyEnum>();
    properties.add(PropertyEnum.WATTAGE_RATING);
    properties.add(PropertyEnum.LAMP_TYPE);

    request.setProperties(properties);

    InternalResultsResponse<PropertyValidValue> response =
        getSmartPointAccessorBCL().fetchPropertyValidValues(request);
    assertResultResponse(response);

    resetMocksToSmartPointArea();

    // Error situation
    setSituation(
        getSmartPointAccessorBCL(),
        SituationsEnum.ERROR,
        ISmartPointDAC.class,
        "fetchPropertyValidValues");
    response = getSmartPointAccessorBCL().fetchPropertyValidValues(request);
    assertEquals("Results list object should be 0", response.getResultsList().size(), 0);
  }
  /** Test fetch light by rni id. */
  @Test
  public void testFetchLightByRniId() {
    // Success situation
    LightRequest request = TestBaseUtil.createLightRequest();
    request.addLight(TestBaseUtil.createLight());
    InternalResultsResponse<Light> response = getSmartPointAccessorBCL().fetchLightByRniId(request);
    assertResultResponse(response);

    resetMocksToSmartPointArea();

    // Error situation
    setSituation(
        getSmartPointAccessorBCL(),
        SituationsEnum.ERROR,
        ISmartPointDAC.class,
        "fetchLightByRniId");
    response = getSmartPointAccessorBCL().fetchLightByRniId(request);
    assertMessages(response, ERROR_CODE);
  }
  /** Test fetch all lights to apply schedule. */
  @Test
  public void testFetchAllLightsToApplySchedule() {
    // Success situation
    ScheduleRequest request = TestBaseUtil.createScheduleRequest();
    request.setSchedule(TestBaseUtil.createOffSetSchedule());
    InternalResultsResponse<Light> response =
        getSmartPointAccessorBCL().fetchAllLightsToApplySchedule(request);
    assertResultResponse(response);

    resetMocksToSmartPointArea();

    // Error situation
    setSituation(
        getSmartPointAccessorBCL(),
        SituationsEnum.ERROR,
        ISmartPointDAC.class,
        "fetchAllLightsToApplySchedule");
    response = getSmartPointAccessorBCL().fetchAllLightsToApplySchedule(request);
    assertMessages(response, ERROR_CODE);
  }
  /** 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);
  }
  /** Test fetch all lights by process. */
  @Test
  public void testFetchAllLightsByProcess() {
    // Success situation
    ProcessRequest request = TestBaseUtil.createProcessRequest();
    Process process = TestBaseUtil.createProcess(TestBaseUtil.createLight(), null);
    request.setProcess(process);
    InternalResultsResponse<Light> response =
        getSmartPointAccessorBCL().fetchAllLightsByProcess(request);
    assertResultResponse(response);

    resetMocksToSmartPointArea();

    // Error situation
    setSituation(
        getSmartPointAccessorBCL(),
        SituationsEnum.ERROR,
        ISmartPointDAC.class,
        "fetchAllLightsByProcess");
    response = getSmartPointAccessorBCL().fetchAllLightsByProcess(request);
    assertMessages(response, ERROR_CODE);
  }
  /** Test can insert custom search. */
  @Test
  public void testCanInsertCustomSearch() {
    // Can Insert
    List<MessageInfo> list = new ArrayList<MessageInfo>();

    CustomSearchRequest request = TestBaseUtil.createCustomSearchRequest();
    request.setCustomSearch(TestBaseUtil.createCustomSearch());
    Boolean canInsert =
        getSmartPointAccessorBCL()
            .fetchCanInsertCustomSearch(
                TestBaseUtil.createTenant(), TestBaseUtil.createCustomSearch(), 1, list, null);
    assertEquals("Can Insert", canInsert, true);

    resetMocksToSmartPointArea();

    // Can Not Insert
    setSituation(
        getSmartPointAccessorBCL(),
        SituationsEnum.ERROR,
        ISmartPointDAC.class,
        "fetchCanInsertCustomSearch");
    canInsert =
        getSmartPointAccessorBCL()
            .fetchCanInsertCustomSearch(
                TestBaseUtil.createTenant(), TestBaseUtil.createCustomSearch(), 1, list, null);
    assertEquals("Can Not Insert", canInsert, false);
  }
  /** Test fetch light by id. */
  @Test
  public void testFetchLightById() {
    // Success situation
    LightRequest lightRequest = TestBaseUtil.createLightRequest();
    Light light = TestBaseUtil.createLight();
    lightRequest.addLight(light);
    InternalResultsResponse<Light> response =
        getSmartPointAccessorBCL().fetchLightById(lightRequest);
    assertResultResponse(response);

    lightRequest = TestBaseUtil.createLightRequest();
    light = TestBaseUtil.createLight();
    light.getLightLocation().setZipCode("OffSetNegative");
    lightRequest.addLight(light);
    response = getSmartPointAccessorBCL().fetchLightById(lightRequest);
    assertResultResponse(response);

    resetMocksToSmartPointArea();

    // Error situation
    setSituation(
        getSmartPointAccessorBCL(), SituationsEnum.ERROR, ISmartPointDAC.class, "fetchLightById");
    lightRequest = TestBaseUtil.createLightRequest();
    light = TestBaseUtil.createLight();
    lightRequest.addLight(light);
    response = getSmartPointAccessorBCL().fetchLightById(lightRequest);
    assertMessages(response, ERROR_CODE);
  }
  /** Test fetch all columns filters. */
  @Test
  public void testFetchAllColumnsFilters() {
    // Success situation
    ColumnFilterRequest request = TestBaseUtil.createColumnFilterRequest();
    request.setListTypeEnum(ListTypeEnum.SMARTPOINTLIST);
    InternalResultsResponse<ColumnFilterResponse> response =
        getSmartPointAccessorBCL().fetchAllColumnFilters(request);
    assertResultResponse(response);

    resetMocksToSmartPointArea();

    // Error situation
    setSituation(
        getSmartPointAccessorBCL(),
        SituationsEnum.ERROR,
        ISmartPointDAC.class,
        "fetchAllColumnFilters");
    request = TestBaseUtil.createColumnFilterRequest();
    request.setListTypeEnum(ListTypeEnum.SMARTPOINTLIST);
    response = getSmartPointAccessorBCL().fetchAllColumnFilters(request);
    assertMessages(response, ERROR_CODE);
  }
 /** Testfetch light configuration by id. */
 @Test
 public void testfetchLightConfigurationById() {
   // Test success
   InternalResultsResponse<Light> internalResultsResponse = new InternalResultsResponse<Light>();
   setSituation(
       getSmartPointAccessorBCL(),
       SituationsEnum.SUCCESS,
       ISmartPointDAC.class,
       "fetchLightConfigurationById");
   internalResultsResponse =
       getSmartPointAccessorBCL().fetchLightConfigurationById(TestBaseUtil.createLightRequest());
   assertResultResponse(internalResultsResponse);
 }
  /** Test fetch all custom search. */
  @Test
  public void testFetchAllCustomSearch() {
    // Success situation
    InquiryPaginationRequest request = TestBaseUtil.createInquiryPaginationRequest();
    InternalResultsResponse<CustomSearch> response =
        getSmartPointAccessorBCL().fetchAllCustomSearch(request);
    assertResultResponse(response);

    resetMocksToSmartPointArea();

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