コード例 #1
0
ファイル: RepositoryTest.java プロジェクト: Juusoh/s2012-wepa
  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));
  }