Skip to content
Snippets Groups Projects
Commit e2d22859 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

allow java stacktrace in the report

parent ba0a2fb5
No related branches found
No related tags found
1 merge request!15Reports improvements
Pipeline #63517 passed
......@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.2.0] - 2022-07-23
### Improvement
- error report allows for Java stacktrace to be provided (#12)
## [1.1.0] - 2022-07-23
### Improvement
- frontend is provided by accessing data over API
......
......@@ -35,6 +35,9 @@ public class ErrorReport {
@Column(columnDefinition = "text")
private String stacktrace;
@Column(columnDefinition = "text")
private String javaStacktrace;
public String generateReport() {
final var NO_DATA = "Not provided by reporter";
var report = String.format("id: %s\n", id);
......@@ -46,6 +49,7 @@ public class ErrorReport {
report += String.format("version: %s\n", version == null ? NO_DATA : version);
report += String.format("comment: %s\n", comment == null ? NO_DATA : comment);
report += String.format("stacktrace: ```%s```\n", stacktrace == null ? NO_DATA : stacktrace);
report += String.format("Java stacktrace: ```%s```\n", javaStacktrace == null ? NO_DATA : javaStacktrace);
return report;
}
......@@ -120,4 +124,12 @@ public class ErrorReport {
public void setComment(final String comment) {
this.comment = comment;
}
public String getJavaStacktrace() {
return javaStacktrace;
}
public void setJavaStacktrace(final String javaStacktrace) {
this.javaStacktrace = javaStacktrace;
}
}
alter table error_report add column java_stacktrace varchar;
\ No newline at end of file
......@@ -26,7 +26,8 @@ public class Docs {
fieldWithPath("timestamp").description("timestamp").type(JsonFieldType.STRING).optional(),
fieldWithPath("version").description("minerva version").type(JsonFieldType.STRING),
fieldWithPath("comment").description("user comment").type(JsonFieldType.STRING).optional(),
fieldWithPath("stacktrace").description("JavaScript stacktrace").type(JsonFieldType.STRING));
fieldWithPath("stacktrace").description("JavaScript stacktrace").type(JsonFieldType.STRING),
fieldWithPath("javaStacktrace").description("Java stacktrace").type(JsonFieldType.STRING).optional());
}
public static Snippet getProjectControllerResponse() {
......@@ -44,10 +45,13 @@ public class Docs {
return Arrays.asList(fieldWithPath("id").description("machine id").type(JsonFieldType.NUMBER),
fieldWithPath("version").description("minerva version").type(JsonFieldType.STRING),
fieldWithPath("status").description("machine status").type(JsonFieldType.STRING),
fieldWithPath("authenticationToken").description("token that should be used when modyfing machine data").type(JsonFieldType.STRING)
fieldWithPath("authenticationToken").description("token that should be used when modyfing machine data")
.type(JsonFieldType.STRING)
.optional(),
fieldWithPath("statusUpdatedAt").description("timestamp when the status was last updated").type(JsonFieldType.STRING),
fieldWithPath("createdAt").description("timestamp when machine was registered in the net").type(JsonFieldType.STRING),
fieldWithPath("statusUpdatedAt").description("timestamp when the status was last updated")
.type(JsonFieldType.STRING),
fieldWithPath("createdAt").description("timestamp when machine was registered in the net")
.type(JsonFieldType.STRING),
fieldWithPath("rootUrl").description("root url of minerva installation").type(JsonFieldType.STRING));
}
......@@ -60,7 +64,8 @@ public class Docs {
.description("machine id"));
}
protected static Snippet getPageableWrapperPayload(final boolean ignoreInDocumentation, final List<FieldDescriptor> dataPayload) {
protected static Snippet getPageableWrapperPayload(final boolean ignoreInDocumentation,
final List<FieldDescriptor> dataPayload) {
List<FieldDescriptor> fields = Arrays.asList(fieldWithPath("isLastPage")
.description("is it the last page in pageable response")
.type(JsonFieldType.BOOLEAN),
......@@ -107,8 +112,10 @@ public class Docs {
fieldWithPath("organism").description("organism (taxonomy ID)").type(JsonFieldType.STRING),
fieldWithPath("disease").description("disease (mesh ID)").type(JsonFieldType.STRING),
fieldWithPath("status").description("project status").type(JsonFieldType.STRING),
fieldWithPath("statusUpdatedAt").description("timestamp when the status was last updated").type(JsonFieldType.STRING),
fieldWithPath("createdAt").description("timestamp when project was registered in the net").type(JsonFieldType.STRING),
fieldWithPath("statusUpdatedAt").description("timestamp when the status was last updated")
.type(JsonFieldType.STRING),
fieldWithPath("createdAt").description("timestamp when project was registered in the net")
.type(JsonFieldType.STRING),
subsectionWithPath("machine").description("machine where project is located"));
}
......
package lu.uni.lcsb.minerva.net.controller;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post;
......@@ -51,6 +52,13 @@ class ReportControllerTest extends AControllerTest {
+ "at initMap (https://www.vmh.life/minerva/index.xhtml?id=ReconMap-3&search=gthrd[m]&drugSearch=Glutathione&x=34209&y=30126&zoom=8&:41:20)\n"
+ "at onload (https://www.vmh.life/minerva/index.xhtml?id=ReconMap-3&search=gthrd[m]&drugSearch=Glutathione&x=34209&y=30126&zoom=8&:52:45)";
private static final String SAMPLE_JAVA_STACKTRACE = "java.lang.Exception\n"
+ " at lu.uni.lcsb.minerva.net.controller.ReportControllerTest.createReportWithJavaStacktrace(ReportControllerTest.java:190)\n"
+ " at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n"
+ " at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n"
+ " at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n"
+ " at java.base/java.lang.reflect.Method.invoke(Method.java:566)\n"
+ "";
@Autowired
protected ObjectMapper objectMapper;
......@@ -165,4 +173,27 @@ class ReportControllerTest extends AControllerTest {
.andExpect(status().isBadRequest());
}
@Test
void createReportWithJavaStacktrace() throws Exception {
ErrorReport testReport = new ErrorReport();
testReport.setVersion("13.0.0");
testReport.setStacktrace(SAMPLE_JS_STACKTRACE);
testReport.setJavaStacktrace(SAMPLE_JAVA_STACKTRACE);
testReport.setId(-1);
var request = post("/api/reports")
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(testReport));
String response = mockMvc.perform(request)
.andExpect(status().is2xxSuccessful())
.andReturn().getResponse().getContentAsString();
ErrorReport report = objectMapper.readValue(response, new TypeReference<ErrorReport>() {
});
assertTrue(report.getId() > 0);
assertEquals(SAMPLE_JAVA_STACKTRACE, report.getJavaStacktrace());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment