/**
   * Asserts that the factory recognized configured repository classes that contain custom method
   * but no custom implementation could be found. Furthremore the exception has to contain the name
   * of the repository interface as for a large repository configuration it's hard to find out where
   * this error occured.
   *
   * @throws Exception
   */
  @Test
  public void capturesMissingCustomImplementationAndProvidesInterfacename() throws Exception {

    try {
      factory.getRepository(SampleRepository.class);
    } catch (IllegalArgumentException e) {
      assertTrue(e.getMessage().contains(SampleRepository.class.getName()));
    }
  }
示例#2
0
 /**
  * Tests that planner throws an error if you pass to {@link
  * Planner#convert(org.eigenbase.sql.SqlNode)} a {@link org.eigenbase.sql.SqlNode} that has been
  * parsed but not validated.
  */
 @Test
 public void testConvertWithoutValidateFails() throws Exception {
   Planner planner = getPlanner();
   SqlNode parse = planner.parse("select * from \"emps\"");
   try {
     RelNode rel = planner.convert(parse);
     fail("expected error, got " + rel);
   } catch (IllegalArgumentException e) {
     assertThat(
         e.getMessage(), containsString("cannot move from STATE_3_PARSED to STATE_4_VALIDATED"));
   }
 }
  @Test
  public void usesQueryDslRepositoryIfInterfaceImplementsExecutor() {

    when(metadata.getJavaType()).thenReturn(User.class);
    assertEquals(
        QueryDslJpaRepository.class,
        factory.getRepositoryBaseClass(
            new DefaultRepositoryMetadata(QueryDslSampleRepository.class)));

    try {
      QueryDslSampleRepository repository = factory.getRepository(QueryDslSampleRepository.class);
      assertEquals(QueryDslJpaRepository.class, ((Advised) repository).getTargetClass());
    } catch (IllegalArgumentException e) {
      assertThat(
          e.getStackTrace()[0].getClassName(),
          is("org.springframework.data.querydsl.SimpleEntityPathResolver"));
    }
  }