コード例 #1
0
  /**
   * Attempts to enrich a legal cvTerm but with a null fetcher. This should throw an illegal state
   * exception.
   *
   * @throws EnricherException
   */
  @Test(expected = IllegalArgumentException.class)
  public void test_enriching_with_null_CvTermFetcher() throws EnricherException {
    BioactiveEntity bioactiveEntity = new DefaultBioactiveEntity(TEST_SHORTNAME, TEST_FULLNAME);
    bioactiveEntity.setChebi(CHEBI_ID);

    enricher = new FullBioactiveEntityUpdater(null);
  }
コード例 #2
0
  /**
   * Creates a scenario where the fetcher always throws a bridge failure exception. Shows that the
   * query does not repeat infinitely.
   *
   * @throws psidev.psi.mi.jami.enricher.exception.EnricherException
   */
  @Test(expected = EnricherException.class)
  public void test_bridgeFailure_throws_exception_when_persistent() throws EnricherException {

    persistentBioactiveEntity = new DefaultBioactiveEntity(TEST_SHORTNAME, TEST_FULLNAME);
    persistentBioactiveEntity.setChebi(CHEBI_ID);

    int timesToTry = -1;

    FailingBioactiveEntityFetcher fetcher = new FailingBioactiveEntityFetcher(timesToTry);
    fetcher.addEntry(CHEBI_ID, Collections.singleton(persistentBioactiveEntity));
    enricher = new FullBioactiveEntityUpdater(fetcher);

    enricher.enrich(persistentBioactiveEntity);

    fail("Exception should be thrown before this point");
  }
コード例 #3
0
  /**
   * Creates a scenario where the fetcher does not retrieve an entry on its first attempt. If the
   * enricher re-queries the fetcher, it will eventually receive the entry.
   *
   * @throws EnricherException
   */
  @Test
  public void test_bridgeFailure_does_not_throw_exception_when_not_persistent()
      throws EnricherException {

    persistentBioactiveEntity = new DefaultBioactiveEntity(TEST_SHORTNAME, TEST_FULLNAME);
    persistentBioactiveEntity.setChebi(CHEBI_ID);

    int timesToTry = 3;
    assertTrue(
        "The test can not be applied as the conditions do not invoke the required response. "
            + "Change the timesToTry.",
        timesToTry < 5);

    FailingBioactiveEntityFetcher fetcher = new FailingBioactiveEntityFetcher(timesToTry);
    fetcher.addEntry(CHEBI_ID, Collections.singleton(persistentBioactiveEntity));
    enricher = new FullBioactiveEntityUpdater(fetcher);

    enricher.enrich(persistentBioactiveEntity);

    assertEquals(TEST_FULLNAME, persistentBioactiveEntity.getFullName());
  }