PortalNotificationMapper { public PortalNotification convert(PortalNotificationEntity portalNotificationEntity) { final PortalNotification portalNotification = new PortalNotification(); portalNotification.setCreatedAt(portalNotificationEntity.getCreatedAt().toInstant().atOffset(ZoneOffset.UTC)); portalNotification.setId(portalNotificationEntity.getId()); portalNotification.setMessage(portalNotificationEntity.getMessage()); portalNotification.setTitle(portalNotificationEntity.getTitle()); return portalNotification; }  PortalNotification convert(PortalNotificationEntity portalNotificationEntity);  }
@Test public void testConvert() { Instant now = Instant.now(); Date nowDate = Date.from(now); PortalNotificationEntity portalNotificationEntity = new PortalNotificationEntity(); portalNotificationEntity.setCreatedAt(nowDate); portalNotificationEntity.setId(NOTIF_ID); portalNotificationEntity.setMessage(NOTIF_MESSAGE); portalNotificationEntity.setTitle(NOTIF_TITLE); PortalNotification responsePortalNotif = new PortalNotificationMapper().convert(portalNotificationEntity); assertNotNull(responsePortalNotif); assertEquals(NOTIF_ID, responsePortalNotif.getId()); assertEquals(NOTIF_MESSAGE, responsePortalNotif.getMessage()); assertEquals(NOTIF_TITLE, responsePortalNotif.getTitle()); assertEquals(now.toEpochMilli(), responsePortalNotif.getCreatedAt().toInstant().toEpochMilli()); }