[Task 63947] applied feedback on SubmissionForm matcher

This commit is contained in:
Raf Ponsaerts
2019-07-25 12:57:41 +02:00
parent a1f653bdd6
commit c70c1d3030
2 changed files with 17 additions and 11 deletions

View File

@@ -146,7 +146,9 @@ public class SubmissionFormConverter implements DSpaceConverter<DCInputSet, Subm
}
}
inputField.setInput(inputRest);
inputField.setSelectableMetadata(selectableMetadata);
if (dcinput.isMetadataField()) {
inputField.setSelectableMetadata(selectableMetadata);
}
if (dcinput.isRelationshipField()) {
handleSelectableRelationships(dcinput, selectableRelationships);
}

View File

@@ -23,7 +23,8 @@ import org.hamcrest.Matcher;
*/
public class SubmissionFormFieldMatcher {
private SubmissionFormFieldMatcher() { }
private SubmissionFormFieldMatcher() {
}
/**
* Shortcut for the
@@ -46,7 +47,7 @@ public class SubmissionFormFieldMatcher {
* @return a Matcher for all the condition above
*/
public static Matcher<? super Object> matchFormFieldDefinition(String type, String label, String mandatoryMessage,
boolean repeatable, String hints, String metadata) {
boolean repeatable, String hints, String metadata) {
return matchFormFieldDefinition(type, label, mandatoryMessage, repeatable, hints, null, metadata);
}
@@ -72,9 +73,10 @@ public class SubmissionFormFieldMatcher {
* @return a Matcher for all the condition above
*/
public static Matcher<? super Object> matchFormFieldDefinition(String type, String label, String mandatoryMessage,
boolean repeatable, String hints, String style, String metadata) {
boolean repeatable, String hints, String style,
String metadata) {
return allOf(
// check each field definition
// check each field definition
hasJsonPath("$.input.type", is(type)),
hasJsonPath("$.label", containsString(label)),
hasJsonPath("$.selectableMetadata[0].metadata", is(metadata)),
@@ -103,11 +105,11 @@ public class SubmissionFormFieldMatcher {
}
public static Matcher<? super Object> matchFormClosedRelationshipFieldDefinition(String label,
String mandatoryMessage,
boolean repeatable, String hints,
String relationshipType,
String filter,
String searchConfiguration) {
String mandatoryMessage,
boolean repeatable, String hints,
String relationshipType,
String filter,
String searchConfiguration) {
return allOf(
hasJsonPath("$.selectableRelationships[0].relationshipType", is(relationshipType)),
hasJsonPath("$.selectableRelationships[0].filter", is(filter)),
@@ -117,6 +119,8 @@ public class SubmissionFormFieldMatcher {
hasNoJsonPath("$.mandatoryMessage"),
hasJsonPath("$.mandatory", is(mandatoryMessage != null)),
hasJsonPath("$.repeatable", is(repeatable)),
hasJsonPath("$.hints", containsString(hints)));
hasJsonPath("$.hints", containsString(hints)),
hasNoJsonPath("$.input.type"),
hasNoJsonPath("$.selectableMetadata"));
}
}