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-99152 spring boot 3 support #12

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ name=plugin-import-robot
version=1.0.1
description=Reinforce your ReportPortal instance with RobotFramework Import functionality and easily upload your log files right to ReportPortal.
pluginId=RobotFramework
lombokVersion=1.18.30
lombokVersion=1.18.36

springBootVersion=3.4.2
15 changes: 7 additions & 8 deletions plugin-robot/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "io.spring.dependency-management" version "1.1.4"
id "io.spring.dependency-management" version "1.1.7"
id 'java'
id 'jacoco'
id "com.github.node-gradle.node" version "2.2.1"
Expand Down Expand Up @@ -39,21 +39,20 @@ dependencyManagement {
}
}

ext['spring-boot.version'] = "${springBootVersion}"

dependencies {
if (releaseMode) {
implementation 'com.epam.reportportal:commons-dao'
implementation 'com.epam.reportportal:commons'
implementation 'com.epam.reportportal:plugin-api'
annotationProcessor 'com.epam.reportportal:plugin-api'
} else {
implementation 'com.github.reportportal:commons-dao:a98c172'
implementation 'com.github.reportportal:commons:develop-SNAPSHOT'
implementation 'com.github.reportportal:plugin-api:develop-SNAPSHOT'
annotationProcessor 'com.github.reportportal:plugin-api:develop-SNAPSHOT'
implementation 'com.github.reportportal:commons-dao:11fa2a6'
implementation 'com.github.reportportal:plugin-api:8874441'
annotationProcessor 'com.github.reportportal:plugin-api:8874441'
}
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.7'
implementation 'org.hibernate:hibernate-core:5.6.15.Final'

implementation "org.springframework:spring-test"
// add lombok support
compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import jakarta.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
import javax.annotation.PostConstruct;
import org.pf4j.Extension;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import com.google.common.collect.Lists;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.time.Instant;
import java.util.ArrayDeque;
import java.util.ArrayList;
Expand All @@ -69,12 +68,11 @@
import javax.xml.parsers.DocumentBuilder;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.fileupload.disk.DiskFileItem;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.http.MediaTypeFactory;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -380,22 +378,12 @@ private MultipartFile getImageMultipartFile(String msg) {
Matcher matcher = IMG_REGEX.matcher(msg);
if (matcher.find() && zipFile != null) {
String imgName = matcher.group(1);
return findScreenshot(imgName).map(screen -> {
DiskFileItem fileItem = new DiskFileItem("file", screen.getContentType(), false,
screen.getName(),
screen.getContent().length, null);
try (OutputStream os = fileItem.getOutputStream()) {
os.write(screen.getContent());
} catch (IOException e) {
log.error(e.getMessage());
}
return fileItem;
}).map(CommonsMultipartFile::new).orElse(null);
return findScreenshot(imgName).orElse(null);
}
return null;
}

private Optional<SaveLogRQ.File> findScreenshot(String imgName) {
private Optional<MultipartFile> findScreenshot(String imgName) {
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
Expand All @@ -405,10 +393,10 @@ private Optional<SaveLogRQ.File> findScreenshot(String imgName) {
SUPPORTED_IMAGE_CONTENT_TYPES.contains(
MediaTypeFactory.getMediaType(entry.getName()).get().toString())) {
try (InputStream inputStream = zipFile.getInputStream(entry)) {
final SaveLogRQ.File file = new SaveLogRQ.File();
file.setName(entry.getName());
file.setContentType(MediaTypeFactory.getMediaType(entry.getName()).get().toString());
file.setContent(inputStream.readAllBytes());
MultipartFile file = new MockMultipartFile("file",
entry.getName(),
MediaTypeFactory.getMediaType(entry.getName()).get().toString(),
inputStream.readAllBytes());
return Optional.of(file);
} catch (IOException e) {
log.error(e.getMessage());
Expand Down