@Test public void shouldHandleNullStartDatesAndPlaceThemAtTheEnd() { PolicyQueryResultAssembler assembler = new PolicyQueryResultAssembler(); List<PolicyView> policies = new ArrayList<>(Arrays.asList( new PolicyView("1", LocalDate.of(2015,11,1), LocalDate.of(2016,10,30), "Tom Hanks"), new PolicyView("2", null, null, "Alanis Morissette"), new PolicyView("3", LocalDate.of(2015,11,2), LocalDate.of(2016,10,30), "Andy Warhol") )); FindPolicyQueryResult result = assembler.constructResult(policies); Assertions.assertTrue(result.getPolicies().get(2).getNumber().equalsIgnoreCase("2")); }
static FindPolicyQueryResult constructResult(List<PolicyView> policies) { return new FindPolicyQueryResult( policies.stream() .map(PolicyListItemDtoAssembler::map) .sorted(Comparator.comparing(PolicyListItemDto::getDateFrom, Comparator.nullsLast(Comparator.reverseOrder()))) .collect(Collectors.toList()) ); }
PolicyQueryResultAssembler { static FindPolicyQueryResult constructResult(List<PolicyView> policies) { return new FindPolicyQueryResult( policies.stream() .map(PolicyListItemDtoAssembler::map) .sorted(Comparator.comparing(PolicyListItemDto::getDateFrom, Comparator.nullsLast(Comparator.reverseOrder()))) .collect(Collectors.toList()) ); } }
PolicyQueryResultAssembler { static FindPolicyQueryResult constructResult(List<PolicyView> policies) { return new FindPolicyQueryResult( policies.stream() .map(PolicyListItemDtoAssembler::map) .sorted(Comparator.comparing(PolicyListItemDto::getDateFrom, Comparator.nullsLast(Comparator.reverseOrder()))) .collect(Collectors.toList()) ); }  }
PolicyQueryResultAssembler { static FindPolicyQueryResult constructResult(List<PolicyView> policies) { return new FindPolicyQueryResult( policies.stream() .map(PolicyListItemDtoAssembler::map) .sorted(Comparator.comparing(PolicyListItemDto::getDateFrom, Comparator.nullsLast(Comparator.reverseOrder()))) .collect(Collectors.toList()) ); }   }
PolicyQueryResultAssembler { static FindPolicyQueryResult constructResult(List<PolicyView> policies) { return new FindPolicyQueryResult( policies.stream() .map(PolicyListItemDtoAssembler::map) .sorted(Comparator.comparing(PolicyListItemDto::getDateFrom, Comparator.nullsLast(Comparator.reverseOrder()))) .collect(Collectors.toList()) ); }    }