Source:
<code>public void canGetAllSurveys() throws Exception { Set<GuidCreatedOnVersionHolderImpl> mostRecentVersionSurveys = new HashSet<>(); mostRecentVersionSurveys.add(new GuidCreatedOnVersionHolderImpl(createSurvey(new TestSurvey(DynamoSurveyDaoTest.class, true)))); mostRecentVersionSurveys.add(new GuidCreatedOnVersionHolderImpl(createSurvey(new TestSurvey(DynamoSurveyDaoTest.class, true)))); mostRecentVersionSurveys.add(new GuidCreatedOnVersionHolderImpl(createSurvey(new TestSurvey(DynamoSurveyDaoTest.class, true)))); mostRecentVersionSurveys.add(new GuidCreatedOnVersionHolderImpl(createSurvey(new TestSurvey(DynamoSurveyDaoTest.class, true)))); Survey survey = createSurvey(new TestSurvey(DynamoSurveyDaoTest.class, true)); versionSurvey(survey); Thread.sleep(GSI_WAIT_DURATION); List<Survey> surveys = surveyDao.getAllSurveysMostRecentVersion(TEST_STUDY, false); assertContainsAllKeys(mostRecentVersionSurveys, surveys); surveys = surveyDao.getSurveyAllVersions(TEST_STUDY, survey.getGuid(), false); assertEquals("All survey versions are returned", 2, surveys.size()); int totalCount = surveys.size(); Survey version1 = surveys.get(0); Survey version2 = surveys.get(1); assertEquals("Surveys have same GUID", version1.getGuid(), version2.getGuid()); assertEquals("Surveys have same Study key", version1.getStudyIdentifier(), version2.getStudyIdentifier()); assertNotEquals("Surveys have different createdOn attribute", version1.getCreatedOn(), version2.getCreatedOn()); surveyDao.deleteSurveyPermanently(version1); <START> assertEquals(totalCount-1, surveyDao.getSurveyAllVersions(TEST_STUDY, survey.getGuid(), true).size()); <END> }</code><technical_language>Similarly, iterate list verify deleted version is longer in list</technical_language>

Target:
public void canGetAllSurveys() throws Exception { Set<GuidCreatedOnVersionHolderImpl> mostRecentVersionSurveys = new HashSet<>(); mostRecentVersionSurveys.add(new GuidCreatedOnVersionHolderImpl(createSurvey(new TestSurvey(DynamoSurveyDaoTest.class, true)))); mostRecentVersionSurveys.add(new GuidCreatedOnVersionHolderImpl(createSurvey(new TestSurvey(DynamoSurveyDaoTest.class, true)))); mostRecentVersionSurveys.add(new GuidCreatedOnVersionHolderImpl(createSurvey(new TestSurvey(DynamoSurveyDaoTest.class, true)))); mostRecentVersionSurveys.add(new GuidCreatedOnVersionHolderImpl(createSurvey(new TestSurvey(DynamoSurveyDaoTest.class, true)))); Survey survey = createSurvey(new TestSurvey(DynamoSurveyDaoTest.class, true)); versionSurvey(survey); Thread.sleep(GSI_WAIT_DURATION); List<Survey> surveys = surveyDao.getAllSurveysMostRecentVersion(TEST_STUDY, false); assertContainsAllKeys(mostRecentVersionSurveys, surveys); surveys = surveyDao.getSurveyAllVersions(TEST_STUDY, survey.getGuid(), false); assertEquals("All survey versions are returned", 2, surveys.size()); Survey version1 = surveys.get(0); Survey version2 = surveys.get(1); assertEquals("Surveys have same GUID", version1.getGuid(), version2.getGuid()); assertEquals("Surveys have same Study key", version1.getStudyIdentifier(), version2.getStudyIdentifier()); assertNotEquals("Surveys have different createdOn attribute", version1.getCreatedOn(), version2.getCreatedOn()); surveyDao.deleteSurveyPermanently(version1); assertTrue(surveyDao.getSurveyAllVersions(TEST_STUDY, survey.getGuid(), true).stream() .noneMatch((oneSurvey) -> version1.equals(oneSurvey))); }