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

Added assertions on converters unit tests #28

Merged
merged 10 commits into from
Jun 22, 2020
Merged

Conversation

rehammuzzamil
Copy link
Contributor

@rehammuzzamil rehammuzzamil commented Jun 19, 2020

Resolves #26

questionnaireResponse.getItem().get(3).getAnswer().get(0).getValue().as(com.ibm.fhir.model.type.String.class)
.getValue(), event.getTeam());
//TODO : Do we need to test individual obs, details and identifier fields?
System.out.println(questionnaireResponse);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert number of items created, also assert for 2 obs one with single value and one with several variables

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

assertEquals(fihrTask.getBasedOn().get(0).getReference().getValue(), task.getPlanIdentifier());
assertEquals(fihrTask.getMeta().getVersionId().getValue(), String.valueOf(task.getServerVersion()));
assertEquals(fihrTask.getIntent().getValueAsEnumConstant().value(), "plan");
//TODO: Do we need to add assertions for Notes individually?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can test size of notes and one note is properly converted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

assertEquals(patient.getIdentifier().size(),identifiersSize);
assertEquals(patient.getBirthDate().getValue().toString(),client.getBirthdate().toString("YYYY-MM-DD"));
assertEquals(patient.getDeceased().as(com.ibm.fhir.model.type.DateTime.class).getValue().toString(),client.getDeathdate().toString("yyyy-MM-dd'T'HH:mm'Z'"));
//TODO : Individual assertions on relationships, attributes and identifiers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test number of size of relationships, attributes and identifiers converted is accurate and also assert one item from each category

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@githengi githengi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the first param is expected and second is actual for assertEquals update this for all such assertions

Comment on lines 112 to 119
FHIRPathElementNode node = PathEvaluatorLibrary.getInstance().evaluateElementExpression(questionnaireResponse, "QuestionnaireResponse.item.where(linkId='totPopulation')");
QuestionnaireResponse.Item totPopulation = node.element().as(QuestionnaireResponse.Item.class);
assertEquals(1,totPopulation.getAnswer().size());
assertEquals(com.ibm.fhir.model.type.String.of("2"),totPopulation.getAnswer().get(0).getValue());
node = PathEvaluatorLibrary.getInstance().evaluateElementExpression(questionnaireResponse, "QuestionnaireResponse.item.where(linkId='existingLLINs')");

QuestionnaireResponse.Item existingLLINs = node.element().as(QuestionnaireResponse.Item.class);
assertEquals(2, existingLLINs.getAnswer().size()); //Test for multiple values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed this instead of looping for all the items to use FHIRPath expressions to look up obs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

assertEquals(patient.getDeceased().as(com.ibm.fhir.model.type.DateTime.class).getValue().toString(),
client.getDeathdate().toString("yyyy-MM-dd'T'HH:mm'Z'"));
for (Identifier identifier : patient.getIdentifier()) {
if (identifier.getSystem() != null && identifier.getSystem().getValue()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use fhirpath expressions for lookup as if the identifier does not exist then test will fail. With this approach of looping tests will fail if identifiers don't exist

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@githengi githengi merged commit 678eab6 into master Jun 22, 2020
@githengi githengi deleted the 26-unit-tests-converters branch June 22, 2020 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unit test converters
2 participants