Skip to content

Commit

Permalink
Merged in task/dspace-cris-2023_02_x/DSC-1263 (pull request DSpace#3385)
Browse files Browse the repository at this point in the history
Task/dspace cris 2023 02 x/DSC-1263

Approved-by: Vincenzo Mecca
  • Loading branch information
AdamF42 authored and vins01-4science committed Jan 28, 2025
2 parents c0d2912 + 8654149 commit 8e21169
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 15 deletions.
6 changes: 3 additions & 3 deletions bitbucket-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ definitions:
script:
- *setEnv
#- ./dspace-api/src/test/data/dspaceFolder/bin/install_grobid.sh
- mvn -T 1C clean verify -Dmaven.test.skip=true -DskipUnitTests=true -Pdspace-rest -DskipITs=true -DskipIntegrationTests=true -P !assembly -B $MAVEN_ARGS
- mvn -T 1C clean install -Dmaven.test.skip=true -DskipUnitTests=true -Pdspace-rest -DskipITs=true -DskipIntegrationTests=true -P !assembly -B $MAVEN_ARGS
- mvn test -pl dspace-iiif,dspace-oai,dspace-rdf,dspace-rest,dspace-server-webapp,dspace-services,dspace-sword,dspace-swordv2 -Dmaven.test.skip=false -DskipUnitTests=false -Pdspace-rest -DskipITs=false -Pdspace-rest -DskipIntegrationTests=false -B -Dsurefire.rerunFailingTestsCount=2 -Dtest.argLine=-Xmx4096M -DfailIfNoTests=false -Dtest=*IT,!Abstract*,!ItemImportIT,!GenericAuthorizationFeatureIT,!ItemRestRepositoryIT,!LeftTiltedRelationshipRestRepositoryIT,!RelationshipRestRepositoryIT,!StatisticsRestRepositoryIT,!WorkspaceItemRestRepositoryIT,!DiscoveryRestControllerIT,!PatchMetadataIT,!RightTiltedRelationshipRestRepositoryIT $MAVEN_ARGS
artifacts:
- dspace-iiif/target/surefire-reports/*-output.txt
Expand Down Expand Up @@ -80,7 +80,7 @@ definitions:
script:
- *setEnv
#- ./dspace-api/src/test/data/dspaceFolder/bin/install_grobid.sh
- mvn -T 1C clean verify -Dmaven.test.skip=true -DskipUnitTests=true -Pdspace-rest -DskipITs=true -DskipIntegrationTests=true -P !assembly -B $MAVEN_ARGS
- mvn -T 1C clean install -Dmaven.test.skip=true -DskipUnitTests=true -Pdspace-rest -DskipITs=true -DskipIntegrationTests=true -P !assembly -B $MAVEN_ARGS
- mvn test -Dmaven.test.skip=false -DskipUnitTests=false -Pdspace-rest -DskipITs=false -Pdspace-rest -DskipIntegrationTests=false -B -Dsurefire.rerunFailingTestsCount=2 -Dtest.argLine=-Xmx4096M -DfailIfNoTests=false -Dtest=ItemImportIT,GenericAuthorizationFeatureIT,ItemRestRepositoryIT,LeftTiltedRelationshipRestRepositoryIT,RelationshipRestRepositoryIT,StatisticsRestRepositoryIT,WorkspaceItemRestRepositoryIT,DiscoveryRestControllerIT,PatchMetadataIT,RightTiltedRelationshipRestRepositoryIT $MAVEN_ARGS
artifacts:
- dspace-iiif/target/surefire-reports/*-output.txt
Expand Down Expand Up @@ -110,7 +110,7 @@ definitions:
- maven
script:
- *setEnv
- mvn -T 1C clean verify license:check -Dmaven.test.skip=true -Dmaven.test.skip=true -DskipUnitTests=true -Pdspace-rest -DskipITs=true -DskipIntegrationTests=true -P !assembly -B $MAVEN_ARGS
- mvn -T 1C clean install license:check -Dmaven.test.skip=true -Dmaven.test.skip=true -DskipUnitTests=true -Pdspace-rest -DskipITs=true -DskipIntegrationTests=true -P !assembly -B $MAVEN_ARGS
- mvn verify -pl dspace-api -Dmaven.test.skip=false -DskipUnitTests=true -Pdspace-rest -DskipITs=false -Pdspace-rest -DskipIntegrationTests=false -P !assembly -B -Dsurefire.rerunFailingTestsCount=2 -Dtest.argLine=-Xmx4096M $MAVEN_ARGS
artifacts:
- dspace-api/target/surefire-reports/*-output.txt
Expand Down
4 changes: 2 additions & 2 deletions dspace-api/src/main/java/org/dspace/app/util/DCInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public DCInput(Map<String, String> fieldMap, Map<String, List<String>> listMap)
language = Boolean.valueOf(fieldMap.get("language"));
valueLanguageList = new ArrayList<>();
if (language) {
String languageNameTmp = fieldMap.get("value-pairs-name");
String languageNameTmp = fieldMap.get("language.value-pairs-name");
if (StringUtils.isBlank(languageNameTmp)) {
languageNameTmp = LanguageName;
}
Expand All @@ -206,7 +206,7 @@ public DCInput(Map<String, String> fieldMap, Map<String, List<String>> listMap)
// these types are list-controlled
if ("dropdown".equals(inputType) || "qualdrop_value".equals(inputType)
|| "list".equals(inputType)) {
valueListName = fieldMap.get("value-pairs-name");
valueListName = fieldMap.get(inputType + ".value-pairs-name");
valueList = listMap.get(valueListName);
}
hint = fieldMap.get("hint");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ private void processField(String formName, Node n, Map<String, String> field)
"." + field.get("dc-qualifier") +
" has no language attribute");
} else {
field.put(PAIR_TYPE_NAME, pairTypeName);
field.put("language." + PAIR_TYPE_NAME, pairTypeName);
}
}
} else if (StringUtils.equalsIgnoreCase(tagName, "linked-metadata-field")) {
Expand Down Expand Up @@ -596,7 +596,7 @@ private void handleInputTypeTagName(String formName, Map<String, String> field,
"." + field.get("dc-qualifier") +
" has no name attribute");
} else {
field.put(PAIR_TYPE_NAME, pairTypeName);
field.put(value + "." + PAIR_TYPE_NAME, pairTypeName);
}
}
}
Expand Down Expand Up @@ -735,7 +735,7 @@ private void checkValues()
if (StringUtils.isNotBlank(type) && (type.equals("dropdown")
|| type.equals("qualdrop_value")
|| type.equals("list"))) {
String pairsName = fld.get(PAIR_TYPE_NAME);
String pairsName = fld.get(type + "." + PAIR_TYPE_NAME);
List<String> v = valuePairs.get(pairsName);
if (v == null) {
String errString = "Cannot find value pairs for " + pairsName;
Expand Down
28 changes: 28 additions & 0 deletions dspace-api/src/test/data/dspaceFolder/config/submission-forms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,23 @@ it, please enter the types and the actual numbers or codes.</hint>
</row>
</form>

<form name="qualdrop-with-languages">
<row>
<field>
<dc-schema>dc</dc-schema>
<dc-element>identifier</dc-element>
<dc-qualifier></dc-qualifier>
<!-- An input-type of qualdrop_value MUST be marked as repeatable -->
<repeatable>true</repeatable>
<label>Identifiers</label>
<input-type value-pairs-name="common_identifiers">qualdrop_value</input-type>
<hint>Test qualdrop.</hint>
<language value-pairs-name="test_languages">true</language>
<required></required>
</field>
</row>
</form>

<form name="traditionalpageone-cris-dc-contributor-author">
<row>
<field>
Expand Down Expand Up @@ -3007,6 +3024,17 @@ it, please enter the types and the actual numbers or codes.</hint>
</pair>
</value-pairs>

<value-pairs value-pairs-name="test_languages" dc-term="language_iso">
<pair>
<displayed-value>Lang1</displayed-value>
<stored-value>ln_1</stored-value>
</pair>
<pair>
<displayed-value>Lang2</displayed-value>
<stored-value>ln_2</stored-value>
</pair>
</value-pairs>

</form-value-pairs>

</input-forms>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

import static org.dspace.app.rest.matcher.SubmissionFormFieldMatcher.matchFormWithVisibility;
import static org.dspace.app.rest.matcher.SubmissionFormFieldMatcher.matchFormWithoutVisibility;
import static org.dspace.app.rest.matcher.SubmissionFormFieldMatcher.matchSelectableMetadata;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
Expand Down Expand Up @@ -73,7 +75,7 @@ public void findAll() throws Exception {
.andExpect(content().contentType(contentType))
//The configuration file for the test env includes PAGE_TOTAL_ELEMENTS forms
.andExpect(jsonPath("$.page.size", is(20)))
.andExpect(jsonPath("$.page.totalElements", equalTo(43)))
.andExpect(jsonPath("$.page.totalElements", equalTo(44)))
.andExpect(jsonPath("$.page.totalPages", equalTo(3)))
.andExpect(jsonPath("$.page.number", is(0)))
.andExpect(
Expand All @@ -90,7 +92,7 @@ public void findAllWithNewlyCreatedAccountTest() throws Exception {
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$.page.size", is(20)))
.andExpect(jsonPath("$.page.totalElements", equalTo(43)))
.andExpect(jsonPath("$.page.totalElements", equalTo(44)))
.andExpect(jsonPath("$.page.totalPages", equalTo(3)))
.andExpect(jsonPath("$.page.number", is(0)))
.andExpect(jsonPath("$._links.self.href", Matchers.startsWith(REST_SERVER_URL
Expand Down Expand Up @@ -671,7 +673,7 @@ public void findAllPaginationTest() throws Exception {
Matchers.containsString("/api/config/submissionforms?"),
Matchers.containsString("page=21"), Matchers.containsString("size=2"))))
.andExpect(jsonPath("$.page.size", is(2)))
.andExpect(jsonPath("$.page.totalElements", equalTo(43)))
.andExpect(jsonPath("$.page.totalElements", equalTo(44)))
.andExpect(jsonPath("$.page.totalPages", equalTo(22)))
.andExpect(jsonPath("$.page.number", is(0)));

Expand All @@ -680,8 +682,8 @@ public void findAllPaginationTest() throws Exception {
.param("page", "15"))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.submissionforms[0].id", is("traditionalpagethree-cris-collapsed")))
.andExpect(jsonPath("$._embedded.submissionforms[1].id", is("orange")))
.andExpect(jsonPath("$._embedded.submissionforms[0].id", is("qualdrop-with-languages")))
.andExpect(jsonPath("$._embedded.submissionforms[1].id", is("traditionalpagethree-cris-collapsed")))
.andExpect(jsonPath("$._links.first.href", Matchers.allOf(
Matchers.containsString("/api/config/submissionforms?"),
Matchers.containsString("page=0"), Matchers.containsString("size=2"))))
Expand All @@ -698,7 +700,7 @@ public void findAllPaginationTest() throws Exception {
Matchers.containsString("/api/config/submissionforms?"),
Matchers.containsString("page=21"), Matchers.containsString("size=2"))))
.andExpect(jsonPath("$.page.size", is(2)))
.andExpect(jsonPath("$.page.totalElements", equalTo(43)))
.andExpect(jsonPath("$.page.totalElements", equalTo(44)))
.andExpect(jsonPath("$.page.totalPages", equalTo(22)))
.andExpect(jsonPath("$.page.number", is(15)));
}
Expand Down Expand Up @@ -745,8 +747,34 @@ public void visibilityTest() throws Exception {
Matchers.containsString("/api/config/submissionforms?"),
Matchers.containsString("page=21"), Matchers.containsString("size=2"))))
.andExpect(jsonPath("$.page.size", is(2)))
.andExpect(jsonPath("$.page.totalElements", equalTo(43)))
.andExpect(jsonPath("$.page.totalElements", equalTo(44)))
.andExpect(jsonPath("$.page.totalPages", equalTo(22)))
.andExpect(jsonPath("$.page.number", is(4)));
}

@Test
public void findQualdropWithLanguagesTest() throws Exception {
String token = getAuthToken(eperson.getEmail(), password);
getClient(token).perform(get("/api/config/submissionforms/qualdrop-with-languages"))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$.rows[0].fields[0].selectableMetadata", containsInAnyOrder(
matchSelectableMetadata("dc.identifier.doi", "DOI", false),
matchSelectableMetadata("dc.identifier.scopus", "Scopus ID", false),
matchSelectableMetadata("dc.identifier.isi", "WOS ID", false),
matchSelectableMetadata("dc.identifier.adsbibcode", "Ads Code", false),
matchSelectableMetadata("dc.identifier.pmid", "Pubmed ID", false),
matchSelectableMetadata("dc.identifier.arxiv", "arXiv ID", false),
matchSelectableMetadata("dc.identifier.issn", "ISSN", false),
matchSelectableMetadata("dc.identifier.other", "Other", false),
matchSelectableMetadata("dc.identifier.ismn", "ISMN", false),
matchSelectableMetadata("dc.identifier.govdoc", "Gov't Doc #", false),
matchSelectableMetadata("dc.identifier.uri", "URI", false),
matchSelectableMetadata("dc.identifier.isbn", "ISBN", false)
)))
.andExpect(jsonPath("$.rows[0].fields[0].languageCodes", containsInAnyOrder(
SubmissionFormFieldMatcher.matchLanguageCode("Lang1", "ln_1"),
SubmissionFormFieldMatcher.matchLanguageCode("Lang2", "ln_2")
)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,37 @@ public static Matcher<? super Object> matchFormFieldDefinition(String type, Stri
);
}

/**
* Creates a matcher to verify the properties of a selectableMetadata entry.
*
* @param metadata the metadata field to match (e.g., "dc.identifier.doi")
* @param label the label associated with the metadata field (e.g., "DOI")
* @param closed whether the metadata field is closed (true or false)
* @return a Matcher that verifies the "metadata", "label", and "closed" properties of a selectableMetadata object
*/
public static Matcher<Object> matchSelectableMetadata(String metadata, String label, boolean closed) {
return allOf(
hasJsonPath("$.metadata", is(metadata)),
hasJsonPath("$.label", is(label)),
hasJsonPath("$.closed", is(closed))
);
}

/**
* Creates a matcher to validate an object representing a language code in a JSON response.
*
* @param display The expected value of the "display" field, representing the name of the language.
* @param code The expected value of the "code" field, representing the language code.
* @return A {@link Matcher} that validates the "display" and "code" fields of the JSON object.
*/
public static Matcher<Object> matchLanguageCode(String display, String code) {
return allOf(
hasJsonPath("$.display", is(display)),
hasJsonPath("$.code", is(code))
);
}


/**
* Check the json representation of an open relationship field.
* This is a combination of an entity relationship lookup and a plain text metadata entry field
Expand Down

0 comments on commit 8e21169

Please sign in to comment.