예제 #1
0
  private void extendsCrudRepositoryWithCorrectTypeParameters(
      String clazzName, String typeOneClass) {
    Class clazz = Reflex.reflect(clazzName).cls();
    Type[] typeArguments = null;
    try {
      Type[] types = clazz.getGenericInterfaces();
      ParameterizedType type = (ParameterizedType) types[0];
      typeArguments = type.getActualTypeArguments();
    } catch (Exception e) {
      fail(
          "When class "
              + clazzName
              + " extends CrudRepository, it should provide classes "
              + typeOneClass
              + " and "
              + Long.class.getName()
              + " as type parameters.");
    }

    assertTrue(
        "When class "
            + clazzName
            + " extends CrudRepository, it should provide classes "
            + typeOneClass
            + " and "
            + Long.class.getName()
            + " as type parameters.",
        typeArguments[0].equals(Reflex.reflect(typeOneClass).cls()));
    assertTrue(
        "When class "
            + clazzName
            + " extends CrudRepository, it should provide classes "
            + typeOneClass
            + " and "
            + Long.class.getName()
            + " as type parameters.",
        typeArguments[1].equals(Long.class));
  }