Skip to content

Commit

Permalink
Trim values stored in choices (#752)
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed May 14, 2024
1 parent 3f579c4 commit 5076ff7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/javarosa/core/model/SelectChoice.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private SelectChoice(String labelID, String labelInnerText, String value, boolea
throw new XFormParseException("SelectChoice{id,innerText}:{" + labelID + "," + labelInnerText + "}, has null Value!");
}

this.value = value;
this.value = value.trim();
this.isLocalizable = isLocalizable;
this.textID = labelID;
this.labelInnerText = labelInnerText;
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/org/javarosa/core/model/SelectChoiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ public void value_should_continue_being_an_empty_string_after_deserialization()
assertThat(deserializedScenario.getQuestionAtIndex().getChoice(0).getValue(), is(""));
}

@Test
public void value_should_be_trimmed_when_select_choice_object_constructed() {
SelectChoice choice = new SelectChoice(null, "Label", " value ", false);

assertThat(choice.getValue(), is("value"));
}

@Test
public void getChild_returnsNamedChild_whenChoicesAreFromSecondaryInstance() throws XFormParser.ParseException {
setUpSimpleReferenceManager(r("external-select-geojson.xml").getParent(), "file");
Expand Down

0 comments on commit 5076ff7

Please sign in to comment.