From 7f58602626a46108fbd87cacad1312eaafbc11db Mon Sep 17 00:00:00 2001 From: Michael Seaton Date: Fri, 20 Dec 2024 13:16:52 -0500 Subject: [PATCH] Additional fixes to mocked context sensitive tests --- .../impl/PersonNameTranslatorImplTest.java | 47 ------------------- 1 file changed, 47 deletions(-) diff --git a/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/PersonNameTranslatorImplTest.java b/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/PersonNameTranslatorImplTest.java index e96aeb9b0..5cea64418 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/PersonNameTranslatorImplTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/PersonNameTranslatorImplTest.java @@ -16,11 +16,6 @@ import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notNullValue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.Arrays; -import java.util.Collections; import org.hl7.fhir.r4.model.Extension; import org.hl7.fhir.r4.model.HumanName; @@ -30,12 +25,7 @@ import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; import org.openmrs.PersonName; -import org.openmrs.api.AdministrationService; -import org.openmrs.layout.name.NameSupport; -import org.openmrs.layout.name.NameTemplate; import org.openmrs.module.fhir2.FhirConstants; -import org.openmrs.serialization.SerializationException; -import org.openmrs.serialization.SimpleXStreamSerializer; @RunWith(MockitoJUnitRunner.class) public class PersonNameTranslatorImplTest { @@ -165,43 +155,6 @@ public void shouldOnlyCreateOneExtensionForExtensibleAttributes() { assertThat(extension.getExtension().size(), greaterThan(1)); } - @Test - public void shouldUseDefaultNameTemplateToSetNameText() throws SerializationException { - AdministrationService administrationService = mock(AdministrationService.class); - when(administrationService.getGlobalProperty("layout.name.format")).thenReturn("test"); - - NameSupport nameSupportInstance = new NameSupport(); - NameTemplate customNameTemplate = new SimpleXStreamSerializer() - .deserialize("\n" + " test\n" - + " Test Name Format\n" + " \n" - + " \n" - + " \n" - + " \n" + " \n" - + " \n" + " \n" - + " \n" - + " \n" + " \n" - + " \n" + " givenName\n" + " familyName\n" - + " middleName\n" + " \n" + " \n" - + " givenName\n" + " familyName\n" - + " \n" + "", - NameTemplate.class); - nameSupportInstance.setLayoutTemplates(Collections.singletonList(customNameTemplate)); - nameSupportInstance.setSpecialTokens(Arrays.asList("prefix", "givenName", "middleName", "familyNamePrefix", - "familyNameSuffix", "familyName2", "familyName", "degree")); - - PersonName name = new PersonName(); - name.setGivenName(PERSON_GIVEN_NAME); - name.setMiddleName(PERSON_MIDDLE_NAME); - name.setFamilyName(PERSON_FAMILY_NAME); - - HumanName fhirName = personNameTranslator.toFhirResource(name); - - assertThat(fhirName, notNullValue()); - assertThat(fhirName.getTextElement(), notNullValue()); - assertThat(fhirName.getTextElement().getValue(), - equalTo(PERSON_GIVEN_NAME + " " + PERSON_FAMILY_NAME + " " + PERSON_MIDDLE_NAME)); - } - @Test public void shouldConvertHumanNameToPersonName() { HumanName name = new HumanName();