Add Unit tests and test data for Laboratory Handler

I’m currently working on this ticket where I’m expected to add Unit tests and test data for Laboratory Handler. However, I have encountered some challenges in the process.
When I run a mvn install on the module, it builds successfully, but when I run:

mvn -Dtest=DiagnosticReportServiceTest test

It fails with this error log. Why could this be happening?
cc: @harsha89 , @dkayiwa

Ignoring the above,

public void getGlobalProperty_shouldReturnGlobalProperty() {
   //This returns a null global property.	
	String globalProperty = Context.getAdministrationService().getGlobalProperty("fhir.diagnosticreport.result");
	assertNotNull("Global Property shouldn't be null", globalProperty);

The above String “fhir.diagnosticreport.result” returns a null global Property. Please if I have a wrong perception towards this, feel free to correct me. Otherwise this breaks subsequent API calls like DiagnosticReportService.getDiagnosticReport(String id) which later depends on FHIRUtils.getDiagnosticReportResultConcept() that breaks the call by returning a null globalProperty. I’m not sure why this is happening :frowning: . Could any one look into this and direct me on how to fix it?
cc @harsha89 , @dkayiwa , @darius

Is this before making your change or after?

Do you have this global property set?

Thanks for looking into this,
This is a new behavior to my experience, this doesn’t happen after my changes, even on a freshly cloned module. But surprisingly a full maven build runs successfully.

Can you try running the test from your IDE?

Nope, its statically included in the API, here . Am not soo sure why this happens, do I need to first set the property? If so, do you mind directing me how to!

The errors I see here are not consistent with your second post. Can you explain exactly what you are doing, what behavior where you expecting and what behavior you are getting.

Running the tests in the IDE works fine :slight_smile:

The first post is different from the second, I ignored the first post and looked at my current blocker.

Ok and is it ok now? Also would be nice to quote what reply you are responding to as I’m getting lost with the mixed up replies.

What I expect is that the Global Property of key “fhir.diagnosticreport.result” should be included by default at the dev of the module since It was hard coded in the API. Could I be wrong at this?

I’m sorry about that :wink:

You did not answer the question properly. My question had 3 parts.

Part 1: What are you doing?

Part 2: What behavior expecting

Part 3: What behavior are you getting instead

If I know what you are doing, I can try to do same and see if I will get the behavior you are getting.

I’m working on this ticket basically adding Unit tests and test data for LaboratoryHandler via DiagnosticReportServiceImpl . I came up with some unit tests like

public void getDiagnosticReport_shouldReturnDiagnosticReport() throws Exception {
	DiagnosticReportService service = getService();
	DiagnosticReport report = service.getDiagnosticReport("6bdec581-23aa-45fd-b578-413897aa6e8a");

However, this test fails due the mention below

Its because of the method that returns a null GlobalProperty that fails this out

I expect a Diagnostic Report to be returned

But generally what that error is saying is that you are fetching a global property that doesn’t exist. To debug first thing is check the property id to make sure you have it right. If you have it right then you need to make sure the property actually exists. To do that depends on whether it’s failing at runtime or within a unit test. If it’s within a unit test you have to check the XxxTestDataset.xml file for that unit test to see if they specified a global property with that id. If it’s at runtime then you can check in the config.xml or from the web application administration section.

Its not even returning a null report object but breaks in the API somewhere here

1 Like

I understand now the problem you are having. See if my response above is helpful.

My ideal or perception towards this is that, since it was already included in the API statically, it should have already been included here, I expect it to be already included in a certain dataSet but I have seen none :frowning: