Commit 69f86899 authored by Matija Obreza's avatar Matija Obreza
Browse files

PDF: Accept entity IDs as request body, not over querystring

parent 85067f90
......@@ -23,8 +23,6 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import com.querydsl.core.types.OrderSpecifier;
import io.swagger.v3.oas.annotations.Parameter;
import org.apache.commons.lang3.ArrayUtils;
import org.genesys.blocks.model.EmptyModel;
import org.genesys.filerepository.InvalidRepositoryPathException;
......@@ -47,8 +45,10 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.querydsl.core.types.OrderSpecifier;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.RequestParam;
import io.swagger.v3.oas.annotations.Parameter;
/**
* A basic API controller for CRUD operations
......@@ -202,8 +202,8 @@ public abstract class CRUDController<E extends EmptyModel, S extends CRUDService
* Generate report from template for entities.
*/
@PostMapping(value = "/report/generate/{reportTemplate}")
@Operation(description = "Generate report by template", summary = "report by template")
public void generateReport(@PathVariable String reportTemplate, @RequestParam(value = "entityIds") Set<Long> entityIds, HttpServletResponse response) throws Exception {
@Operation(description = "Generate report by template", summary = "Generate PDF")
public void generateReport(@PathVariable String reportTemplate, @RequestBody Set<Long> entityIds, HttpServletResponse response) throws Exception {
crudService.generateReport(reportTemplate, entityIds, response);
}
......
......@@ -681,7 +681,10 @@ public class CropControllerTest extends AbstractApiV1Test {
assertThat(crop.getId(), is(notNullValue()));
mockMvc
.perform(post(CropController.API_URL.concat("/report/generate/{reportTemplate}?entityIds={id}"), "cropReport.jrxml", crop.getId()))
.perform(post(CropController.API_URL.concat("/report/generate/{reportTemplate}"), "cropReport.jrxml")
.contentType(MediaType.APPLICATION_JSON)
.content("[" + crop.getId() + "]")
)
// .andDo(org.springframework.test.web.servlet.result.MockMvcResultHandlers.print())
.andExpect(status().isNotFound());
......@@ -691,7 +694,10 @@ public class CropControllerTest extends AbstractApiV1Test {
}
mockMvc
.perform(post(CropController.API_URL.concat("/report/generate/{reportTemplate}?entityIds={id}"), "cropReport.jrxml", crop.getId()))
.perform(post(CropController.API_URL.concat("/report/generate/{reportTemplate}"), "cropReport.jrxml")
.contentType(MediaType.APPLICATION_JSON)
.content("[" + crop.getId() + "]")
)
// .andDo(org.springframework.test.web.servlet.result.MockMvcResultHandlers.print())
.andExpect(status().is5xxServerError());
......@@ -700,7 +706,10 @@ public class CropControllerTest extends AbstractApiV1Test {
}
mockMvc
.perform(post(CropController.API_URL.concat("/report/generate/{reportTemplate}?entityIds={id}"), "cropReport.jrxml", crop.getId()))
.perform(post(CropController.API_URL.concat("/report/generate/{reportTemplate}"), "cropReport.jrxml")
.contentType(MediaType.APPLICATION_JSON)
.content("[" + crop.getId() + "]")
)
// .andDo(org.springframework.test.web.servlet.result.MockMvcResultHandlers.print())
.andExpect(status().is5xxServerError());
......@@ -731,7 +740,10 @@ public class CropControllerTest extends AbstractApiV1Test {
/*@formatter:off*/
// var mvcResult = mockMvc
mockMvc
.perform(post(CropController.API_URL.concat("/report/generate/{reportTemplate}?entityIds={id}"), "cropReport.jrxml", crop.getId()))
.perform(post(CropController.API_URL.concat("/report/generate/{reportTemplate}"), "cropReport.jrxml")
.contentType(MediaType.APPLICATION_JSON)
.content("[" + crop.getId() + "]")
)
// .andDo(org.springframework.test.web.servlet.result.MockMvcResultHandlers.print())
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_PDF))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment