コード例 #1
0
  public void testSearchByString() throws Exception {
    final FundsMutationSubjectRepository subjectRepository = bundle.fundsMutationSubjects();

    FundsMutationSubject clothes =
        FundsMutationSubject.builder(subjectRepository)
            .setName("Clothes")
            .setType(FundsMutationSubject.Type.PRODUCT)
            .build();
    subjectRepository.addSubject(clothes);
    FundsMutationSubject cleaners =
        FundsMutationSubject.builder(subjectRepository)
            .setName("Cleaners")
            .setType(FundsMutationSubject.Type.PRODUCT)
            .build();
    subjectRepository.addSubject(cleaners);
    ImmutableList<FundsMutationSubject> found = subjectRepository.nameLikeSearch("Cl%");
    assertTrue(
        "Search strange result " + found.get(0),
        found.get(0).equals(cleaners) || found.get(0).equals(clothes));
    assertTrue(
        "Search strange result " + found.get(1),
        found.get(1).equals(cleaners) || found.get(1).equals(clothes));
    found = subjectRepository.nameLikeSearch("%s");
    assertTrue(
        "Search strange result " + found.get(0),
        found.get(0).equals(cleaners) || found.get(0).equals(clothes));
    assertTrue(
        "Search strange result " + found.get(1),
        found.get(1).equals(cleaners) || found.get(1).equals(clothes));
    found = subjectRepository.nameLikeSearch("%ers%");
    assertTrue("Search strange result " + found.get(0), found.get(0).equals(cleaners));
  }