#9806: Use builders for group, comm, coll creation in StructBuilderIT

(cherry picked from commit 2ef69045d1)
This commit is contained in:
Kim Shepherd
2024-09-06 15:32:08 +02:00
committed by github-actions[bot]
parent a678870078
commit ba8385117c

View File

@@ -23,11 +23,12 @@ import javax.xml.transform.stream.StreamSource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.AbstractIntegrationTest;
import org.dspace.AbstractIntegrationTestWithDatabase;
import org.dspace.authorize.AuthorizeException;
import org.dspace.builder.CollectionBuilder;
import org.dspace.builder.CommunityBuilder;
import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.content.MetadataSchemaEnum;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.CollectionService;
import org.dspace.content.service.CommunityService;
@@ -38,7 +39,6 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.w3c.dom.Attr;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Comparison;
import org.xmlunit.diff.ComparisonFormatter;
@@ -52,7 +52,7 @@ import org.xmlunit.diff.Difference;
* @author Mark H. Wood <mwood@iupui.edu>
*/
public class StructBuilderIT
extends AbstractIntegrationTest {
extends AbstractIntegrationTestWithDatabase {
private static final Logger log = LogManager.getLogger();
private static final CommunityService communityService
@@ -79,7 +79,8 @@ public class StructBuilderIT
* @throws IOException passed through.
*/
@Before
public void setUp() throws SQLException, AuthorizeException, IOException {
public void setUp() throws Exception {
super.setUp();
// Clear out all communities and collections.
context.turnOffAuthorisationSystem();
for (Community community : communityService.findAllTop(context)) {
@@ -285,19 +286,15 @@ public class StructBuilderIT
* @throws org.dspace.authorize.AuthorizeException passed through.
*/
@Test
public void testExportStructure()
throws ParserConfigurationException, SAXException, IOException,
SQLException, AuthorizeException {
public void testExportStructure() {
// Create some structure to test.
context.turnOffAuthorisationSystem();
Community community0 = communityService.create(null, context);
communityService.setMetadataSingleValue(context, community0,
MetadataSchemaEnum.DC.getName(), "title", null,
null, "Top Community 0");
Collection collection0_0 = collectionService.create(context, community0);
collectionService.setMetadataSingleValue(context, collection0_0,
MetadataSchemaEnum.DC.getName(), "title", null,
null, "Collection 0.0");
// Top level community
Community community0 = CommunityBuilder.createCommunity(context)
.withName("Top Community 0").build();
// Collection below top level community
Collection collection0_0 = CollectionBuilder.createCollection(context, community0)
.withName("Collection 0.0").build();
// Export the current structure.
System.out.println("exportStructure");