Skip to content

Commit

Permalink
EnsembleSummaryView sorts Ensembles in Descending order
Browse files Browse the repository at this point in the history
  • Loading branch information
tedyoung committed Jan 23, 2024
1 parent f900e8f commit 4934809
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.time.ZonedDateTime;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
Expand All @@ -28,6 +29,7 @@ public record EnsembleSummaryView(long id,

public static List<EnsembleSummaryView> from(List<Ensemble> ensembles, MemberId memberId, MemberService memberService) {
return ensembles.stream()
.sorted(Comparator.comparing(Ensemble::startDateTime).reversed())
.map(ensemble -> toView(ensemble, memberId, memberService))
.toList();
}
Expand Down Expand Up @@ -72,8 +74,8 @@ static Status createStatusFor(Ensemble ensemble, MemberStatus memberStatusForEns

if (ensemble.isCompleted()) {
return Status.linksOnly(List.of(
new DisplayLink(ensemble.recordingLink().toString(),
"Recording Link")));
new DisplayLink(ensemble.recordingLink().toString(),
"Recording Link")));
}

return switch (memberStatusForEnsemble) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.net.URI;
import java.time.ZonedDateTime;
import java.util.Comparator;
import java.util.List;

import static org.assertj.core.api.Assertions.*;
Expand All @@ -36,16 +37,13 @@ class AllViews {
void ensemblesSortedDescendingByDate() {
Ensemble ensembleYesterday = new EnsembleBuilder()
.scheduled(ZonedDateTime.now().minusDays(1))
.id(7).named("Yesterday")
.build();
.id(7).named("Yesterday").build();
Ensemble ensembleLastWeek = new EnsembleBuilder()
.scheduled(ZonedDateTime.now().minusWeeks(1))
.id(3).named("Last Week")
.build();
.id(3).named("Last Week").build();
Ensemble ensembleLastMonth = new EnsembleBuilder()
.scheduled(ZonedDateTime.now().minusMonths(1))
.id(5).named("Last Month")
.build();
.id(5).named("Last Month").build();
List<Ensemble> ensembles = List.of(ensembleLastWeek, ensembleYesterday, ensembleLastMonth);
MemberService memberService = new DefaultMemberService(new InMemoryMemberRepository());
MemberId memberId = MemberId.of(71L);
Expand All @@ -54,7 +52,7 @@ void ensemblesSortedDescendingByDate() {

assertThat(viewsDescending)
.extracting(EnsembleSummaryView::dateTime)
.isSorted();
.isSortedAccordingTo(Comparator.reverseOrder());
}
}

Expand Down

0 comments on commit 4934809

Please sign in to comment.