/** 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 verify custom search. */
  @Test
  public void testVerifyCustomSearch() {
    // Success situation
    List<SearchParameter> params = new ArrayList<SearchParameter>();
    SearchParameter param = new SearchParameter();

    CustomSearch customSearch = new CustomSearch();

    // Without Search Parameters
    SearchLight customSearchReturn = getSmartPointAccessorBCL().verifyCustomSearch(customSearch);
    assertEquals("should have no parameters", 0, customSearchReturn.getSearchParameters().size());

    customSearch.setName("name");
    customSearch.setDescription("description");

    // One Search Parameters with value null
    customSearch.setSearchParameters(Arrays.asList(new SearchParameter()));
    customSearchReturn = getSmartPointAccessorBCL().verifyCustomSearch(customSearch);
    assertNotNull("should be valid  ", customSearch.getSearchParameters());

    param = new SearchParameter();
    param.setPropertyEnum(PropertyEnum.GROUP_ID);
    param.setValue("0");
    params.add(param);

    param = new SearchParameter();
    param.setPropertyEnum(PropertyEnum.TAG_ID);
    param.setValue("1");
    params.add(param);

    param = new SearchParameter();
    param.setPropertyEnum(PropertyEnum.OFFSET_SCHEDULE);
    param.setValue("2");
    params.add(param);

    param = new SearchParameter();
    param.setPropertyEnum(PropertyEnum.EVENT_SCHEDULE);
    param.setValue("3");
    params.add(param);

    customSearch.setSearchParameters(params);

    customSearchReturn = getSmartPointAccessorBCL().verifyCustomSearch(customSearch);
    assertNotNull("Should be valid", customSearch.getSearchParameters());
    assertEquals(
        "should have the same number of params",
        params.size(),
        customSearch.getSearchParameters().size());

    for (SearchParameter p : customSearch.getSearchParameters()) {
      assertFalse("should be all false ", p.isValidParameter() && !p.isValidParameter());
    }

    assertNotNull("Should be valid ", customSearchReturn.getSearchParameters());
    assertEquals(
        "should have parameters",
        ARBITRARY_SEARCH_PARAMETERS_SIZE_4,
        customSearchReturn.getSearchParameters().size());

    resetMocksToSmartPointArea();

    // Error situation
    setSituation(
        getSmartPointAccessorBCL(), SituationsEnum.ERROR, IGroupBCL.class, "fetchGroupById");
    customSearchReturn = getSmartPointAccessorBCL().verifyCustomSearch(customSearch);

    setSituation(
        getSmartPointAccessorBCL(), SituationsEnum.ERROR, IScheduleBCL.class, "fetchScheduleById");
    customSearchReturn = getSmartPointAccessorBCL().verifyCustomSearch(customSearch);

    setSituation(getSmartPointAccessorBCL(), SituationsEnum.ERROR, ITagBCL.class, "fetchTagById");
    customSearchReturn = getSmartPointAccessorBCL().verifyCustomSearch(customSearch);

    resetMocksToSmartPointArea();

    // Success situation
    params.clear();
    param = new SearchParameter();
    param.setPropertyEnum(PropertyEnum.STREET_NAME);
    param.setValue("street name");
    params.add(param);

    param = new SearchParameter();
    param.setPropertyEnum(PropertyEnum.CITY_NAME);
    param.setValue("omaha");
    params.add(param);

    customSearch.setSearchParameters(params);

    customSearchReturn = getSmartPointAccessorBCL().verifyCustomSearch(customSearch);
    assertNotNull("should be valid ", customSearch.getSearchParameters());
    assertEquals(
        "should have the same number of params ",
        params.size(),
        customSearch.getSearchParameters().size());

    for (SearchParameter p : customSearch.getSearchParameters()) {
      assertTrue("should be all true ", p.isValidParameter());
    }

    assertNotNull("should be valid", customSearchReturn.getSearchParameters());
    assertEquals(
        "should have the same number of parameters",
        params.size(),
        customSearchReturn.getSearchParameters().size());
  }