use of se.riv.clinicalprocess.healthcond.certificate.v3.IntygsStatus in project webcert by sklintyg.
the class IntygDraftsConverterTest method testFindLatestStatus.
@Test
public void testFindLatestStatus() {
LocalDateTime defaultTime = LocalDateTime.now();
CertificateState res;
List<IntygsStatus> statuses;
// test with empty list
statuses = new ArrayList<>();
res = IntygDraftsConverter.findLatestStatus(statuses);
assertEquals(CertificateState.UNHANDLED, res);
// test with just some statuses
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);
// test with DELETED in the list, which should be removed
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);
// test with DELETED and RESTORED in the list, which should be removed
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);
// test with just DELETED, which will be removed and result in an empty list
statuses = new ArrayList<>();
statuses.add(buildIntygsStatus(StatusKod.DELETE.name(), defaultTime.minusHours(1)));
res = IntygDraftsConverter.findLatestStatus(statuses);
assertEquals(CertificateState.UNHANDLED, res);
}
use of se.riv.clinicalprocess.healthcond.certificate.v3.IntygsStatus in project webcert by sklintyg.
the class IntygDraftsConverterTest method buildIntygsStatus.
private IntygsStatus buildIntygsStatus(String statuskod, LocalDateTime timestamp) {
IntygsStatus status = new IntygsStatus();
status.setStatus(new Statuskod());
status.getStatus().setCode(statuskod);
status.setTidpunkt(timestamp);
return status;
}
Aggregations