Fixed unit test asserts
This commit is contained in:
parent
4dbef9a799
commit
b0635a91cd
|
@ -308,42 +308,10 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
@Test
|
@Test
|
||||||
public void testRequiredQuestionWithEnableWhenHdesQuestionHasAnswerTrue() {
|
public void testRequiredQuestionWithEnableWhenHdesQuestionHasAnswerTrue() {
|
||||||
|
|
||||||
Questionnaire q = new Questionnaire();
|
|
||||||
q.addItem().setLinkId("link0").setRequired(true).setType(QuestionnaireItemType.STRING);
|
|
||||||
|
|
||||||
// create the questionnaire
|
|
||||||
QuestionnaireItemComponent item1 = new QuestionnaireItemComponent();
|
|
||||||
item1.setLinkId("link1").setRequired(true);
|
|
||||||
q.addItem(item1);
|
|
||||||
QuestionnaireItemEnableWhenComponent enable = new QuestionnaireItemEnableWhenComponent();
|
|
||||||
item1.addEnableWhen(enable);
|
|
||||||
enable.setQuestion("link0");
|
|
||||||
enable.setHasAnswer(true);
|
|
||||||
|
|
||||||
|
|
||||||
//q.getItemFirstRep().addEnableWhen().
|
|
||||||
//q.addItem().setLinkId("link1").setRequired(true).setType(QuestionnaireItemType.STRING);
|
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
|
||||||
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
|
||||||
qa.addItem().setLinkId("link0").addAnswer().setValue(new StringType("FOO"));
|
|
||||||
|
|
||||||
String reference = qa.getQuestionnaire().getReference();
|
|
||||||
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference))).thenReturn(q);
|
|
||||||
ValidationResult errors = myVal.validateWithResult(qa);
|
|
||||||
|
|
||||||
ourLog.info(errors.toString());
|
|
||||||
assertThat(errors.toString(), containsString("No issues"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRequiredQuestionWithEnableWhenHidesQuestion() {
|
|
||||||
|
|
||||||
Questionnaire q = new Questionnaire();
|
Questionnaire q = new Questionnaire();
|
||||||
q.addItem().setLinkId("link0").setRequired(false).setType(QuestionnaireItemType.STRING);
|
q.addItem().setLinkId("link0").setRequired(false).setType(QuestionnaireItemType.STRING);
|
||||||
|
|
||||||
// create the questionnaire
|
//link1 question is enabled when link0 has answer
|
||||||
QuestionnaireItemComponent item1 = new QuestionnaireItemComponent();
|
QuestionnaireItemComponent item1 = new QuestionnaireItemComponent();
|
||||||
item1.setLinkId("link1").setRequired(true);
|
item1.setLinkId("link1").setRequired(true);
|
||||||
q.addItem(item1);
|
q.addItem(item1);
|
||||||
|
@ -352,11 +320,9 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
enable.setQuestion("link0");
|
enable.setQuestion("link0");
|
||||||
enable.setHasAnswer(true);
|
enable.setHasAnswer(true);
|
||||||
|
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
||||||
//qa.addItem().setLinkId("link0").addAnswer().setValue(new StringType("FOO"));
|
|
||||||
|
|
||||||
String reference = qa.getQuestionnaire().getReference();
|
String reference = qa.getQuestionnaire().getReference();
|
||||||
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference))).thenReturn(q);
|
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference))).thenReturn(q);
|
||||||
|
@ -366,6 +332,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
assertThat(errors.toString(), containsString("No issues"));
|
assertThat(errors.toString(), containsString("No issues"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRequiredQuestionWithEnableWhenHasAnswerTrueWithAnswer() {
|
public void testRequiredQuestionWithEnableWhenHasAnswerTrueWithAnswer() {
|
||||||
|
|
||||||
|
@ -401,12 +368,10 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRequiredQuestionWithEnableWheHidesRequiredQuestionnHasAnswerFalse() {
|
public void testRequiredQuestionWithEnableWhenHidesRequiredQuestionnHasAnswerFalse() {
|
||||||
|
|
||||||
Questionnaire q = new Questionnaire();
|
Questionnaire q = new Questionnaire();
|
||||||
q.addItem().setLinkId("link0").setRequired(false).setType(QuestionnaireItemType.STRING);
|
q.addItem().setLinkId("link0").setRequired(false).setType(QuestionnaireItemType.STRING);
|
||||||
|
|
||||||
// create the questionnaire
|
|
||||||
QuestionnaireItemComponent item1 = new QuestionnaireItemComponent();
|
QuestionnaireItemComponent item1 = new QuestionnaireItemComponent();
|
||||||
item1.setLinkId("link1").setRequired(true);
|
item1.setLinkId("link1").setRequired(true);
|
||||||
q.addItem(item1);
|
q.addItem(item1);
|
||||||
|
@ -415,10 +380,6 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
enable.setQuestion("link0");
|
enable.setQuestion("link0");
|
||||||
enable.setHasAnswer(false);
|
enable.setHasAnswer(false);
|
||||||
|
|
||||||
|
|
||||||
//q.getItemFirstRep().addEnableWhen().
|
|
||||||
//q.addItem().setLinkId("link1").setRequired(true).setType(QuestionnaireItemType.STRING);
|
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
||||||
|
|
Loading…
Reference in New Issue