@Test public void testConvertToCertificateEventDTOWithExtendedMessage() { IntygContentHolder intygContentHolder = getIntygContentHolder(); when(intygService.fetchIntygDataForInternalUse(anyString(), anyBoolean())).thenReturn(intygContentHolder); when(intygService.getIntygTypeInfo(PARENT_CERTIFICATE_ID)).thenReturn(new IntygTypeInfo(PARENT_CERTIFICATE_ID, "type", "version")); CertificateEvent event = new CertificateEvent(); event.setCertificateId(CERTIFICATE_ID); event.setEventCode(EventCode.ERSATTER); CertificateEventDTO dto = converter.convertToCertificateEventDTO(event); verify(intygService).fetchIntygDataForInternalUse(anyString(), anyBoolean()); verify(intygService).getIntygTypeInfo(anyString()); assertNotNull(dto); assertEquals(CERTIFICATE_ID, dto.getCertificateId()); assertEquals(EventCode.ERSATTER, dto.getEventCode()); assertNotNull(dto.getExtendedMessage()); assertNotNull(dto.getExtendedMessage().getOriginalCertificateType()); }
public CertificateEventDTO convertToCertificateEventDTO(CertificateEvent event) { CertificateEventDTO eventDto = new CertificateEventDTO(event); if (event.getEventCode() == EventCode.ERSATTER || event.getEventCode() == EventCode.FORLANGER || event.getEventCode() == EventCode.SKAPATFRAN || event.getEventCode() == EventCode.KOPIERATFRAN || event.getEventCode() == EventCode.KOMPLETTERAR) { Optional<ExtendedEventMessage> dataForExtendedMessage = getDataForExtendedMessage(event); dataForExtendedMessage.ifPresent(message -> eventDto.setExtendedMessage(message)); } return eventDto; }
CertificateEventConverter { public CertificateEventDTO convertToCertificateEventDTO(CertificateEvent event) { CertificateEventDTO eventDto = new CertificateEventDTO(event); if (event.getEventCode() == EventCode.ERSATTER || event.getEventCode() == EventCode.FORLANGER || event.getEventCode() == EventCode.SKAPATFRAN || event.getEventCode() == EventCode.KOPIERATFRAN || event.getEventCode() == EventCode.KOMPLETTERAR) { Optional<ExtendedEventMessage> dataForExtendedMessage = getDataForExtendedMessage(event); dataForExtendedMessage.ifPresent(message -> eventDto.setExtendedMessage(message)); } return eventDto; } }
CertificateEventConverter { public CertificateEventDTO convertToCertificateEventDTO(CertificateEvent event) { CertificateEventDTO eventDto = new CertificateEventDTO(event); if (event.getEventCode() == EventCode.ERSATTER || event.getEventCode() == EventCode.FORLANGER || event.getEventCode() == EventCode.SKAPATFRAN || event.getEventCode() == EventCode.KOPIERATFRAN || event.getEventCode() == EventCode.KOMPLETTERAR) { Optional<ExtendedEventMessage> dataForExtendedMessage = getDataForExtendedMessage(event); dataForExtendedMessage.ifPresent(message -> eventDto.setExtendedMessage(message)); } return eventDto; }  }
CertificateEventConverter { public CertificateEventDTO convertToCertificateEventDTO(CertificateEvent event) { CertificateEventDTO eventDto = new CertificateEventDTO(event); if (event.getEventCode() == EventCode.ERSATTER || event.getEventCode() == EventCode.FORLANGER || event.getEventCode() == EventCode.SKAPATFRAN || event.getEventCode() == EventCode.KOPIERATFRAN || event.getEventCode() == EventCode.KOMPLETTERAR) { Optional<ExtendedEventMessage> dataForExtendedMessage = getDataForExtendedMessage(event); dataForExtendedMessage.ifPresent(message -> eventDto.setExtendedMessage(message)); } return eventDto; }  CertificateEventDTO convertToCertificateEventDTO(CertificateEvent event); }
CertificateEventConverter { public CertificateEventDTO convertToCertificateEventDTO(CertificateEvent event) { CertificateEventDTO eventDto = new CertificateEventDTO(event); if (event.getEventCode() == EventCode.ERSATTER || event.getEventCode() == EventCode.FORLANGER || event.getEventCode() == EventCode.SKAPATFRAN || event.getEventCode() == EventCode.KOPIERATFRAN || event.getEventCode() == EventCode.KOMPLETTERAR) { Optional<ExtendedEventMessage> dataForExtendedMessage = getDataForExtendedMessage(event); dataForExtendedMessage.ifPresent(message -> eventDto.setExtendedMessage(message)); } return eventDto; }  CertificateEventDTO convertToCertificateEventDTO(CertificateEvent event);  }