Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong deserialization of SelectChoice.value #532

Closed
ggalmazor opened this issue Jan 28, 2020 · 0 comments · Fixed by #533
Closed

Wrong deserialization of SelectChoice.value #532

ggalmazor opened this issue Jan 28, 2020 · 0 comments · Fixed by #533
Assignees

Comments

@ggalmazor
Copy link
Contributor

Problem description

According to the normal constructors of SelectChoice, its value member should never be null. Nevertheless, value could have a null value after deserialization if it was holding an empty string before.

Steps to reproduce the problem

The following test proves this:

@Test
public void value_should_continue_being_an_empty_string_after_deserialization() throws IOException, DeserializationException {
    Scenario scenario = Scenario.init("SelectChoice.getValue() regression test form", html(
        head(
            title("SelectChoice.getValue() regression test form"),
            model(
                mainInstance(t("data id=\"some-form\"",
                    t("the-choice")
                )),
                bind("/data/the-choice").type("string").required()
            )
        ),
        body(select1("/data/the-choice",
            label("Select one choice"),
            item("", "Empty value")
        ))
    ));

    scenario.next();
    assertThat(scenario.getQuestionAtIndex().getChoice(0).getValue(), is(""));

    Scenario deserializedScenario = scenario.serializeAndDeserializeForm();
    deserializedScenario.newInstance();
    deserializedScenario.next();
    assertThat(deserializedScenario.getQuestionAtIndex().getChoice(0).getValue(), is(""));
}

Expected behavior

The value member should not change its value after deserialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants