Commit d81a0f64 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

handle situation with empty zip-entries list

parent 2f4dd7d2
......@@ -284,6 +284,9 @@ public class ProjectController extends BaseController {
@RequestParam Map<String, Object> body,
@PathVariable(value = "projectId") String projectId) throws IOException, QueryException, SecurityException {
fixFormUrlEncodedBody(body);
if (Objects.equals(body.get("zip-entries"), "")) {
body.remove("zip-entries");
}
CreateProjectDTO data = objectMapper.readValue(objectMapper.writeValueAsString(body), CreateProjectDTO.class);
if (projectId.equals("*")) {
......
......@@ -573,14 +573,52 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest
.content(body)
.session(createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD));
String content = mockMvc.perform(request).andExpect(status().is2xxSuccessful())
mockMvc.perform(request).andExpect(status().is2xxSuccessful())
.andDo(document("projects/project_data/create_simple",
projectPathParameters(),
createProjectRequestSnippet(),
snippets.getProjectSnippet()));
} finally {
waitForProjectToFinishLoading(TEST_PROJECT);
}
}
@Test
public void addProjectWithEmptyZipEntries() throws Exception {
User admin = userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN);
try {
UploadedFileEntry fileEntry = createFileInSeparateThread(
new String(Files.readAllBytes(Paths.get("./src/test/resources/generic.xml")), "UTF-8"),
admin);
String body = EntityUtils.toString(new UrlEncodedFormEntity(Arrays.asList(
new BasicNameValuePair("projectId", TEST_PROJECT),
new BasicNameValuePair("name", "New Disease Map"),
new BasicNameValuePair("file-id", String.valueOf(fileEntry.getId())),
new BasicNameValuePair("mapCanvasType", "OPEN_LAYERS"),
new BasicNameValuePair("cache", "false"),
new BasicNameValuePair("description", "this is my awesome project"),
new BasicNameValuePair("notify-email", "notify.me@uni.lu"),
new BasicNameValuePair("disease", "D010300"),
new BasicNameValuePair("organism", "9606"),
new BasicNameValuePair("sbgn", "false"),
new BasicNameValuePair("version", "0.0.1"),
new BasicNameValuePair("annotate", "false"),
new BasicNameValuePair("verify-annotations", "false"),
new BasicNameValuePair("zip-entries", ""),
new BasicNameValuePair("parser", "lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser"))));
snippets.getProjectSnippet()))
.andReturn().getResponse().getContentAsString();
logger.debug(content);
RequestBuilder request = post("/api/projects/{projectId}/", TEST_PROJECT)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.content(body)
.session(createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD));
mockMvc.perform(request).andExpect(status().is2xxSuccessful())
.andDo(document("projects/project_data/create_simple",
projectPathParameters(),
createProjectRequestSnippet(),
snippets.getProjectSnippet()));
} finally {
waitForProjectToFinishLoading(TEST_PROJECT);
......
Markdown is supported
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