use of uk.nhs.digital.website.beans.SupplementaryInformation in project hippo by NHS-digital-website.
the class SupplementaryInformationHubComponent method doBeforeRender.
@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) {
super.doBeforeRender(request, response);
final HstRequestContext context = request.getRequestContext();
final SupplementaryInformationHub document = (SupplementaryInformationHub) context.getContentBean();
if (document != null) {
request.setAttribute("document", document);
}
List<SupplementaryInformation> si = getListOfSupplementaryInformation();
request.setAttribute("years", years(si));
String selectedYear = DocumentUtils.findYearOrDefault(getSelectedYear(request), Calendar.getInstance().get(Calendar.YEAR));
request.setAttribute("selectedYear", selectedYear);
final Month selectedMonth = findMonthOrNull(getSelectedMonth(request));
if (Objects.nonNull(selectedMonth)) {
request.setAttribute("selectedMonth", selectedMonth);
}
request.setAttribute("months", months(Integer.parseInt(selectedYear), si));
}
use of uk.nhs.digital.website.beans.SupplementaryInformation in project hippo by NHS-digital-website.
the class DocumentUtilsTest method ordersByPublishedDateMostRecentFirst.
@Test
public void ordersByPublishedDateMostRecentFirst() {
final SupplementaryInformation supp1 = Mockito.mock(SupplementaryInformation.class);
final SupplementaryInformation supp2 = Mockito.mock(SupplementaryInformation.class);
final SupplementaryInformation supp3 = Mockito.mock(SupplementaryInformation.class);
given(supp1.getPublishedDate()).willReturn(new GregorianCalendar(2019, Calendar.JANUARY, 10));
given(supp2.getPublishedDate()).willReturn(new GregorianCalendar(2020, Calendar.JANUARY, 10));
given(supp3.getPublishedDate()).willReturn(new GregorianCalendar(2019, Calendar.JANUARY, 11));
final List<SupplementaryInformation> sorted = DocumentUtils.getSortedSupplementaryInformation(Arrays.asList(supp1, supp2, supp3));
assertEquals(supp2, sorted.get(0));
assertEquals(supp3, sorted.get(1));
assertEquals(supp1, sorted.get(2));
}
Aggregations