@@ -10820,11 +10820,10 @@ public void uploadAndReplaceTest() throws Exception {
1082010820 context.restoreAuthSystemState();
1082110821
1082210822 String token = getAuthToken(admin.getEmail(), password);
10823- int oldFileIndex = 0;
1082410823 // Upload new file, to replace old one
1082510824 getClient(token).perform(multipart("/api/submission/workspaceitems/" + workspaceItem.getID())
1082610825 .file(newFile)
10827- .param("replaceFile", Integer. toString(oldFileIndex ))
10826+ .param("replaceFile", originalBitstream.getID(). toString())
1082810827 .param("replaceName", "true"))
1082910828 .andExpect(status().isCreated())
1083010829 .andExpect(jsonPath("$.sections.upload.files[0].metadata['dc.title'][0].value",
@@ -10890,16 +10889,10 @@ public void uploadAndReplaceBadParamTest() throws Exception {
1089010889 .file(newFile)
1089110890 .param("replaceFile", bitstream.getName()))
1089210891 .andExpect(status().isBadRequest());
10893- // UUID is not supported
10894- getClient(token).perform(multipart("/api/submission/workspaceitems/" + workspaceItem.getID())
10895- .file(newFile)
10896- .param("replaceFile", bitstream.getID().toString()))
10897- .andExpect(status().isBadRequest());
10898- // Parameter cannot be out of bounds
10899- int fileIndexOutOfBounds = 1;
10892+ // Integer is not supported
1090010893 getClient(token).perform(multipart("/api/submission/workspaceitems/" + workspaceItem.getID())
1090110894 .file(newFile)
10902- .param("replaceFile", Integer.toString(fileIndexOutOfBounds) ))
10895+ .param("replaceFile", "0" ))
1090310896 .andExpect(status().isBadRequest());
1090410897 }
1090510898
@@ -10955,8 +10948,9 @@ public void uploadAndReplaceForbiddenTest() throws Exception {
1095510948 .withIssueDate("2017-10-17")
1095610949 .build();
1095710950 // Create file that will be replaced
10951+ Bitstream originalFile;
1095810952 try (InputStream is = IOUtils.toInputStream("Test", CharEncoding.UTF_8)) {
10959- BitstreamBuilder.createBitstream(context, workspaceItem.getItem(), is)
10953+ originalFile = BitstreamBuilder.createBitstream(context, workspaceItem.getItem(), is)
1096010954 .withName("Bitstream")
1096110955 .withDescription("description")
1096210956 .withMimeType("text/plain")
@@ -10969,11 +10963,10 @@ public void uploadAndReplaceForbiddenTest() throws Exception {
1096910963 context.restoreAuthSystemState();
1097010964
1097110965 String token = getAuthToken(eperson.getEmail(), password);
10972- int oldFileIndex = 0;
1097310966 // Upload new file, to replace old one
1097410967 getClient(token).perform(multipart("/api/submission/workspaceitems/" + workspaceItem.getID())
1097510968 .file(newFile)
10976- .param("replaceFile", Integer. toString(oldFileIndex )))
10969+ .param("replaceFile", originalFile.getID(). toString()))
1097710970 .andExpect(status().isForbidden());
1097810971 }
1097910972
@@ -11009,11 +11002,10 @@ public void uploadAndReplaceNoWriteRightsTest() throws Exception {
1100911002 context.restoreAuthSystemState();
1101011003
1101111004 String token = getAuthToken(eperson.getEmail(), password);
11012- int oldFileIndex = 0;
1101311005 // Upload new file, to replace old one
1101411006 getClient(token).perform(multipart("/api/submission/workspaceitems/" + workspaceItem.getID())
1101511007 .file(newFile)
11016- .param("replaceFile", Integer. toString(oldFileIndex )))
11008+ .param("replaceFile", originalFile.getID(). toString()))
1101711009 .andExpect(status().isForbidden());
1101811010 }
1101911011
0 commit comments