Skip to content

Commit b6e0c2e

Browse files
author
Matus Kasak
committed
Testing item without bitstream
1 parent 00be273 commit b6e0c2e

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

dspace-api/src/main/java/org/dspace/health/LegalCheck.java

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.dspace.core.Context;
2929

3030
/**
31+
* This check provides information about the number of items categorized by license type.
3132
* @author Matus Kasak (dspace at dataquest.sk)
3233
*/
3334
public class LegalCheck extends Check {

dspace-api/src/test/java/org/dspace/scripts/HealthReportIT.java

+48
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
import org.dspace.AbstractIntegrationTestWithDatabase;
1919
import org.dspace.app.launcher.ScriptLauncher;
2020
import org.dspace.app.scripts.handler.impl.TestDSpaceRunnableHandler;
21+
import org.dspace.builder.CollectionBuilder;
22+
import org.dspace.builder.CommunityBuilder;
23+
import org.dspace.builder.ItemBuilder;
24+
import org.dspace.content.Collection;
25+
import org.dspace.content.Community;
26+
import org.dspace.content.Item;
2127
import org.junit.Test;
2228

2329
/**
@@ -40,4 +46,46 @@ public void testDefaultHealthcheckRun() throws Exception {
4046
assertThat(messages, hasSize(1));
4147
assertThat(messages, hasItem(containsString("HEALTH REPORT:")));
4248
}
49+
50+
@Test
51+
public void testLegalCheck() throws Exception {
52+
TestDSpaceRunnableHandler testDSpaceRunnableHandler = new TestDSpaceRunnableHandler();
53+
context.turnOffAuthorisationSystem();
54+
Community rootCommunity = CommunityBuilder.createCommunity(context)
55+
.withName("Parent Community")
56+
.build();
57+
Community community = CommunityBuilder.createSubCommunity(context, rootCommunity)
58+
.withName("Sub Community A")
59+
.build();
60+
61+
Collection collection = CollectionBuilder.createCollection(context, community)
62+
.withName("Collection 1")
63+
.withSubmitterGroup(eperson)
64+
.build();
65+
66+
Item item = ItemBuilder.createItem(context, collection)
67+
.withTitle("Test Item Without Bitstream")
68+
.build();
69+
70+
String[] args = new String[] { "health-report", "-c", "3" };
71+
ScriptLauncher.handleScript(args, ScriptLauncher.getConfig(kernelImpl), testDSpaceRunnableHandler, kernelImpl);
72+
73+
assertThat(testDSpaceRunnableHandler.getErrorMessages(), empty());
74+
List<String> messages = testDSpaceRunnableHandler.getInfoMessages();
75+
assertThat(messages, hasSize(1));
76+
assertThat(messages, hasItem(containsString("no license")));
77+
}
78+
// NOVY TEST
79+
// Pouzijes builder na vytvorenie Itemu bez bitstreamu (WorkspaceItemBuilder, ItemBUilder(
80+
/**
81+
* WorkspaceItem witem = WorkspaceItemBuilder.createWorkspaceItem(context, col1)
82+
* .withTitle("Test WorkspaceItem")
83+
* .withIssueDate("2017-10-17")
84+
* .withFulltext("simple-article.pdf", "/local/path/simple-article.pdf", pdf)
85+
* .build();
86+
*
87+
* return witem;
88+
*/
89+
// Zavolat report iba pre LegalCheck
90+
// assertThat noLicense
4391
}

0 commit comments

Comments
 (0)