@Test public void isAnInterface() { exists(); assertTrue( "Class " + AIRCRAFT_REPOSITORY_CLASSNAME + " should be an interface.", Modifier.isInterface(Reflex.reflect(AIRCRAFT_REPOSITORY_CLASSNAME).cls().getModifiers())); assertTrue( "Class " + AIRPORT_REPOSITORY_CLASSNAME + " should be an interface.", Modifier.isInterface(Reflex.reflect(AIRPORT_REPOSITORY_CLASSNAME).cls().getModifiers())); }
@Test public void extendsCrudRepository() { isAnInterface(); assertTrue( "Class " + AIRCRAFT_REPOSITORY_CLASSNAME + " should extend interface " + CrudRepository.class.getName() + ".", CrudRepository.class.isAssignableFrom(Reflex.reflect(AIRCRAFT_REPOSITORY_CLASSNAME).cls())); assertTrue( "Class " + AIRPORT_REPOSITORY_CLASSNAME + " should extend interface " + CrudRepository.class.getName() + ".", CrudRepository.class.isAssignableFrom(Reflex.reflect(AIRPORT_REPOSITORY_CLASSNAME).cls())); }
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)); }
@Before public void haeLuokka() { klass = Reflex.reflect(klassName); }
@Test public void exists() { Reflex.reflect(AIRCRAFT_REPOSITORY_CLASSNAME); Reflex.reflect(AIRPORT_REPOSITORY_CLASSNAME); }