SubscriptionMapper { public Subscription convert(SubscriptionEntity subscriptionEntity) { final Subscription subscriptionItem = new Subscription(); subscriptionItem.setId(subscriptionEntity.getId()); subscriptionItem.setApi(subscriptionEntity.getApi()); subscriptionItem.setApplication(subscriptionEntity.getApplication()); subscriptionItem.setCreatedAt(getDate(subscriptionEntity.getCreatedAt())); subscriptionItem.setEndAt(getDate(subscriptionEntity.getEndingAt())); subscriptionItem.setProcessedAt(getDate(subscriptionEntity.getProcessedAt())); subscriptionItem.setStartAt(getDate(subscriptionEntity.getStartingAt())); subscriptionItem.setPausedAt(getDate(subscriptionEntity.getPausedAt())); subscriptionItem.setClosedAt(getDate(subscriptionEntity.getClosedAt())); subscriptionItem.setPausedAt(getDate(subscriptionEntity.getPausedAt())); subscriptionItem.setPlan(subscriptionEntity.getPlan()); subscriptionItem.setRequest(subscriptionEntity.getRequest()); subscriptionItem.setReason(subscriptionEntity.getReason()); subscriptionItem.setStatus(Subscription.StatusEnum.fromValue(subscriptionEntity.getStatus().name())); subscriptionItem.setSubscribedBy(subscriptionEntity.getSubscribedBy()); return subscriptionItem; }  Subscription convert(SubscriptionEntity subscriptionEntity);  }
@Test public void testConvert() { Instant now = Instant.now(); Date nowDate = Date.from(now); subscriptionEntity = new SubscriptionEntity(); subscriptionEntity.setApi(SUBSCRIPTION_API); subscriptionEntity.setApplication(SUBSCRIPTION_APPLICATION); subscriptionEntity.setClientId(SUBSCRIPTION_CLIENT_ID); subscriptionEntity.setClosedAt(nowDate); subscriptionEntity.setCreatedAt(nowDate); subscriptionEntity.setEndingAt(nowDate); subscriptionEntity.setId(SUBSCRIPTION_ID); subscriptionEntity.setPausedAt(nowDate); subscriptionEntity.setPlan(SUBSCRIPTION_PLAN); subscriptionEntity.setProcessedAt(nowDate); subscriptionEntity.setProcessedBy(SUBSCRIPTION_PROCESSED_BY); subscriptionEntity.setReason(SUBSCRIPTION_REASON); subscriptionEntity.setRequest(SUBSCRIPTION_REQUEST); subscriptionEntity.setStartingAt(nowDate); subscriptionEntity.setStatus(SubscriptionStatus.ACCEPTED); subscriptionEntity.setSubscribedBy(SUBSCRIPTION_SUBSCRIBED_BY); subscriptionEntity.setUpdatedAt(nowDate); Subscription subscription = subscriptionMapper.convert(subscriptionEntity); assertNotNull(subscription); assertEquals(SUBSCRIPTION_API, subscription.getApi()); assertEquals(SUBSCRIPTION_APPLICATION, subscription.getApplication()); assertEquals(now.toEpochMilli(), subscription.getCreatedAt().toInstant().toEpochMilli()); assertEquals(now.toEpochMilli(), subscription.getEndAt().toInstant().toEpochMilli()); assertEquals(SUBSCRIPTION_ID, subscription.getId()); assertEquals(SUBSCRIPTION_PLAN, subscription.getPlan()); assertEquals(now.toEpochMilli(), subscription.getProcessedAt().toInstant().toEpochMilli()); assertEquals(SUBSCRIPTION_REQUEST, subscription.getRequest()); assertEquals(now.toEpochMilli(), subscription.getStartAt().toInstant().toEpochMilli()); assertEquals(StatusEnum.ACCEPTED, subscription.getStatus()); }