mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 14:03:17 +00:00
[Task 63946] applied the feedback
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
package org.dspace.content;
|
package org.dspace.content;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.equalTo;
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.CoreMatchers.not;
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||||
import static org.hamcrest.CoreMatchers.nullValue;
|
import static org.hamcrest.CoreMatchers.nullValue;
|
||||||
@@ -506,4 +507,52 @@ public class BitstreamTest extends AbstractDSpaceObjectTest {
|
|||||||
nullValue());
|
nullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testSetSequenceIdToAlreadyExistingIllegalArgumentException()
|
||||||
|
throws SQLException, IOException, AuthorizeException {
|
||||||
|
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
Community owningCommunity = communityService.create(null, context);
|
||||||
|
Collection collection = collectionService.create(context, owningCommunity);
|
||||||
|
WorkspaceItem workspaceItem = workspaceItemService.create(context, collection, false);
|
||||||
|
Item item = installItemService.installItem(context, workspaceItem);
|
||||||
|
|
||||||
|
item.setSubmitter(context.getCurrentUser());
|
||||||
|
itemService.update(context, item);
|
||||||
|
//we need to commit the changes so we don't block the table for testing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File f = new File(testProps.get("test.bitstream").toString());
|
||||||
|
Bitstream firstBitstream = itemService.createSingleBitstream(context, new FileInputStream(f), item);
|
||||||
|
Bitstream secondBitstream = itemService.createSingleBitstream(context, new FileInputStream(f), item);
|
||||||
|
|
||||||
|
bitstreamService.setSequenceId(context, secondBitstream, item, firstBitstream.getSequenceID());
|
||||||
|
context.restoreAuthSystemState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetSequenceId() throws SQLException, IOException, AuthorizeException {
|
||||||
|
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
Community owningCommunity = communityService.create(null, context);
|
||||||
|
Collection collection = collectionService.create(context, owningCommunity);
|
||||||
|
WorkspaceItem workspaceItem = workspaceItemService.create(context, collection, false);
|
||||||
|
Item item = installItemService.installItem(context, workspaceItem);
|
||||||
|
|
||||||
|
item.setSubmitter(context.getCurrentUser());
|
||||||
|
itemService.update(context, item);
|
||||||
|
//we need to commit the changes so we don't block the table for testing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File f = new File(testProps.get("test.bitstream").toString());
|
||||||
|
Bitstream firstBitstream = itemService.createSingleBitstream(context, new FileInputStream(f), item);
|
||||||
|
Bitstream secondBitstream = itemService.createSingleBitstream(context, new FileInputStream(f), item);
|
||||||
|
|
||||||
|
bitstreamService.setSequenceId(context, secondBitstream, item, firstBitstream.getSequenceID() + 1);
|
||||||
|
assertThat(secondBitstream.getSequenceID(), is(firstBitstream.getSequenceID() + 1));
|
||||||
|
context.restoreAuthSystemState();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,9 @@ import org.dspace.app.rest.utils.ContextUtil;
|
|||||||
import org.dspace.app.rest.utils.Utils;
|
import org.dspace.app.rest.utils.Utils;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
|
import org.dspace.content.BitstreamFormat;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.content.service.BitstreamFormatService;
|
||||||
import org.dspace.content.service.BitstreamService;
|
import org.dspace.content.service.BitstreamService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
@@ -61,6 +63,9 @@ public class ItemUploadController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private MetadataConverter metadataConverter;
|
private MetadataConverter metadataConverter;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BitstreamFormatService bitstreamFormatService;
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = "/bitstreams", headers = "content-type=multipart/form-data")
|
@RequestMapping(method = RequestMethod.POST, value = "/bitstreams", headers = "content-type=multipart/form-data")
|
||||||
@PreAuthorize("hasPermission(#uuid, 'ITEM', 'WRITE') && hasPermission(#uuid, 'ITEM', 'ADD')")
|
@PreAuthorize("hasPermission(#uuid, 'ITEM', 'WRITE') && hasPermission(#uuid, 'ITEM', 'ADD')")
|
||||||
public BitstreamResource uploadBitstream(HttpServletRequest request, @PathVariable UUID uuid,
|
public BitstreamResource uploadBitstream(HttpServletRequest request, @PathVariable UUID uuid,
|
||||||
@@ -86,7 +91,8 @@ public class ItemUploadController {
|
|||||||
throw new UnprocessableEntityException("The InputStream from the file couldn't be read");
|
throw new UnprocessableEntityException("The InputStream from the file couldn't be read");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
bitstream = processBitstreamCreation(context, item, fileInputStream, properties, uploadfile.getOriginalFilename());
|
bitstream = processBitstreamCreation(context, item, fileInputStream, properties,
|
||||||
|
uploadfile.getOriginalFilename());
|
||||||
itemService.update(context, item);
|
itemService.update(context, item);
|
||||||
context.commit();
|
context.commit();
|
||||||
} catch (AuthorizeException | IOException | SQLException e) {
|
} catch (AuthorizeException | IOException | SQLException e) {
|
||||||
@@ -140,6 +146,8 @@ public class ItemUploadController {
|
|||||||
bitstream.setName(context, originalFilename);
|
bitstream.setName(context, originalFilename);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
BitstreamFormat bitstreamFormat = bitstreamFormatService.guessFormat(context, bitstream);
|
||||||
|
bitstreamService.setFormat(context, bitstream, bitstreamFormat);
|
||||||
bitstreamService.update(context, bitstream);
|
bitstreamService.update(context, bitstream);
|
||||||
|
|
||||||
return bitstream;
|
return bitstream;
|
||||||
|
@@ -8,14 +8,20 @@
|
|||||||
package org.dspace.app.rest;
|
package org.dspace.app.rest;
|
||||||
|
|
||||||
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.core.IsNull.notNullValue;
|
import static org.hamcrest.core.IsNull.notNullValue;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.dspace.app.rest.builder.CollectionBuilder;
|
import org.dspace.app.rest.builder.CollectionBuilder;
|
||||||
import org.dspace.app.rest.builder.CommunityBuilder;
|
import org.dspace.app.rest.builder.CommunityBuilder;
|
||||||
import org.dspace.app.rest.builder.ItemBuilder;
|
import org.dspace.app.rest.builder.ItemBuilder;
|
||||||
|
import org.dspace.app.rest.matcher.BitstreamMatcher;
|
||||||
import org.dspace.app.rest.matcher.MetadataMatcher;
|
import org.dspace.app.rest.matcher.MetadataMatcher;
|
||||||
import org.dspace.app.rest.model.BitstreamPropertiesRest;
|
import org.dspace.app.rest.model.BitstreamPropertiesRest;
|
||||||
import org.dspace.app.rest.model.MetadataRest;
|
import org.dspace.app.rest.model.MetadataRest;
|
||||||
@@ -32,6 +38,7 @@ import org.junit.Test;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.mock.web.MockMultipartFile;
|
import org.springframework.mock.web.MockMultipartFile;
|
||||||
|
import org.springframework.test.web.servlet.MvcResult;
|
||||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||||
|
|
||||||
public class ItemUploadControllerIT extends AbstractEntityIntegrationTest {
|
public class ItemUploadControllerIT extends AbstractEntityIntegrationTest {
|
||||||
@@ -67,7 +74,7 @@ public class ItemUploadControllerIT extends AbstractEntityIntegrationTest {
|
|||||||
input.getBytes());
|
input.getBytes());
|
||||||
|
|
||||||
BitstreamPropertiesRest bitstreamPropertiesRest = new BitstreamPropertiesRest();
|
BitstreamPropertiesRest bitstreamPropertiesRest = new BitstreamPropertiesRest();
|
||||||
bitstreamPropertiesRest.setBundleName("ORIGINAL");
|
bitstreamPropertiesRest.setBundleName("TESTINGBUNDLE");
|
||||||
bitstreamPropertiesRest.setName("testing");
|
bitstreamPropertiesRest.setName("testing");
|
||||||
bitstreamPropertiesRest.setSequenceId(123456);
|
bitstreamPropertiesRest.setSequenceId(123456);
|
||||||
|
|
||||||
@@ -93,14 +100,15 @@ public class ItemUploadControllerIT extends AbstractEntityIntegrationTest {
|
|||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
getClient(token).perform(MockMvcRequestBuilders.fileUpload("/api/core/items/" + item.getID() + "/bitstreams")
|
MvcResult mvcResult = getClient(token).perform(
|
||||||
|
MockMvcRequestBuilders.fileUpload("/api/core/items/" + item.getID() + "/bitstreams")
|
||||||
.file(file)
|
.file(file)
|
||||||
.param("properties", mapper
|
.param("properties", mapper
|
||||||
.writeValueAsString(bitstreamPropertiesRest)))
|
.writeValueAsString(bitstreamPropertiesRest)))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.name", Matchers.is("testing")))
|
.andExpect(jsonPath("$.name", is("testing")))
|
||||||
.andExpect(jsonPath("$.bundleName", Matchers.is("ORIGINAL")))
|
.andExpect(jsonPath("$.bundleName", is("TESTINGBUNDLE")))
|
||||||
.andExpect(jsonPath("$.sequenceId", Matchers.is(Integer.parseInt("123456"))))
|
.andExpect(jsonPath("$.sequenceId", is(Integer.parseInt("123456"))))
|
||||||
.andExpect(jsonPath("$", Matchers.allOf(
|
.andExpect(jsonPath("$", Matchers.allOf(
|
||||||
hasJsonPath("$.metadata", Matchers.allOf(
|
hasJsonPath("$.metadata", Matchers.allOf(
|
||||||
MetadataMatcher.matchMetadata("dc.description",
|
MetadataMatcher.matchMetadata("dc.description",
|
||||||
@@ -111,7 +119,17 @@ public class ItemUploadControllerIT extends AbstractEntityIntegrationTest {
|
|||||||
"Custom Copyright Text"),
|
"Custom Copyright Text"),
|
||||||
MetadataMatcher.matchMetadata("dc.title",
|
MetadataMatcher.matchMetadata("dc.title",
|
||||||
"testing")
|
"testing")
|
||||||
)))));
|
))))).andReturn();
|
||||||
|
|
||||||
|
String content = mvcResult.getResponse().getContentAsString();
|
||||||
|
Map<String, Object> map = mapper.readValue(content, Map.class);
|
||||||
|
String bitstreamId = String.valueOf(map.get("id"));
|
||||||
|
|
||||||
|
getClient(token).perform(get("/api/core/items/" + item.getID() + "/bitstreams"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("_embedded.bitstreams", Matchers.hasItem(
|
||||||
|
BitstreamMatcher.matchBitstreamEntry(UUID.fromString(bitstreamId), file.getSize()))));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -141,9 +159,25 @@ public class ItemUploadControllerIT extends AbstractEntityIntegrationTest {
|
|||||||
MockMultipartFile file = new MockMultipartFile("file", "hello.txt", MediaType.TEXT_PLAIN_VALUE,
|
MockMultipartFile file = new MockMultipartFile("file", "hello.txt", MediaType.TEXT_PLAIN_VALUE,
|
||||||
input.getBytes());
|
input.getBytes());
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
getClient(token).perform(MockMvcRequestBuilders.fileUpload("/api/core/items/" + item.getID() + "/bitstreams")
|
MvcResult mvcResult = getClient(token)
|
||||||
|
.perform(MockMvcRequestBuilders.fileUpload("/api/core/items/" + item.getID() + "/bitstreams")
|
||||||
.file(file))
|
.file(file))
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.bundleName", is("ORIGINAL")))
|
||||||
|
.andExpect(jsonPath("$.name", is("hello.txt")))
|
||||||
|
.andExpect(jsonPath("$.sequenceId", is(1)))
|
||||||
|
.andReturn();
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
|
String content = mvcResult.getResponse().getContentAsString();
|
||||||
|
Map<String, Object> map = mapper.readValue(content, Map.class);
|
||||||
|
String bitstreamId = String.valueOf(map.get("id"));
|
||||||
|
|
||||||
|
getClient(token).perform(get("/api/core/items/" + item.getID() + "/bitstreams"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("_embedded.bitstreams", Matchers.hasItem(
|
||||||
|
BitstreamMatcher.matchBitstreamEntry(UUID.fromString(bitstreamId), file.getSize()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -177,10 +211,22 @@ public class ItemUploadControllerIT extends AbstractEntityIntegrationTest {
|
|||||||
input.getBytes());
|
input.getBytes());
|
||||||
|
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
getClient(token).perform(MockMvcRequestBuilders.fileUpload("/api/core/items/" + item.getID() + "/bitstreams")
|
MvcResult mvcResult = getClient(token)
|
||||||
|
.perform(MockMvcRequestBuilders.fileUpload("/api/core/items/" + item.getID() + "/bitstreams")
|
||||||
.file(file))
|
.file(file))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.uuid", notNullValue()));
|
.andExpect(jsonPath("$.uuid", notNullValue())).andReturn();
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
|
String content = mvcResult.getResponse().getContentAsString();
|
||||||
|
Map<String, Object> map = mapper.readValue(content, Map.class);
|
||||||
|
String bitstreamId = String.valueOf(map.get("id"));
|
||||||
|
|
||||||
|
getClient(token).perform(get("/api/core/items/" + item.getID() + "/bitstreams"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("_embedded.bitstreams", Matchers.hasItem(
|
||||||
|
BitstreamMatcher.matchBitstreamEntry(UUID.fromString(bitstreamId), file.getSize()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -215,6 +261,10 @@ public class ItemUploadControllerIT extends AbstractEntityIntegrationTest {
|
|||||||
getClient(token).perform(MockMvcRequestBuilders.fileUpload("/api/core/items/" + item.getID() + "/bitstreams")
|
getClient(token).perform(MockMvcRequestBuilders.fileUpload("/api/core/items/" + item.getID() + "/bitstreams")
|
||||||
.file(file))
|
.file(file))
|
||||||
.andExpect(status().isForbidden());
|
.andExpect(status().isForbidden());
|
||||||
|
|
||||||
|
getClient(token).perform(get("/api/core/items/" + item.getID() + "/bitstreams"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("_embedded.bitstreams").doesNotExist());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -249,6 +299,10 @@ public class ItemUploadControllerIT extends AbstractEntityIntegrationTest {
|
|||||||
getClient().perform(MockMvcRequestBuilders.fileUpload("/api/core/items/" + item.getID() + "/bitstreams")
|
getClient().perform(MockMvcRequestBuilders.fileUpload("/api/core/items/" + item.getID() + "/bitstreams")
|
||||||
.file(file))
|
.file(file))
|
||||||
.andExpect(status().isUnauthorized());
|
.andExpect(status().isUnauthorized());
|
||||||
|
|
||||||
|
getClient(token).perform(get("/api/core/items/" + item.getID() + "/bitstreams"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("_embedded.bitstreams").doesNotExist());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -282,51 +336,31 @@ public class ItemUploadControllerIT extends AbstractEntityIntegrationTest {
|
|||||||
input.getBytes());
|
input.getBytes());
|
||||||
|
|
||||||
BitstreamPropertiesRest bitstreamPropertiesRest = new BitstreamPropertiesRest();
|
BitstreamPropertiesRest bitstreamPropertiesRest = new BitstreamPropertiesRest();
|
||||||
String originalBundle = "ORIGINAL";
|
String testbundle = "TESTBUNDLE";
|
||||||
bitstreamPropertiesRest.setBundleName(originalBundle);
|
bitstreamPropertiesRest.setBundleName(testbundle);
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
|
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
getClient(token).perform(MockMvcRequestBuilders.fileUpload("/api/core/items/" + item.getID() + "/bitstreams")
|
MvcResult mvcResult = getClient(token)
|
||||||
|
.perform(MockMvcRequestBuilders.fileUpload("/api/core/items/" + item.getID() + "/bitstreams")
|
||||||
.file(file)
|
.file(file)
|
||||||
.param("properties", mapper
|
.param("properties", mapper
|
||||||
.writeValueAsString(bitstreamPropertiesRest)))
|
.writeValueAsString(bitstreamPropertiesRest)))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.bundleName", Matchers.is(originalBundle)))
|
.andExpect(jsonPath("$.bundleName", is(testbundle)))
|
||||||
.andExpect(jsonPath("$.uuid", notNullValue()));
|
.andExpect(jsonPath("$.uuid", notNullValue())).andReturn();
|
||||||
}
|
|
||||||
|
|
||||||
//TODO This test just fails to run entirely because we cannot pass 'null' to a file upload
|
|
||||||
// Should we support this test case differently and if so, how?
|
|
||||||
@Test
|
|
||||||
@Ignore
|
|
||||||
public void uploadBitstreamNoFileUnprocessableEntityException() throws Exception {
|
|
||||||
context.turnOffAuthorisationSystem();
|
|
||||||
|
|
||||||
|
|
||||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
String content = mvcResult.getResponse().getContentAsString();
|
||||||
.withName("Parent Community")
|
Map<String, Object> map = mapper.readValue(content, Map.class);
|
||||||
.build();
|
String bitstreamId = String.valueOf(map.get("id"));
|
||||||
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
|
|
||||||
.withName("Sub Community")
|
|
||||||
.build();
|
|
||||||
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build();
|
|
||||||
Collection col2 = CollectionBuilder.createCollection(context, child1).withName("Collection 2").build();
|
|
||||||
Collection col3 = CollectionBuilder.createCollection(context, child1).withName("OrgUnits").build();
|
|
||||||
|
|
||||||
Item item = ItemBuilder.createItem(context, col1)
|
getClient(token).perform(get("/api/core/items/" + item.getID() + "/bitstreams"))
|
||||||
.withTitle("Author1")
|
.andExpect(status().isOk())
|
||||||
.withIssueDate("2017-10-17")
|
.andExpect(jsonPath("_embedded.bitstreams", Matchers.hasItem(
|
||||||
.withAuthor("Smith, Donald")
|
BitstreamMatcher.matchBitstreamEntry(UUID.fromString(bitstreamId), file.getSize()))));
|
||||||
.build();
|
|
||||||
|
|
||||||
String token = getAuthToken(admin.getEmail(), password);
|
|
||||||
|
|
||||||
context.restoreAuthSystemState();
|
|
||||||
getClient(token).perform(MockMvcRequestBuilders.fileUpload("/api/core/items/" + item.getID() + "/bitstreams"))
|
|
||||||
.andExpect(status().isUnprocessableEntity());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO This test doesn't work either as it seems that only the first file is ever transfered into the request
|
// TODO This test doesn't work either as it seems that only the first file is ever transfered into the request
|
||||||
@@ -407,6 +441,10 @@ public class ItemUploadControllerIT extends AbstractEntityIntegrationTest {
|
|||||||
.param("properties", mapper
|
.param("properties", mapper
|
||||||
.writeValueAsString(bitstreamPropertiesRest)))
|
.writeValueAsString(bitstreamPropertiesRest)))
|
||||||
.andExpect(status().isUnprocessableEntity());
|
.andExpect(status().isUnprocessableEntity());
|
||||||
|
|
||||||
|
getClient(token).perform(get("/api/core/items/" + item.getID() + "/bitstreams"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("_embedded.bitstreams").doesNotExist());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -470,9 +508,9 @@ public class ItemUploadControllerIT extends AbstractEntityIntegrationTest {
|
|||||||
.param("properties", mapper
|
.param("properties", mapper
|
||||||
.writeValueAsString(bitstreamPropertiesRest)))
|
.writeValueAsString(bitstreamPropertiesRest)))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.name", Matchers.is("testing")))
|
.andExpect(jsonPath("$.name", is("testing")))
|
||||||
.andExpect(jsonPath("$.bundleName", Matchers.is("ORIGINAL")))
|
.andExpect(jsonPath("$.bundleName", is("ORIGINAL")))
|
||||||
.andExpect(jsonPath("$.sequenceId", Matchers.is(Integer.parseInt("123456"))))
|
.andExpect(jsonPath("$.sequenceId", is(Integer.parseInt("123456"))))
|
||||||
.andExpect(jsonPath("$", Matchers.allOf(
|
.andExpect(jsonPath("$", Matchers.allOf(
|
||||||
hasJsonPath("$.metadata", Matchers.allOf(
|
hasJsonPath("$.metadata", Matchers.allOf(
|
||||||
MetadataMatcher.matchMetadata("dc.description",
|
MetadataMatcher.matchMetadata("dc.description",
|
||||||
@@ -491,6 +529,10 @@ public class ItemUploadControllerIT extends AbstractEntityIntegrationTest {
|
|||||||
.writeValueAsString(bitstreamPropertiesRest)))
|
.writeValueAsString(bitstreamPropertiesRest)))
|
||||||
.andExpect(status().isUnprocessableEntity());
|
.andExpect(status().isUnprocessableEntity());
|
||||||
|
|
||||||
|
getClient(token).perform(get("/api/core/items/" + item.getID() + "/bitstreams"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.page.totalElements", is(1)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user