Skip to content

Commit

Permalink
FM2-312: Minor refactoring on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruhanga committed Dec 14, 2020
1 parent b415c07 commit 0d686a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,6 @@ public void setup() {
medicationRequest = new MedicationRequest();
medicationRequest.setId(DRUG_ORDER_UUID);

try {
Class clazz = drugOrder.getClass();
Field orderNumberField = clazz.getSuperclass().getDeclaredField("orderNumber");
Boolean isAccessible = orderNumberField.isAccessible();
if (!isAccessible) {
orderNumberField.setAccessible(true);
}
orderNumberField.set(((Order) drugOrder), "ORD-1");
}
catch (Exception e) {
e.printStackTrace();
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.Identifier;
import org.hl7.fhir.r4.model.Period;
import org.hl7.fhir.r4.model.Reference;
import org.hl7.fhir.r4.model.Identifier;
import org.hl7.fhir.r4.model.ServiceRequest;
import org.hl7.fhir.r4.model.Task;
import org.junit.Before;
Expand Down Expand Up @@ -493,29 +493,29 @@ public void toFhirResource_shouldTranslateRequester() {
assertThat(result.getReference(), containsString(PRACTITIONER_UUID));
}

@Test
public void toFhirResource_shouldTranslateOrderNumber() {
TestOrder order = new TestOrder();
Provider requester = new Provider();
Reference requesterReference = new Reference();
requester.setUuid(PRACTITIONER_UUID);
order.setUuid(SERVICE_REQUEST_UUID);
order.setOrderer(requester);
setOrderNumberByReflection(order, TEST_ORDER_NUMBER);
requesterReference.setType(FhirConstants.PRACTITIONER)
.setReference(FhirConstants.PRACTITIONER + "/" + PRACTITIONER_UUID);
when(taskService.searchForTasks(any(), any(), any(), any(), any(), any()))
.thenReturn(new MockIBundleProvider<>(Collections.emptyList(), PREFERRED_PAGE_SIZE, COUNT));
when(practitionerReferenceTranslator.toFhirResource(requester)).thenReturn(requesterReference);
Identifier result = translator.toFhirResource(order).getIdentifier().get(0);
assertThat(result, notNullValue());
assertThat(result.getValue(), containsString(TEST_ORDER_NUMBER));
}
@Test
public void toFhirResource_shouldTranslateOrderNumber() {

TestOrder order = new TestOrder();
Provider requester = new Provider();
Reference requesterReference = new Reference();

requester.setUuid(PRACTITIONER_UUID);
order.setUuid(SERVICE_REQUEST_UUID);
order.setOrderer(requester);
setOrderNumberByReflection(order, TEST_ORDER_NUMBER);
requesterReference.setType(FhirConstants.PRACTITIONER)
.setReference(FhirConstants.PRACTITIONER + "/" + PRACTITIONER_UUID);

when(taskService.searchForTasks(any(), any(), any(), any(), any(), any()))
.thenReturn(new MockIBundleProvider<>(Collections.emptyList(), PREFERRED_PAGE_SIZE, COUNT));
when(practitionerReferenceTranslator.toFhirResource(requester)).thenReturn(requesterReference);

Identifier result = translator.toFhirResource(order).getIdentifier().get(0);

assertThat(result, notNullValue());
assertThat(result.getValue(), containsString(TEST_ORDER_NUMBER));
}

private List<Task> setUpBasedOnScenario(Task.TaskStatus status) {
Reference basedOnRef = new Reference();
Expand Down

0 comments on commit 0d686a0

Please sign in to comment.