LevelDAO { public void deleteParameterLevels(QueryRunner queryRunner, String parameterName) { DeleteQuery query = QueryFactory.delete().from(configuration.levelEntityName()) .where("fk_parameter = (select id from " + configuration.parameterEntityName() + " where name = :parameterName)") .withArgument("parameterName", parameterName); queryRunner.delete(query); } LevelDAO(JdbcConfig configuration); void insertParameterLevels(QueryRunner queryRunner, List<Level> levels, long parameterId); long insert(QueryRunner queryRunner, Level level, long parameterId); JdbcLevel getLevel(QueryRunner queryRunner, long id); List<Level> getLevels(QueryRunner queryRunner, long parameterId); List<JdbcLevel> getJdbcLevels(QueryRunner queryRunner, long parameterId); void deleteParameterLevels(QueryRunner queryRunner, String parameterName); void delete(QueryRunner queryRunner, long parameterId, long levelId); void update(QueryRunner queryRunner, long levelId, Level level); void reorder(QueryRunner queryRunner, long[] reorderedLevelIds);  }
@Test public void shouldDeleteLevelsForParameter() { database().withParameter("parameter").withLevels("parameter", 2).build(); LevelDAO levelDAO = get(LevelDAO.class); QueryRunner runner = queryRunner(); levelDAO.deleteParameterLevels(runner, "parameter"); runner.close(); assertDatabase().hasNoLevelsForParameter("parameter").close(); }