@Test public void testFindLatestStatus() { LocalDateTime defaultTime = LocalDateTime.now(); CertificateState res; List<IntygsStatus> statuses; statuses = new ArrayList<>(); res = IntygDraftsConverter.findLatestStatus(statuses); assertEquals(CertificateState.UNHANDLED, res); statuses = new ArrayList<>(); statuses.add(buildIntygsStatus(StatusKod.RECEIV.name(), defaultTime.minusHours(2))); statuses.add(buildIntygsStatus(StatusKod.SENTTO.name(), defaultTime.minusHours(1))); res = IntygDraftsConverter.findLatestStatus(statuses); assertEquals(CertificateState.SENT, res); statuses = new ArrayList<>(); statuses.add(buildIntygsStatus(StatusKod.CANCEL.name(), defaultTime.minusHours(2))); statuses.add(buildIntygsStatus(StatusKod.SENTTO.name(), defaultTime.minusHours(3))); statuses.add(buildIntygsStatus(StatusKod.DELETE.name(), defaultTime.minusHours(1))); statuses.add(buildIntygsStatus(StatusKod.RECEIV.name(), defaultTime.minusHours(4))); res = IntygDraftsConverter.findLatestStatus(statuses); assertEquals(CertificateState.CANCELLED, res); statuses = new ArrayList<>(); statuses.add(buildIntygsStatus(StatusKod.CANCEL.name(), defaultTime.minusHours(2))); statuses.add(buildIntygsStatus(StatusKod.SENTTO.name(), defaultTime.minusHours(3))); statuses.add(buildIntygsStatus(StatusKod.RESTOR.name(), defaultTime.minusMinutes(30))); statuses.add(buildIntygsStatus(StatusKod.DELETE.name(), defaultTime.minusHours(1))); statuses.add(buildIntygsStatus(StatusKod.RECEIV.name(), defaultTime.minusHours(4))); res = IntygDraftsConverter.findLatestStatus(statuses); assertEquals(CertificateState.CANCELLED, res); statuses = new ArrayList<>(); statuses.add(buildIntygsStatus(StatusKod.DELETE.name(), defaultTime.minusHours(1))); res = IntygDraftsConverter.findLatestStatus(statuses); assertEquals(CertificateState.UNHANDLED, res); }
public static CertificateState findLatestStatus(List<IntygsStatus> intygStatuses) { return intygStatuses.stream() .filter(s -> !ARCHIVED_STATUSES.contains(s.getStatus().getCode())) .max(INTYG_STATUS_COMPARATOR) .map(s -> StatusKod.valueOf(s.getStatus().getCode()).toCertificateState()) .orElse(CertificateState.UNHANDLED); }
IntygDraftsConverter { public static CertificateState findLatestStatus(List<IntygsStatus> intygStatuses) { return intygStatuses.stream() .filter(s -> !ARCHIVED_STATUSES.contains(s.getStatus().getCode())) .max(INTYG_STATUS_COMPARATOR) .map(s -> StatusKod.valueOf(s.getStatus().getCode()).toCertificateState()) .orElse(CertificateState.UNHANDLED); } }
IntygDraftsConverter { public static CertificateState findLatestStatus(List<IntygsStatus> intygStatuses) { return intygStatuses.stream() .filter(s -> !ARCHIVED_STATUSES.contains(s.getStatus().getCode())) .max(INTYG_STATUS_COMPARATOR) .map(s -> StatusKod.valueOf(s.getStatus().getCode()).toCertificateState()) .orElse(CertificateState.UNHANDLED); }  }
IntygDraftsConverter { public static CertificateState findLatestStatus(List<IntygsStatus> intygStatuses) { return intygStatuses.stream() .filter(s -> !ARCHIVED_STATUSES.contains(s.getStatus().getCode())) .max(INTYG_STATUS_COMPARATOR) .map(s -> StatusKod.valueOf(s.getStatus().getCode()).toCertificateState()) .orElse(CertificateState.UNHANDLED); }  static List<ListIntygEntry> merge(List<ListIntygEntry> intygList, List<Utkast> utkastList); static List<ListIntygEntry> convertUtkastsToListIntygEntries(List<Utkast> utkastList); static ListIntygEntry convertUtkastToListIntygEntry(Utkast utkast); static CertificateState findLatestStatus(List<IntygsStatus> intygStatuses); static String resolveStatus(Utkast draft); List<ListIntygEntry> convertIntygToListIntygEntries(List<Intyg> intygList, List<ListIntygEntry> webcertIntyg); }
IntygDraftsConverter { public static CertificateState findLatestStatus(List<IntygsStatus> intygStatuses) { return intygStatuses.stream() .filter(s -> !ARCHIVED_STATUSES.contains(s.getStatus().getCode())) .max(INTYG_STATUS_COMPARATOR) .map(s -> StatusKod.valueOf(s.getStatus().getCode()).toCertificateState()) .orElse(CertificateState.UNHANDLED); }  static List<ListIntygEntry> merge(List<ListIntygEntry> intygList, List<Utkast> utkastList); static List<ListIntygEntry> convertUtkastsToListIntygEntries(List<Utkast> utkastList); static ListIntygEntry convertUtkastToListIntygEntry(Utkast utkast); static CertificateState findLatestStatus(List<IntygsStatus> intygStatuses); static String resolveStatus(Utkast draft); List<ListIntygEntry> convertIntygToListIntygEntries(List<Intyg> intygList, List<ListIntygEntry> webcertIntyg);  }