@Test public void shouldSelectPurgeableSnapshots() { setupData("shouldSelectPurgeableSnapshots"); List<PurgeableSnapshotDto> snapshots = dao.selectPurgeableSnapshots(1L); assertThat(snapshots, hasItem(new SnapshotMatcher(1L, true, false))); assertThat(snapshots, hasItem(new SnapshotMatcher(4L, false, false))); assertThat(snapshots, hasItem(new SnapshotMatcher(5L, false, true))); assertThat(snapshots.size(), is(3)); }
@Test public void shouldDeleteProject() { setupData("shouldDeleteProject"); dao.deleteResourceTree(1L); assertEmptyTables( "projects", "snapshots", "action_plans", "action_plans_reviews", "reviews", "review_comments", "issues", "issue_changes", "action_plans_issues"); }
@Test public void shouldCloseReviewWhenDisablingResource() { setupData("shouldCloseReviewWhenDisablingResource"); SqlSession session = getMyBatis().openSession(); try { dao.disableResource(1L, session.getMapper(PurgeMapper.class)); // the above method does not commit and close the session session.commit(); } finally { MyBatis.closeQuietly(session); } checkTables( "shouldCloseReviewWhenDisablingResource", /* excluded column */ new String[] {"updated_at"}, "reviews"); }
@Test public void shouldDeleteSnapshots() { setupData("shouldDeleteSnapshots"); dao.deleteSnapshots(PurgeSnapshotQuery.create().setIslast(false).setResourceId(1L)); checkTables("shouldDeleteSnapshots", "snapshots"); }
@Test public void shouldDisableResourcesWithoutLastSnapshot() { setupData("shouldDisableResourcesWithoutLastSnapshot"); dao.purge(1, new String[0]); checkTables("shouldDisableResourcesWithoutLastSnapshot", "projects", "snapshots"); }
@Test public void shouldDeleteHistoricalDataOfDirectoriesAndFiles() { setupData("shouldDeleteHistoricalDataOfDirectoriesAndFiles"); dao.purge(1, new String[] {Scopes.DIRECTORY, Scopes.FILE}); checkTables("shouldDeleteHistoricalDataOfDirectoriesAndFiles", "projects", "snapshots"); }
@Test public void shouldPurgeProject() { setupData("shouldPurgeProject"); dao.purge(1, new String[0]); checkTables("shouldPurgeProject", "projects", "snapshots"); }
@Test public void shouldDeleteAbortedBuilds() { setupData("shouldDeleteAbortedBuilds"); dao.purge(1L, new String[0]); checkTables("shouldDeleteAbortedBuilds", "snapshots"); }