package com.epam.ta.reportportal.ws.converter.converters;

import com.epam.ta.reportportal.entity.Activity;
import com.epam.ta.reportportal.ws.model.ActivityResource;

import java.sql.Date;
import java.time.ZoneId;
import java.util.function.Function;

public final class ActivityConverter {

	private ActivityConverter() {
		//static only
	}

	public static final Function<Activity, ActivityResource> TO_RESOURCE = activity -> {
		ActivityResource resource = new ActivityResource();
		resource.setActivityId(activity.getId().toString());
		resource.setLastModifiedDate(Date.from(activity.getCreatedAt().atZone(ZoneId.systemDefault()).toInstant()));
		resource.setObjectType(activity.getEntity().name());
		resource.setActionType(activity.getAction());
		resource.setProjectRef(activity.getProjectId().toString());
		resource.setUserRef(activity.getUserId().toString());
		resource.setLoggedObjectRef(activity.getObjectId().toString());
		resource.setDetails(activity.getDetails());
		return resource;
	};
}
@@ -177,77 +177,99 @@
 ava.
-sql.Date
+util.function.Function
 ;%0A
+%0A
 import 
-java.time.ZoneId;%0Aimport java.util.function.Function
+static com.epam.ta.reportportal.commons.EntityUtils.TO_DATE
 ;%0A%0Ap
@@ -588,17 +588,21 @@
 ate(
-Date.from
+TO_DATE.apply
 (act
@@ -625,51 +625,8 @@
 At()
-.atZone(ZoneId.systemDefault()).toInstant()
 ));%0A
@@ -662,22 +662,34 @@
 vity.get
+Activity
 Entity
+Type
 ().name(

Use converter from the EntityUtils