use of com.epam.ta.reportportal.entity.activity.ActivityAction in project service-api by reportportal.
the class ActivityBuilderTest method activityBuilderTest.
@Test
void activityBuilderTest() {
final ActivityAction action = FINISH_LAUNCH;
final Activity.ActivityEntityType entity = LAUNCH;
final String objectName = "objectName";
final Long projectId = 1L;
final Long userId = 2L;
final String username = "username";
final LocalDateTime localDateTime = LocalDateTime.of(2019, 2, 6, 18, 25);
final Long objectId = 3L;
Activity activity = new ActivityBuilder().addAction(action).addActivityEntityType(entity).addObjectName(objectName).addProjectId(projectId).addUserId(userId).addObjectId(objectId).addUserName(username).addCreatedAt(localDateTime).addHistoryField("field", "before", "after").get();
assertEquals(action.getValue(), activity.getAction());
assertEquals(entity.getValue(), activity.getActivityEntityType());
assertEquals(objectName, activity.getDetails().getObjectName());
assertEquals(projectId, activity.getProjectId());
assertEquals(userId, activity.getUserId());
assertEquals(objectId, activity.getObjectId());
assertEquals(username, activity.getUsername());
assertEquals(localDateTime, activity.getCreatedAt());
}
use of com.epam.ta.reportportal.entity.activity.ActivityAction in project service-api by reportportal.
the class GetProjectInfoHandlerImpl method getActivities.
private Map<String, List<ActivityResource>> getActivities(Project project, InfoInterval infoInterval) {
String value = Arrays.stream(ActivityAction.values()).filter(not(ACTIVITIES_PROJECT_FILTER)).map(ActivityAction::getValue).collect(joining(","));
Filter filter = new Filter(Activity.class, Lists.newArrayList(new FilterCondition(IN, false, value, CRITERIA_ACTION), new FilterCondition(EQUALS, false, String.valueOf(project.getId()), CRITERIA_PROJECT_ID), new FilterCondition(GREATER_THAN_OR_EQUALS, false, String.valueOf(Timestamp.valueOf(getStartIntervalDate(infoInterval)).getTime()), CRITERIA_CREATION_DATE)));
List<Activity> activities = activityRepository.findByFilter(filter, PageRequest.of(0, LIMIT, Sort.by(Sort.Direction.DESC, CRITERIA_CREATION_DATE))).getContent();
Map<Long, String> userIdLoginMapping = userRepository.findAllById(activities.stream().filter(a -> a.getUserId() != null).map(Activity::getUserId).collect(Collectors.toSet())).stream().collect(toMap(User::getId, User::getLogin));
return Collections.singletonMap(RESULT, activities.stream().map(a -> ofNullable(a.getUserId()).map(userId -> TO_RESOURCE_WITH_USER.apply(a, userIdLoginMapping.get(userId))).orElseGet(() -> TO_RESOURCE.apply(a))).peek(resource -> resource.setProjectName(project.getName())).collect(toList()));
}
Aggregations