Skip to content

Commit

Permalink
#25079 adding missing sort clause in new code
Browse files Browse the repository at this point in the history
  • Loading branch information
fabrizzio-dotCMS committed May 30, 2023
1 parent 8d5b0f5 commit 8d0488f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
Expand All @@ -69,6 +70,7 @@
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.apache.commons.lang3.BooleanUtils;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
Expand Down Expand Up @@ -1337,6 +1339,12 @@ public void findAllVersionsByVariant() throws DotDataException, DotSecurityExcep
.equals(contentletLanguage2DefaultVariant.getIdentifier())));
assertTrue(contentlets.stream().anyMatch(contentlet -> contentlet.getIdentifier()
.equals(contentletLanguage3DefaultVariant.getIdentifier())));

//Now test findAllVersions is returning the versions in descending order
final List<Contentlet> copy = new ArrayList<>(contentlets);
copy.sort((o1, o2) -> o2.getModDate().compareTo(o1.getModDate()));
assertEquals(copy,contentlets);

}

/**
Expand Down Expand Up @@ -1410,6 +1418,12 @@ public void findAllVersionsWithOldVersionsByVariant() throws DotDataException, D

expectedInodes.forEach(inode -> assertTrue(contentlets.stream()
.anyMatch(contentlet -> contentlet.getInode().equals(inode))));

//Now test findAllVersions is returning the versions in descending order
final List<Contentlet> copy = new ArrayList<>(contentlets);
copy.sort((o1, o2) -> o2.getModDate().compareTo(o1.getModDate()));
assertEquals(copy,contentlets);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ protected List<Contentlet> findAllVersions(final Identifier identifier, final V

return new DotConnect()
.setSQL(String.format(
"select inode from contentlet where identifier = ? and %s = ?",
"select inode from contentlet where identifier = ? and %s = ? order by mod_date desc",
columnName))
.addParam(identifier.getId())
.addParam(variant.name())
Expand Down

0 comments on commit 8d0488f

Please sign in to comment.