/** Tests action validation. */
  @Test
  public void validate() {
    action.validate();
    assertTrue(action.hasActionErrors());
    assertEquals(1, action.getActionErrors().size());
    assertEquals(
        "struts.messages.error.must.enter.keywords", action.getActionErrors().iterator().next());

    action.clearActionErrors();
    action.prepare();
    action.getSearchParameters().setInputValues("input");
    action.validate();
    assertFalse(action.hasActionErrors());
  }
  /** Tests expected behavior when no gene results are found. */
  @Test
  public void searchPathwayNoResults() {
    bioDbNetRemoteService = mock(BioDbNetRemoteService.class);
    when(bioDbNetRemoteService.db2db(any(Db2DbParams.class)))
        .thenAnswer(
            new Answer<String>() {
              @Override
              public String answer(InvocationOnMock invocation) throws Throwable {
                return "Gene Symbol Biocarta Pathway Name";
              }
            });

    BioDbNetSearchImpl bioDbNetSvc = new BioDbNetSearchImpl();
    bioDbNetSvc.setBioDbNetRemoteService(bioDbNetRemoteService);

    action.setBioDbNetService(bioDbNetSvc);
    action.getSearchParameters().setSearchType(SearchType.PATHWAY_BY_GENE);
    action.getSearchParameters().setInputValues(StringUtils.EMPTY);

    assertEquals(PATHWAY_RESULTS, action.search());
    assertTrue(action.getGeneResults().isEmpty());
    assertTrue(action.hasActionErrors());
    assertEquals(1, action.getActionErrors().size());
    assertEquals("bioDbNet.noPathwayResultsFound", action.getActionErrors().iterator().next());
  }
  /** Tests expected behavior when no gene results are found. */
  @Test
  public void searchGenesNoResults() {
    action.getSearchParameters().setSearchType(null);
    action.getSearchParameters().setInputValues(StringUtils.EMPTY);

    assertEquals(GENE_RESULT, action.search());
    assertTrue(action.getGeneResults().isEmpty());
    assertTrue(action.hasActionErrors());
    assertEquals(1, action.getActionErrors().size());
    assertEquals("bioDbNet.noGeneResultsFound", action.getActionErrors().iterator().next());
  }
  /** Tests expected behavior when an exception occurs during the search process. */
  @Test
  public void searchWithException() {
    doThrow(Exception.class).when(bioDbNetRemoteService).db2db(any(Db2DbParams.class));
    action.getSearchParameters().setSearchType(SearchType.PATHWAY);
    action.getSearchParameters().setInputValues(PATHWAY_NAME);

    assertEquals(Action.INPUT, action.search());
    assertTrue(action.hasActionErrors());
    assertEquals(1, action.getActionErrors().size());
    assertEquals("bioDbNet.error", action.getActionErrors().iterator().next());
  }