@Test public void test_poll_setID_noCampaign() { // GIVEN Poll sond = new Poll(); long newID = 42; // WHEN sond.setId(newID); boolean processingCampaign = sond.hasProcessingCampaign(); // THEN assertEquals(sond.getId(), newID); }
@Override public void trim(int height) { super.trim(height); try (Connection con = Db.db.getConnection(); DbIterator<Poll> polls = Poll.getPollsFinishingAtOrBefore(height); PreparedStatement pstmt = con.prepareStatement("DELETE FROM vote WHERE poll_id = ?")) { for (Poll poll : polls) { pstmt.setLong(1, poll.getId()); pstmt.executeUpdate(); } } catch (SQLException e) { throw new RuntimeException(e.toString(), e); } }