Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-87433 || Add missed filename for attachment record mapper #956

Merged
merged 9 commits into from
Nov 27, 2023
85 changes: 43 additions & 42 deletions src/main/java/com/epam/ta/reportportal/dao/util/RecordMappers.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
*/
public class RecordMappers {

private static final ObjectMapper objectMapper;
private static final ObjectMapper objectMapper;

static {
objectMapper = new ObjectMapper();
Expand Down Expand Up @@ -220,6 +220,7 @@ public class RecordMappers {
attachment.setProjectId(r.get(ATTACHMENT.PROJECT_ID));
attachment.setLaunchId(r.get(ATTACHMENT.LAUNCH_ID));
attachment.setItemId(r.get(ATTACHMENT.ITEM_ID));
attachment.setFileName(r.get(ATTACHMENT.FILE_NAME));

return attachment;
}).orElse(null);
Expand Down Expand Up @@ -323,8 +324,8 @@ public class RecordMappers {
);

/**
* Maps record into {@link PatternTemplate} object (only {@link PatternTemplate#id} and
* {@link PatternTemplate#name} fields)
* Maps record into {@link PatternTemplate} object (only {@link PatternTemplate#id} and {@link
* PatternTemplate#name} fields)
*/
public static final Function<? super Record, Optional<PatternTemplate>> PATTERN_TEMPLATE_NAME_RECORD_MAPPER = r -> ofNullable(
r.get(
Expand Down Expand Up @@ -409,45 +410,45 @@ public class RecordMappers {
return new ReportPortalUser.ProjectDetails(projectId, projectName, projectRole);
};

public static final RecordMapper<? super Record, Activity> ACTIVITY_MAPPER = r -> {
Activity activity = new Activity();
activity.setId(r.get(ACTIVITY.ID));
activity.setCreatedAt(r.get(ACTIVITY.CREATED_AT, LocalDateTime.class));
activity.setAction(EventAction.valueOf(r.get(ACTIVITY.ACTION)));
activity.setEventName(r.get(ACTIVITY.EVENT_NAME));
activity.setPriority(EventPriority.valueOf(r.get(ACTIVITY.PRIORITY)));
activity.setObjectId(r.get(ACTIVITY.OBJECT_ID));
activity.setObjectName(r.get(ACTIVITY.OBJECT_NAME));
activity.setObjectType(EventObject.valueOf(r.get(ACTIVITY.OBJECT_TYPE)));
activity.setProjectId(r.get(ACTIVITY.PROJECT_ID));
activity.setProjectName(r.get(PROJECT.NAME));
String detailsJson = r.get(ACTIVITY.DETAILS, String.class);
ofNullable(detailsJson).ifPresent(s -> {
try {
ActivityDetails details = objectMapper.readValue(s, ActivityDetails.class);
activity.setDetails(details);
} catch (IOException e) {
throw new ReportPortalException(ErrorType.UNCLASSIFIED_REPORT_PORTAL_ERROR);
}
});
activity.setSubjectId(r.get(ACTIVITY.SUBJECT_ID));
activity.setSubjectName(ofNullable(r.get(USERS.LOGIN)).orElse(r.get(ACTIVITY.SUBJECT_NAME)));
activity.setSubjectType(EventSubject.valueOf(r.get(ACTIVITY.SUBJECT_TYPE)));
return activity;
};

public static final RecordMapper<? super Record, OwnedEntity> OWNED_ENTITY_RECORD_MAPPER = r -> r.into(
OwnedEntity.class);

private static final BiConsumer<Widget, ? super Record> WIDGET_USER_FILTER_MAPPER = (widget, res) -> ofNullable(
res.get(FILTER.ID)).ifPresent(
id -> {
Set<UserFilter> filters = ofNullable(widget.getFilters()).orElseGet(Sets::newLinkedHashSet);
UserFilter filter = new UserFilter();
filter.setId(id);
filters.add(filter);
widget.setFilters(filters);
});
public static final RecordMapper<? super Record, Activity> ACTIVITY_MAPPER = r -> {
Activity activity = new Activity();
activity.setId(r.get(ACTIVITY.ID));
activity.setCreatedAt(r.get(ACTIVITY.CREATED_AT, LocalDateTime.class));
activity.setAction(EventAction.valueOf(r.get(ACTIVITY.ACTION)));
activity.setEventName(r.get(ACTIVITY.EVENT_NAME));
activity.setPriority(EventPriority.valueOf(r.get(ACTIVITY.PRIORITY)));
activity.setObjectId(r.get(ACTIVITY.OBJECT_ID));
activity.setObjectName(r.get(ACTIVITY.OBJECT_NAME));
activity.setObjectType(EventObject.valueOf(r.get(ACTIVITY.OBJECT_TYPE)));
activity.setProjectId(r.get(ACTIVITY.PROJECT_ID));
activity.setProjectName(r.get(PROJECT.NAME));
String detailsJson = r.get(ACTIVITY.DETAILS, String.class);
ofNullable(detailsJson).ifPresent(s -> {
try {
ActivityDetails details = objectMapper.readValue(s, ActivityDetails.class);
activity.setDetails(details);
} catch (IOException e) {
throw new ReportPortalException(ErrorType.UNCLASSIFIED_REPORT_PORTAL_ERROR);
}
});
activity.setSubjectId(r.get(ACTIVITY.SUBJECT_ID));
activity.setSubjectName(ofNullable(r.get(USERS.LOGIN)).orElse(r.get(ACTIVITY.SUBJECT_NAME)));
activity.setSubjectType(EventSubject.valueOf(r.get(ACTIVITY.SUBJECT_TYPE)));
return activity;
};

public static final RecordMapper<? super Record, OwnedEntity> OWNED_ENTITY_RECORD_MAPPER = r -> r.into(
OwnedEntity.class);

private static final BiConsumer<Widget, ? super Record> WIDGET_USER_FILTER_MAPPER = (widget, res) -> ofNullable(
res.get(FILTER.ID)).ifPresent(
id -> {
Set<UserFilter> filters = ofNullable(widget.getFilters()).orElseGet(Sets::newLinkedHashSet);
UserFilter filter = new UserFilter();
filter.setId(id);
filters.add(filter);
widget.setFilters(filters);
});

private static final BiConsumer<Widget, ? super Record> WIDGET_OPTIONS_MAPPER = (widget, res) -> {
ofNullable(res.get(WIDGET.WIDGET_OPTIONS, String.class)).ifPresent(wo -> {
Expand Down
Loading