From 80176455ad00f3ac3dd67c7a316a5c53ba3ef0fe Mon Sep 17 00:00:00 2001 From: hospel <12736698+ole4ryb@users.noreply.github.com> Date: Fri, 26 Jul 2024 14:31:59 +0100 Subject: [PATCH] small code optimizations --- .../pss/translator/service/ConfidentialityService.java | 2 +- .../mapper/medication/MedicationMapperUtilsTest.java | 8 ++++---- .../medication/MedicationRequestOrderMapperTest.java | 4 ++-- .../medication/MedicationRequestPlanMapperTest.java | 2 +- .../mapper/medication/MedicationStatementMapperTest.java | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/service/ConfidentialityService.java b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/service/ConfidentialityService.java index a1eb60761..663553ce4 100644 --- a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/service/ConfidentialityService.java +++ b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/service/ConfidentialityService.java @@ -26,6 +26,6 @@ public final Meta createMetaAndAddSecurityIfConfidentialityCodesPresent(String m } private boolean isNopat(CV coding) { - return coding.getCode().equals("NOPAT"); + return "NOPAT".equals(coding.getCode()); } } \ No newline at end of file diff --git a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationMapperUtilsTest.java b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationMapperUtilsTest.java index 2b9e92ae6..7c9247cab 100644 --- a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationMapperUtilsTest.java +++ b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationMapperUtilsTest.java @@ -40,7 +40,7 @@ public void When_CreatingMedicationRequest_Expect_ContextAndSubjectMappedAppropr public void When_CreatingPrescriptionTypeExtension_Expect_AcuteValues() { var supplyAuth = unmarshallSupplyAuthorise("buildPrescriptionAcute.xml"); var extension = MedicationMapperUtils.buildPrescriptionTypeExtension(supplyAuth); - assertThat(extension.isPresent()).isTrue(); + assertThat(extension).isPresent(); extension.ifPresent(extension1 -> { assertThat(extension1.getValue()).isInstanceOf(CodeableConcept.class); var codeableConcept = (CodeableConcept) extension1.getValue(); @@ -52,7 +52,7 @@ public void When_CreatingPrescriptionTypeExtension_Expect_AcuteValues() { public void When_CreatingPrescriptionTypeExtension_Expect_RepeatValues() { var supplyAuth = unmarshallSupplyAuthorise("buildPrescriptionRepeat.xml"); var extension = MedicationMapperUtils.buildPrescriptionTypeExtension(supplyAuth); - assertThat(extension.isPresent()).isTrue(); + assertThat(extension).isPresent(); extension.ifPresent(extension1 -> { assertThat(extension1.getValue()).isInstanceOf(CodeableConcept.class); var codeableConcept = (CodeableConcept) extension1.getValue(); @@ -89,7 +89,7 @@ public void When_CreatingDosageQuantity_Expect_ValueToBeMapped() { var supplyAuth = unmarshallSupplyAuthorise("supplyWithQuantity.xml"); var quantity = MedicationMapperUtils.buildDosageQuantity(supplyAuth.getQuantity()); - assertThat(quantity.isPresent()).isTrue(); + assertThat(quantity).isPresent(); quantity.ifPresent(value -> { assertThat(value.getValue().intValue()).isEqualTo(EXPECTED_QUANTITY_SIZE); assertThat(value.getUnit()).isEqualTo("capsule"); @@ -108,7 +108,7 @@ public void When_ExtractingSupplyAuthoriseId_Expect_IdToBeExtractedCorrectly() { var supplyAuth = unmarshallSupplyAuthorise("supplyWithInvalidQuantity.xml"); var authoriseId = MedicationMapperUtils.extractEhrSupplyAuthoriseId(supplyAuth); - assertThat(authoriseId.isPresent()).isTrue(); + assertThat(authoriseId).isPresent(); authoriseId.ifPresent( id -> { assertThat(id).isEqualTo(AUTHORISE_ID); diff --git a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationRequestOrderMapperTest.java b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationRequestOrderMapperTest.java index 49df23a0e..372ac2717 100644 --- a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationRequestOrderMapperTest.java +++ b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationRequestOrderMapperTest.java @@ -61,7 +61,7 @@ public void When_MappingPrescribeResourceWithAllOptionals_Expect_AllFieldsToBeMa when(medicationMapper.extractMedicationReference(any())) .thenReturn(Optional.of(new Reference(new IdType(ResourceType.Medication.name(), MEDICATION_ID)))); - assertThat(prescribe.isPresent()).isTrue(); + assertThat(prescribe).isPresent(); var medicationRequest = medicationRequestOrderMapper.mapToOrderMedicationRequest(new RCMRMT030101UKEhrExtract(), medicationStatement, prescribe.get(), PRACTISE_CODE); assertCommonValues(medicationRequest); @@ -88,7 +88,7 @@ public void When_MappingPrescribeResourceWithNoOptionals_Expect_AllFieldsToBeMap when(medicationMapper.extractMedicationReference(any())) .thenReturn(Optional.of(new Reference(new IdType(ResourceType.Medication.name(), MEDICATION_ID)))); - assertThat(prescribe.isPresent()).isTrue(); + assertThat(prescribe).isPresent(); var medicationRequest = medicationRequestOrderMapper.mapToOrderMedicationRequest(new RCMRMT030101UKEhrExtract(), medicationStatement, prescribe.get(), PRACTISE_CODE); assertCommonValues(medicationRequest); diff --git a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationRequestPlanMapperTest.java b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationRequestPlanMapperTest.java index c1c6a4dc1..f87420418 100644 --- a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationRequestPlanMapperTest.java +++ b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationRequestPlanMapperTest.java @@ -229,7 +229,7 @@ public void When_MappingAuthoriseResourceEffectiveTimeWithNullHighValue_Expect_N final var repeatInformation = medicationRequest.getExtensionsByUrl(REPEAT_INFO_URL); assertThat(repeatInformation).hasSize(1); - assertThat(repeatInformation.get(0).getExtensionsByUrl(REPEATS_EXPIRY_DATE_URL)).hasSize(0); + assertThat(repeatInformation.get(0).getExtensionsByUrl(REPEATS_EXPIRY_DATE_URL)).isEmpty(); } @Test diff --git a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationStatementMapperTest.java b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationStatementMapperTest.java index 560b6f587..298666e1f 100644 --- a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationStatementMapperTest.java +++ b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/medication/MedicationStatementMapperTest.java @@ -64,7 +64,7 @@ public void When_MappingPrescribeResourceWithNoOptionals_Expect_AllFieldsToBeMap when(medicationMapper.extractMedicationReference(any())) .thenReturn(Optional.of(new Reference(new IdType(ResourceType.Medication.name(), MEDICATION_ID)))); - assertThat(authorise.isPresent()).isTrue(); + assertThat(authorise).isPresent(); var medicationStatement1 = medicationStatementMapper.mapToMedicationStatement( ehrExtract, medicationStatement, authorise.get(), PRACTISE_CODE, new DateTimeType()); @@ -96,7 +96,7 @@ public void When_MappingPrescribeResourceWithNoLastIssueDate_Expect_AllFieldsToB when(medicationMapper.extractMedicationReference(any())) .thenReturn(Optional.of(new Reference(new IdType(ResourceType.Medication.name(), MEDICATION_ID)))); - assertThat(authorise.isPresent()).isTrue(); + assertThat(authorise).isPresent(); var medicationStatement1 = medicationStatementMapper.mapToMedicationStatement( new RCMRMT030101UKEhrExtract(), medicationStatement, authorise.get(), PRACTISE_CODE, new DateTimeType()); @@ -222,10 +222,10 @@ private RCMRMT030101UKEhrExtract unmarshallEhrExtract(String fileName) { private MedicationStatement mapMedicationStatementFromEhrFile(String filename, DateTimeType authoredOn) { var ehrExtract = unmarshallEhrExtract(filename); var medicationStatement = extractMedicationStatement(ehrExtract); - assertThat(medicationStatement.isPresent()).isTrue(); + assertThat(medicationStatement).isPresent(); var authorise = extractAuthorise(medicationStatement.orElseThrow()); - assertThat(authorise.isPresent()).isTrue(); + assertThat(authorise).isPresent(); when(medicationMapper.extractMedicationReference(any())) .thenReturn(Optional.of(new Reference(new IdType(ResourceType.Medication.name(), MEDICATION_ID))));