From 90f8a63cba5470d99e094e2a7650b8cc4e203065 Mon Sep 17 00:00:00 2001 From: David B Malkovsky Date: Wed, 4 Dec 2024 10:58:26 -0500 Subject: [PATCH 1/2] Chore: JUnit5 test classes and methods should have default package visibility (#511) --- .../isf/OpenHospitalApiApplicationTests.java | 4 +- .../accounting/rest/BillControllerTest.java | 36 +++++++++--------- .../rest/AdmissionControllerTest.java | 28 +++++++------- .../rest/AdmissionTypeControllerTest.java | 12 +++--- .../agetype/rest/AgeTypeControllerTest.java | 12 +++--- .../rest/DischargeTypeControllerTest.java | 12 +++--- .../disease/rest/DiseaseControllerTest.java | 30 +++++++-------- .../rest/DiseaseTypeControllerTest.java | 12 +++--- .../DeliveryResultTypeControllerTest.java | 12 +++--- .../rest/DeliveryTypeControllerTest.java | 12 +++--- .../org/isf/exam/rest/ExamControllerTest.java | 4 +- .../isf/exam/rest/ExamRowControllerTest.java | 2 +- .../rest/ExaminationControllerTest.java | 2 +- .../exatype/rest/ExamTypeControllerTest.java | 2 +- .../lab/rest/LaboratoryControllerTest.java | 10 ++--- .../isf/login/rest/LoginControllerTest.java | 4 +- .../org/isf/opd/rest/OpdControllerTest.java | 6 +-- .../rest/OperationControllerTest.java | 12 +++--- .../patient/rest/PatientControllerTest.java | 38 +++++++++---------- .../java/org/isf/security/JWTFilterTest.java | 24 ++++++------ .../org/isf/security/TokenProviderTest.java | 36 +++++++++--------- .../supplier/rest/SupplierControllerTest.java | 4 +- .../rest/UserGroupControllerTest.java | 4 +- .../isf/users/rest/UserControllerTest.java | 6 +-- .../rest/UserSettingControllerTest.java | 4 +- .../vaccine/rest/VaccineControllerTest.java | 14 +++---- .../rest/VaccineTypeControllerTest.java | 14 +++---- .../isf/visits/rest/VisitsControllerTest.java | 12 +++--- .../org/isf/ward/rest/WardControllerTest.java | 22 +++++------ 29 files changed, 195 insertions(+), 195 deletions(-) diff --git a/src/test/java/org/isf/OpenHospitalApiApplicationTests.java b/src/test/java/org/isf/OpenHospitalApiApplicationTests.java index 2aa6864b6..97e5af6fe 100644 --- a/src/test/java/org/isf/OpenHospitalApiApplicationTests.java +++ b/src/test/java/org/isf/OpenHospitalApiApplicationTests.java @@ -27,10 +27,10 @@ @ExtendWith(SpringExtension.class) @SpringBootTest -public class OpenHospitalApiApplicationTests { +class OpenHospitalApiApplicationTests { // @Test -// public void contextLoads() { +// void contextLoads() { // /* // * Context loading is working correctly. However, since this test does not provide any additional value and may actually slow down the tests execution, // * it's recommended to remove it. The loading context is implicitly tested by other tests that run as SpringBootTest. diff --git a/src/test/java/org/isf/accounting/rest/BillControllerTest.java b/src/test/java/org/isf/accounting/rest/BillControllerTest.java index f9ebd272d..8b6fc10e8 100644 --- a/src/test/java/org/isf/accounting/rest/BillControllerTest.java +++ b/src/test/java/org/isf/accounting/rest/BillControllerTest.java @@ -96,7 +96,7 @@ /** * @author Emerson Castaneda */ -public class BillControllerTest extends ControllerBaseTest { +class BillControllerTest extends ControllerBaseTest { private static final Logger LOGGER = LoggerFactory.getLogger(BillControllerTest.class); @@ -122,7 +122,7 @@ public class BillControllerTest extends ControllerBaseTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new BillController(billManagerMock, priceListManagerMock, patientManagerMock, billMapper, billItemsMapper, billPaymentsMapper)) @@ -147,7 +147,7 @@ void closeService() throws Exception { } @Test - public void when_post_bills_is_call_without_contentType_header_then_HttpMediaTypeNotSupportedException() throws Exception { + void when_post_bills_is_call_without_contentType_header_then_HttpMediaTypeNotSupportedException() throws Exception { String request = "/bills"; MvcResult result = this.mockMvc @@ -167,7 +167,7 @@ public void when_post_bills_is_call_without_contentType_header_then_HttpMediaTyp } @Test - public void when_post_bills_is_call_with_empty_body_then_BadRequest_HttpMessageNotReadableException() throws Exception { + void when_post_bills_is_call_with_empty_body_then_BadRequest_HttpMessageNotReadableException() throws Exception { String request = "/bills"; String empty_body = ""; @@ -191,7 +191,7 @@ public void when_post_bills_is_call_with_empty_body_then_BadRequest_HttpMessageN } @Test - public void when_post_patients_PatientBrowserManager_getPatient_returns_null_then_OHAPIException_BadRequest() throws Exception { + void when_post_patients_PatientBrowserManager_getPatient_returns_null_then_OHAPIException_BadRequest() throws Exception { String request = "/bills"; FullBillDTO newFullBillDTO = FullBillDTOHelper.setup(patientMapper, billItemsMapper, billPaymentsMapper); Integer id = 0; @@ -223,7 +223,7 @@ public void when_post_patients_PatientBrowserManager_getPatient_returns_null_the } @Test - public void when_put_bills_PatientBrowserManager_getPatient_returns_null_then_OHAPIException_BadRequest() throws Exception { + void when_put_bills_PatientBrowserManager_getPatient_returns_null_then_OHAPIException_BadRequest() throws Exception { Integer id = 123; String request = "/bills/{id}"; @@ -256,7 +256,7 @@ public void when_put_bills_PatientBrowserManager_getPatient_returns_null_then_OH } @Test - public void when_put_bills_PatientBrowserManager_getPatient_returns_null_then_OK() throws Exception { + void when_put_bills_PatientBrowserManager_getPatient_returns_null_then_OK() throws Exception { Integer id = 123; String request = "/bills/{id}"; FullBillDTO newFullBillDTO = FullBillDTOHelper.setup(patientMapper, billItemsMapper, billPaymentsMapper); @@ -309,7 +309,7 @@ public void when_put_bills_PatientBrowserManager_getPatient_returns_null_then_OK } @Test - public void when_get_items_with_existent_id_then_getItems_returns_items_and_OK() throws Exception { + void when_get_items_with_existent_id_then_getItems_returns_items_and_OK() throws Exception { Integer id = 123; String request = "/bills/items/{bill_id}"; @@ -332,7 +332,7 @@ public void when_get_items_with_existent_id_then_getItems_returns_items_and_OK() } @Test - public void when_get_items_with_existent_id_then_getItems_is_empty_and_isNoContent() throws Exception { + void when_get_items_with_existent_id_then_getItems_is_empty_and_isNoContent() throws Exception { Integer id = 123; String request = "/bills/items/{bill_id}"; @@ -346,7 +346,7 @@ public void when_get_items_with_existent_id_then_getItems_is_empty_and_isNoConte } @Test - public void when_get_bill_with_existent_id_then_response_BillDTO_and_OK() throws Exception { + void when_get_bill_with_existent_id_then_response_BillDTO_and_OK() throws Exception { int id = 123; String request = "/bills/{id}"; @@ -367,7 +367,7 @@ public void when_get_bill_with_existent_id_then_response_BillDTO_and_OK() throws } @Test - public void when_delete_bill_with_existent_id_then_response_true_and_OK() throws Exception { + void when_delete_bill_with_existent_id_then_response_true_and_OK() throws Exception { int id = 123; String request = "/bills/{id}"; @@ -386,7 +386,7 @@ public void when_delete_bill_with_existent_id_then_response_true_and_OK() throws } @Test - public void when_get_bill_pending_affiliate_with_existent_patient_code_then_response_List_of_BillDTO_and_OK() throws Exception { + void when_get_bill_pending_affiliate_with_existent_patient_code_then_response_List_of_BillDTO_and_OK() throws Exception { int code = 123; String request = "/bills/pending/affiliate?patient_code={code}"; @@ -409,7 +409,7 @@ public void when_get_bill_pending_affiliate_with_existent_patient_code_then_resp } @Test - public void when_post_searchBillsByPayments_with_a_list_of_existent_billsPaymentsDTO_then_response_List_of_BillDTO_and_OK() throws Exception { + void when_post_searchBillsByPayments_with_a_list_of_existent_billsPaymentsDTO_then_response_List_of_BillDTO_and_OK() throws Exception { String request = "/bills/search/by/payments"; List billsPaymentsList = BillPaymentsDTOHelper.genListModel(2, billPaymentsMapper); @@ -435,7 +435,7 @@ public void when_post_searchBillsByPayments_with_a_list_of_existent_billsPayment } @Test - public void when_get_pendingBills_with_existent_patient_code_then_response_List_of_BillDTO_and_OK() throws Exception { + void when_get_pendingBills_with_existent_patient_code_then_response_List_of_BillDTO_and_OK() throws Exception { int code = 123; String request = "/bills/pending?patient_code={code}"; @@ -461,7 +461,7 @@ public void when_get_pendingBills_with_existent_patient_code_then_response_List_ } @Test - public void when_post_searchBillsByItem_with_valid_dates_and_billItemsDTO_content_and_PatientBrowserManager_getBills_returns_billList_then_OK() + void when_post_searchBillsByItem_with_valid_dates_and_billItemsDTO_content_and_PatientBrowserManager_getBills_returns_billList_then_OK() throws Exception { String request = "/bills/search/by/item?datefrom={dateFrom}&dateto={dateTo}"; String dateFrom = LocalDateTime.now().format(DateTimeFormatter.ofPattern(Constants.DATE_FORMAT_YYYY_MM_DD_T_HH_MM_SS_SSS_Z)); @@ -494,7 +494,7 @@ public void when_post_searchBillsByItem_with_valid_dates_and_billItemsDTO_conten } @Test - public void when_get_searchBills_with_valid_dates_and_valid_patient_code_and_PatientBrowserManager_getBills_returns_billList_then_OK() throws Exception { + void when_get_searchBills_with_valid_dates_and_valid_patient_code_and_PatientBrowserManager_getBills_returns_billList_then_OK() throws Exception { String request = "/bills?datefrom={dateFrom}&dateto={dateTo}&patient_code={patient_code}"; String dateFrom = LocalDateTime.now().format(DateTimeFormatter.ofPattern(Constants.DATE_FORMAT_YYYY_MM_DD_T_HH_MM_SS_SSS_Z)); String dateTo = LocalDateTime.now().format(DateTimeFormatter.ofPattern(Constants.DATE_FORMAT_YYYY_MM_DD_T_HH_MM_SS_SSS_Z)); @@ -524,7 +524,7 @@ public void when_get_searchBills_with_valid_dates_and_valid_patient_code_and_Pat } @Test - public void when_get_getDistinctItems_BillBrowserManager_getDistinctItems_returns_BillItemsDTOList_then_OK() throws Exception { + void when_get_getDistinctItems_BillBrowserManager_getDistinctItems_returns_BillItemsDTOList_then_OK() throws Exception { String request = "/bills/items"; //TODO move to a Helper once it duplicates somewhere else @@ -553,7 +553,7 @@ public void when_get_getDistinctItems_BillBrowserManager_getDistinctItems_return } @Test - public void when_get_getPaymentsByBillId_with_valid_bill_id_and_BillBrowserManager_getPayments_returns_BillPaymentsList_then_OK() throws Exception { + void when_get_getPaymentsByBillId_with_valid_bill_id_and_BillBrowserManager_getPayments_returns_BillPaymentsList_then_OK() throws Exception { String request = "/bills/payments/{bill_id}"; int billId = 123; diff --git a/src/test/java/org/isf/admission/rest/AdmissionControllerTest.java b/src/test/java/org/isf/admission/rest/AdmissionControllerTest.java index 7ec9377e3..0caac3b2e 100644 --- a/src/test/java/org/isf/admission/rest/AdmissionControllerTest.java +++ b/src/test/java/org/isf/admission/rest/AdmissionControllerTest.java @@ -83,7 +83,7 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -public class AdmissionControllerTest { +class AdmissionControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(AdmissionControllerTest.class); @@ -122,13 +122,13 @@ public class AdmissionControllerTest { private AutoCloseable closeable; - public AdmissionControllerTest() { + AdmissionControllerTest() { admittedMapper = new AdmittedPatientMapper(); admissionMapper = new AdmissionMapper(); } @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new AdmissionController(admissionManagerMock, patientManagerMock, wardManagerMock, @@ -153,7 +153,7 @@ void closeService() throws Exception { } @Test - public void testGetCurrentAdmission_200() throws Exception { + void testGetCurrentAdmission_200() throws Exception { String request = "/admissions/current"; Integer patientCode = 1; @@ -179,7 +179,7 @@ public void testGetCurrentAdmission_200() throws Exception { } @Test - public void testGetAllAdmittedPatients_200() throws Exception { + void testGetAllAdmittedPatients_200() throws Exception { String request = "/admissions/admittedPatients"; List admittedPatients = PatientHelper.setupAdmittedPatientList(2); @@ -199,7 +199,7 @@ public void testGetAllAdmittedPatients_200() throws Exception { } @Test - public void testGetAdmittedPatientsSearch_200() throws Exception { + void testGetAdmittedPatientsSearch_200() throws Exception { String request = "/admissions/admittedPatients?searchterms={searchTerms}"; List admittedPatients = PatientHelper.setupAdmittedPatientList(2); @@ -219,7 +219,7 @@ public void testGetAdmittedPatientsSearch_200() throws Exception { } @Test - public void testGetAdmittedPatients_200() throws Exception { + void testGetAdmittedPatients_200() throws Exception { String request = "/admissions/admittedPatients?searchterms={searchTerms}&admissionRange={admissionRange}&dischargeRange={dischargeRange}"; List admittedPatients = PatientHelper.setupAdmittedPatientList(2); @@ -240,7 +240,7 @@ public void testGetAdmittedPatients_200() throws Exception { } @Test - public void testGetPatientAdmissions_200() throws Exception { + void testGetPatientAdmissions_200() throws Exception { int patientCode = 1; String request = "/admissions/patient/{patientCode}" ; @@ -265,7 +265,7 @@ public void testGetPatientAdmissions_200() throws Exception { } @Test - public void testGetNextYProgressiveId_200() throws Exception { + void testGetNextYProgressiveId_200() throws Exception { String request = "/admissions/getNextProgressiveIdInYear"; String wardCode = "1"; @@ -291,7 +291,7 @@ public void testGetNextYProgressiveId_200() throws Exception { } @Test - public void testGetUsedWardBed_200() throws Exception { + void testGetUsedWardBed_200() throws Exception { String request = "/admissions/getBedsOccupationInWard?wardid={wardCode}"; String wardCode = "1"; @@ -315,7 +315,7 @@ public void testGetUsedWardBed_200() throws Exception { } @Test - public void testDeleteAdmission_200() throws Exception { + void testDeleteAdmission_200() throws Exception { int id = 123; String request = "/admissions/{id}"; @@ -334,7 +334,7 @@ public void testDeleteAdmission_200() throws Exception { } @Test - public void testDischargeAdmission_200() throws Exception { + void testDischargeAdmission_200() throws Exception { Integer patientCode = 1; String request = "/admissions/discharge"; @@ -373,7 +373,7 @@ public void testDischargeAdmission_200() throws Exception { } @Test - public void testNewAdmissions_201() throws Exception { + void testNewAdmissions_201() throws Exception { String request = "/admissions"; Integer id = 1; @@ -424,7 +424,7 @@ public void testNewAdmissions_201() throws Exception { } @Test - public void testUpdateAdmissions() throws Exception { + void testUpdateAdmissions() throws Exception { String request = "/admissions"; AdmissionDTO body = AdmissionHelper.setup(admissionMapper); diff --git a/src/test/java/org/isf/admtype/rest/AdmissionTypeControllerTest.java b/src/test/java/org/isf/admtype/rest/AdmissionTypeControllerTest.java index 88d4f9f28..7f34e5666 100644 --- a/src/test/java/org/isf/admtype/rest/AdmissionTypeControllerTest.java +++ b/src/test/java/org/isf/admtype/rest/AdmissionTypeControllerTest.java @@ -55,7 +55,7 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -public class AdmissionTypeControllerTest { +class AdmissionTypeControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(AdmissionTypeControllerTest.class); @@ -69,7 +69,7 @@ public class AdmissionTypeControllerTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new AdmissionTypeController(admissionTypeManagerMock, admissionTypemapper)) @@ -87,7 +87,7 @@ void closeService() throws Exception { } @Test - public void testNewAdmissionType_201() throws Exception { + void testNewAdmissionType_201() throws Exception { String request = "/admissiontypes"; AdmissionTypeDTO body = AdmissionTypeDTOHelper.setup(admissionTypemapper); @@ -113,7 +113,7 @@ public void testNewAdmissionType_201() throws Exception { } @Test - public void testUpdateAdmissionType_200() throws Exception { + void testUpdateAdmissionType_200() throws Exception { String request = "/admissiontypes"; AdmissionTypeDTO body = AdmissionTypeDTOHelper.setup(admissionTypemapper); AdmissionType admissionType = new AdmissionType("ZZ", "aDescription"); @@ -138,7 +138,7 @@ public void testUpdateAdmissionType_200() throws Exception { } @Test - public void testGetAdmissionTypes_200() throws Exception { + void testGetAdmissionTypes_200() throws Exception { String request = "/admissiontypes"; AdmissionType admissionType = new AdmissionType("ZZ", "aDescription"); @@ -158,7 +158,7 @@ public void testGetAdmissionTypes_200() throws Exception { } @Test - public void testDeleteAdmissionType_200() throws Exception { + void testDeleteAdmissionType_200() throws Exception { String request = "/admissiontypes/{code}"; AdmissionTypeDTO body = AdmissionTypeDTOHelper.setup(admissionTypemapper); String code = body.getCode(); diff --git a/src/test/java/org/isf/agetype/rest/AgeTypeControllerTest.java b/src/test/java/org/isf/agetype/rest/AgeTypeControllerTest.java index 043fde23c..c1b8d7759 100644 --- a/src/test/java/org/isf/agetype/rest/AgeTypeControllerTest.java +++ b/src/test/java/org/isf/agetype/rest/AgeTypeControllerTest.java @@ -58,7 +58,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; -public class AgeTypeControllerTest { +class AgeTypeControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(AgeTypeControllerTest.class); @@ -74,7 +74,7 @@ public class AgeTypeControllerTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new AgeTypeController(ageTypeManagerMock, ageTypeMapper)) @@ -92,7 +92,7 @@ void closeService() throws Exception { } @Test - public void testGetAllAgeTypes_200() throws Exception { + void testGetAllAgeTypes_200() throws Exception { String request = "/agetypes"; List results = AgeTypeHelper.genArrayList(5); @@ -113,7 +113,7 @@ public void testGetAllAgeTypes_200() throws Exception { } @Test - public void testUpdateAgeType_200() throws Exception { + void testUpdateAgeType_200() throws Exception { String request = "/agetypes"; List ageTypes = AgeTypeHelper.genList(5); List body = ageTypeMapper.map2DTOList(ageTypes); @@ -136,7 +136,7 @@ public void testUpdateAgeType_200() throws Exception { } @Test - public void testGetAgeTypeCodeByAge_200() throws Exception { + void testGetAgeTypeCodeByAge_200() throws Exception { String request = "/agetypes/code?age={age}"; int age = 10; @@ -158,7 +158,7 @@ public void testGetAgeTypeCodeByAge_200() throws Exception { } @Test - public void testGetAgeTypeByIndex_200() throws Exception { + void testGetAgeTypeByIndex_200() throws Exception { String request = "/agetypes/{index}"; int index = 10; AgeType ageType = AgeTypeHelper.setup(index); diff --git a/src/test/java/org/isf/disctype/rest/DischargeTypeControllerTest.java b/src/test/java/org/isf/disctype/rest/DischargeTypeControllerTest.java index 10f7666f1..b16589a02 100644 --- a/src/test/java/org/isf/disctype/rest/DischargeTypeControllerTest.java +++ b/src/test/java/org/isf/disctype/rest/DischargeTypeControllerTest.java @@ -57,7 +57,7 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -public class DischargeTypeControllerTest { +class DischargeTypeControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(DischargeTypeControllerTest.class); @@ -71,7 +71,7 @@ public class DischargeTypeControllerTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new DischargeTypeController(discTypeManagerMock, dischargeTypeMapper)) @@ -89,7 +89,7 @@ void closeService() throws Exception { } @Test - public void testNewDischargeType_201() throws Exception { + void testNewDischargeType_201() throws Exception { String request = "/dischargetypes"; String code = "ZZ"; DischargeType dischargeType = DischargeTypeHelper.setup(code); @@ -115,7 +115,7 @@ public void testNewDischargeType_201() throws Exception { } @Test - public void testUpdateDischargeType_200() throws Exception { + void testUpdateDischargeType_200() throws Exception { String request = "/dischargetypes"; String code = "ZZ"; DischargeType dischargeType = DischargeTypeHelper.setup(code); @@ -141,7 +141,7 @@ public void testUpdateDischargeType_200() throws Exception { } @Test - public void testGetDischargeTypes_200() throws Exception { + void testGetDischargeTypes_200() throws Exception { String request = "/dischargetypes"; DischargeType dischargeType = new DischargeType("ZZ", "aDescription"); @@ -164,7 +164,7 @@ public void testGetDischargeTypes_200() throws Exception { } @Test - public void testDeleteDischargeType_200() throws Exception { + void testDeleteDischargeType_200() throws Exception { String request = "/dischargetypes/{code}"; String code = "ZZ"; DischargeTypeDTO body = dischargeTypeMapper.map2DTO(DischargeTypeHelper.setup(code)); diff --git a/src/test/java/org/isf/disease/rest/DiseaseControllerTest.java b/src/test/java/org/isf/disease/rest/DiseaseControllerTest.java index 7a223436f..04bd2bde6 100644 --- a/src/test/java/org/isf/disease/rest/DiseaseControllerTest.java +++ b/src/test/java/org/isf/disease/rest/DiseaseControllerTest.java @@ -56,7 +56,7 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -public class DiseaseControllerTest { +class DiseaseControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(DiseaseControllerTest.class); @@ -70,7 +70,7 @@ public class DiseaseControllerTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new DiseaseController(diseaseBrowserManagerMock, diseaseMapper)) @@ -88,7 +88,7 @@ void closeService() throws Exception { } @Test - public void testGetDiseasesOpd_200() throws Exception { + void testGetDiseasesOpd_200() throws Exception { String request = "/diseases/opd"; List diseases = DiseaseHelper.setupDiseaseList(3); @@ -106,7 +106,7 @@ public void testGetDiseasesOpd_200() throws Exception { } @Test - public void testGetDiseasesOpdByCode_200() throws Exception { + void testGetDiseasesOpdByCode_200() throws Exception { String request = "/diseases/opd/{typecode}"; String typeCode = "1"; @@ -127,7 +127,7 @@ public void testGetDiseasesOpdByCode_200() throws Exception { } @Test - public void testGetDiseasesIpdOut_200() throws Exception { + void testGetDiseasesIpdOut_200() throws Exception { String request = "/diseases/ipd/out"; List diseases = DiseaseHelper.setupDiseaseList(3); @@ -146,7 +146,7 @@ public void testGetDiseasesIpdOut_200() throws Exception { } @Test - public void testGetDiseasesIpdOutByCode_200() throws Exception { + void testGetDiseasesIpdOutByCode_200() throws Exception { String request = "/diseases/ipd/out/{typecode}"; String typeCode = "1"; @@ -167,7 +167,7 @@ public void testGetDiseasesIpdOutByCode_200() throws Exception { } @Test - public void testGetDiseasesIpdIn_200() throws Exception { + void testGetDiseasesIpdIn_200() throws Exception { String request = "/diseases/ipd/in"; @@ -187,7 +187,7 @@ public void testGetDiseasesIpdIn_200() throws Exception { } @Test - public void testGetDiseasesIpdInByCode_200() throws Exception { + void testGetDiseasesIpdInByCode_200() throws Exception { String request = "/diseases/ipd/out/{typecode}"; String typeCode = "1"; @@ -208,7 +208,7 @@ public void testGetDiseasesIpdInByCode_200() throws Exception { } @Test - public void testGetDiseases_200() throws Exception { + void testGetDiseases_200() throws Exception { String request = "/diseases/both"; List diseases = DiseaseHelper.setupDiseaseList(3); @@ -227,7 +227,7 @@ public void testGetDiseases_200() throws Exception { } @Test - public void testGetDiseasesString_200() throws Exception { + void testGetDiseasesString_200() throws Exception { String request = "/diseases/both/{typecode}"; String typeCode = "1"; @@ -249,7 +249,7 @@ public void testGetDiseasesString_200() throws Exception { } @Test - public void testGetAllDiseases_200() throws Exception { + void testGetAllDiseases_200() throws Exception { String request = "/diseases/all"; List diseases = DiseaseHelper.setupDiseaseList(3); @@ -268,7 +268,7 @@ public void testGetAllDiseases_200() throws Exception { } @Test - public void testGetDiseaseByCode() throws Exception { + void testGetDiseaseByCode() throws Exception { String request = "/diseases/{code}"; String code = "999"; @@ -289,7 +289,7 @@ public void testGetDiseaseByCode() throws Exception { } @Test - public void testNewDisease_200() throws Exception { + void testNewDisease_200() throws Exception { String request = "/diseases"; Disease disease = DiseaseHelper.setup(); @@ -318,7 +318,7 @@ public void testNewDisease_200() throws Exception { } @Test - public void testUpdateDisease_201() throws Exception { + void testUpdateDisease_201() throws Exception { String request = "/diseases"; Disease disease = DiseaseHelper.setup(); @@ -344,7 +344,7 @@ public void testUpdateDisease_201() throws Exception { } @Test - public void testDeleteDisease() throws Exception { + void testDeleteDisease() throws Exception { String request = "/diseases/{code}"; String code = "999"; diff --git a/src/test/java/org/isf/distype/rest/DiseaseTypeControllerTest.java b/src/test/java/org/isf/distype/rest/DiseaseTypeControllerTest.java index ed9894f75..407b649b5 100644 --- a/src/test/java/org/isf/distype/rest/DiseaseTypeControllerTest.java +++ b/src/test/java/org/isf/distype/rest/DiseaseTypeControllerTest.java @@ -57,7 +57,7 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -public class DiseaseTypeControllerTest { +class DiseaseTypeControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(DiseaseTypeControllerTest.class); @@ -71,7 +71,7 @@ public class DiseaseTypeControllerTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new DiseaseTypeController(diseaseTypeBrowserManager, diseaseTypeMapper)) @@ -89,7 +89,7 @@ void closeService() throws Exception { } @Test - public void testGetAllDiseaseTypes_200() throws Exception { + void testGetAllDiseaseTypes_200() throws Exception { String request = "/diseasetypes"; List results = DiseaseTypeHelper.setupDiseaseTypeList(3); @@ -111,7 +111,7 @@ public void testGetAllDiseaseTypes_200() throws Exception { } @Test - public void testNewDiseaseType_201() throws Exception { + void testNewDiseaseType_201() throws Exception { String request = "/diseasetypes"; int code = 123; DiseaseType diseaseType = DiseaseTypeHelper.setup(code); @@ -137,7 +137,7 @@ public void testNewDiseaseType_201() throws Exception { } @Test - public void testUpdateDiseaseType_200() throws Exception { + void testUpdateDiseaseType_200() throws Exception { String request = "/diseasetypes"; int code = 456; @@ -164,7 +164,7 @@ public void testUpdateDiseaseType_200() throws Exception { } @Test - public void testDeleteDiseaseType_200() throws Exception { + void testDeleteDiseaseType_200() throws Exception { String request = "/diseasetypes/{code}"; DiseaseTypeDTO body = diseaseTypeMapper.map2DTO(DiseaseTypeHelper.setup(0)); diff --git a/src/test/java/org/isf/dlvrrestype/rest/DeliveryResultTypeControllerTest.java b/src/test/java/org/isf/dlvrrestype/rest/DeliveryResultTypeControllerTest.java index 5aedc533b..41b9afb55 100644 --- a/src/test/java/org/isf/dlvrrestype/rest/DeliveryResultTypeControllerTest.java +++ b/src/test/java/org/isf/dlvrrestype/rest/DeliveryResultTypeControllerTest.java @@ -57,7 +57,7 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -public class DeliveryResultTypeControllerTest { +class DeliveryResultTypeControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(DeliveryResultTypeControllerTest.class); @@ -71,7 +71,7 @@ public class DeliveryResultTypeControllerTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new DeliveryResultTypeController(deliveryResultTypeBrowserManagerMock, deliveryResultTypeMapper)) @@ -89,7 +89,7 @@ void closeService() throws Exception { } @Test - public void testNewDeliveryResultType_201() throws Exception { + void testNewDeliveryResultType_201() throws Exception { String request = "/deliveryresulttypes"; int code = 123; DeliveryResultType deliveryResultType = DeliveryResultTypeHelper.setup(code); @@ -118,7 +118,7 @@ public void testNewDeliveryResultType_201() throws Exception { } @Test - public void testUpdateDeliveryResultTypet_200() throws Exception { + void testUpdateDeliveryResultTypet_200() throws Exception { String request = "/deliveryresulttypes"; int code = 456; @@ -145,7 +145,7 @@ public void testUpdateDeliveryResultTypet_200() throws Exception { } @Test - public void testGetDeliveryResultTypes_200() throws Exception { + void testGetDeliveryResultTypes_200() throws Exception { String request = "/deliveryresulttypes"; List results = DeliveryResultTypeHelper.setupDeliveryResultTypeList(3); @@ -167,7 +167,7 @@ public void testGetDeliveryResultTypes_200() throws Exception { } @Test - public void testDeleteDeliveryResultType() throws Exception { + void testDeleteDeliveryResultType() throws Exception { String request = "/deliveryresulttypes/{code}"; DeliveryResultTypeDTO body = deliveryResultTypeMapper.map2DTO(DeliveryResultTypeHelper.setup(0)); diff --git a/src/test/java/org/isf/dlvrtype/rest/DeliveryTypeControllerTest.java b/src/test/java/org/isf/dlvrtype/rest/DeliveryTypeControllerTest.java index bc0bf5512..c4df98fe2 100644 --- a/src/test/java/org/isf/dlvrtype/rest/DeliveryTypeControllerTest.java +++ b/src/test/java/org/isf/dlvrtype/rest/DeliveryTypeControllerTest.java @@ -57,7 +57,7 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -public class DeliveryTypeControllerTest { +class DeliveryTypeControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(DeliveryTypeControllerTest.class); @@ -71,7 +71,7 @@ public class DeliveryTypeControllerTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new DeliveryTypeController(deliveryTypeBrowserManagerMock, deliveryTypeMapper)) @@ -89,7 +89,7 @@ void closeService() throws Exception { } @Test - public void testNewDeliveryType_201() throws Exception { + void testNewDeliveryType_201() throws Exception { String request = "/deliverytypes"; int code = 123; DeliveryType deliveryType = DeliveryTypeHelper.setup(code); @@ -118,7 +118,7 @@ public void testNewDeliveryType_201() throws Exception { } @Test - public void testUpdateDeliveryTypet_200() throws Exception { + void testUpdateDeliveryTypet_200() throws Exception { String request = "/deliverytypes/"; int code = 456; @@ -145,7 +145,7 @@ public void testUpdateDeliveryTypet_200() throws Exception { } @Test - public void testGetDeliveryTypes_200() throws Exception { + void testGetDeliveryTypes_200() throws Exception { String request = "/deliverytypes"; List results = DeliveryTypeHelper.setupDeliveryTypeList(3); @@ -167,7 +167,7 @@ public void testGetDeliveryTypes_200() throws Exception { } @Test - public void testDeleteDeliveryType_200() throws Exception { + void testDeleteDeliveryType_200() throws Exception { String request = "/deliverytypes/{code}"; DeliveryTypeDTO body = deliveryTypeMapper.map2DTO(DeliveryTypeHelper.setup(0)); diff --git a/src/test/java/org/isf/exam/rest/ExamControllerTest.java b/src/test/java/org/isf/exam/rest/ExamControllerTest.java index e73bbce31..27fa85276 100644 --- a/src/test/java/org/isf/exam/rest/ExamControllerTest.java +++ b/src/test/java/org/isf/exam/rest/ExamControllerTest.java @@ -58,9 +58,9 @@ @SpringBootTest(classes = OpenHospitalApiApplication.class) @AutoConfigureMockMvc -public class ExamControllerTest { +class ExamControllerTest { - private final Logger LOGGER = LoggerFactory.getLogger(ExamControllerTest.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ExamControllerTest.class); @Autowired private MockMvc mvc; diff --git a/src/test/java/org/isf/exam/rest/ExamRowControllerTest.java b/src/test/java/org/isf/exam/rest/ExamRowControllerTest.java index 6d20db610..c33cc80e5 100644 --- a/src/test/java/org/isf/exam/rest/ExamRowControllerTest.java +++ b/src/test/java/org/isf/exam/rest/ExamRowControllerTest.java @@ -65,7 +65,7 @@ */ @SpringBootTest(classes = OpenHospitalApiApplication.class) @AutoConfigureMockMvc -public class ExamRowControllerTest { +class ExamRowControllerTest { @Autowired private MockMvc mvc; diff --git a/src/test/java/org/isf/examination/rest/ExaminationControllerTest.java b/src/test/java/org/isf/examination/rest/ExaminationControllerTest.java index 6ee8ab874..b19438007 100644 --- a/src/test/java/org/isf/examination/rest/ExaminationControllerTest.java +++ b/src/test/java/org/isf/examination/rest/ExaminationControllerTest.java @@ -61,7 +61,7 @@ */ @SpringBootTest(classes = OpenHospitalApiApplication.class) @AutoConfigureMockMvc -public class ExaminationControllerTest { +class ExaminationControllerTest { @Autowired private MockMvc mvc; diff --git a/src/test/java/org/isf/exatype/rest/ExamTypeControllerTest.java b/src/test/java/org/isf/exatype/rest/ExamTypeControllerTest.java index 4f19ee112..c1414078f 100644 --- a/src/test/java/org/isf/exatype/rest/ExamTypeControllerTest.java +++ b/src/test/java/org/isf/exatype/rest/ExamTypeControllerTest.java @@ -60,7 +60,7 @@ */ @SpringBootTest(classes = OpenHospitalApiApplication.class) @AutoConfigureMockMvc -public class ExamTypeControllerTest { +class ExamTypeControllerTest { @Autowired private MockMvc mvc; diff --git a/src/test/java/org/isf/lab/rest/LaboratoryControllerTest.java b/src/test/java/org/isf/lab/rest/LaboratoryControllerTest.java index 8cec619aa..2a57cac36 100644 --- a/src/test/java/org/isf/lab/rest/LaboratoryControllerTest.java +++ b/src/test/java/org/isf/lab/rest/LaboratoryControllerTest.java @@ -67,7 +67,7 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -public class LaboratoryControllerTest { +class LaboratoryControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(LaboratoryControllerTest.class); @@ -89,7 +89,7 @@ public class LaboratoryControllerTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new LaboratoryController(laboratoryManager, patientBrowserManager, examManager, laboratoryMapper, laboratoryRowMapper)) @@ -107,7 +107,7 @@ void closeService() throws Exception { } @Test - public void testNewLaboratory_201() throws Exception { + void testNewLaboratory_201() throws Exception { String request = "/laboratories"; LabWithRowsDTO labWithRowsDTO = new LabWithRowsDTO(); @@ -142,7 +142,7 @@ public void testNewLaboratory_201() throws Exception { } @Test - public void testUpdateLaboratory_200() throws Exception { + void testUpdateLaboratory_200() throws Exception { String request = "/laboratories/{code}"; LabWithRowsDTO labWithRowsDTO = new LabWithRowsDTO(); @@ -180,7 +180,7 @@ public void testUpdateLaboratory_200() throws Exception { } @Test - public void testGetLaboratory_200() throws Exception { + void testGetLaboratory_200() throws Exception { String request = "/laboratories/byPatientId/{patId}"; LabWithRowsDTO labWithRowsDTO = new LabWithRowsDTO(); diff --git a/src/test/java/org/isf/login/rest/LoginControllerTest.java b/src/test/java/org/isf/login/rest/LoginControllerTest.java index e08cf4f9e..c60150f97 100644 --- a/src/test/java/org/isf/login/rest/LoginControllerTest.java +++ b/src/test/java/org/isf/login/rest/LoginControllerTest.java @@ -64,7 +64,7 @@ import io.jsonwebtoken.JwtException; @SpringBootTest(classes = OpenHospitalApiApplication.class) -public class LoginControllerTest { +class LoginControllerTest { private MockMvc mvc; @@ -86,7 +86,7 @@ public class LoginControllerTest { private AutoCloseable closeable; @BeforeEach - public void setUp() { + void setUp() { closeable = MockitoAnnotations.openMocks(this); LoginController loginController = new LoginController( diff --git a/src/test/java/org/isf/opd/rest/OpdControllerTest.java b/src/test/java/org/isf/opd/rest/OpdControllerTest.java index 0c745f4dc..9c4efcd48 100644 --- a/src/test/java/org/isf/opd/rest/OpdControllerTest.java +++ b/src/test/java/org/isf/opd/rest/OpdControllerTest.java @@ -56,7 +56,7 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -public class OpdControllerTest { +class OpdControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(OpdControllerTest.class); @@ -81,7 +81,7 @@ public class OpdControllerTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new OpdController(opdBrowserManagerMock, opdMapper, patientBrowserManagerMock, operationRowBrowserManagerMock, @@ -100,7 +100,7 @@ void closeService() throws Exception { } @Test - public void testNewOpd_201() throws Exception { + void testNewOpd_201() throws Exception { String request = "/opds"; Patient patient = PatientHelper.setup(); Integer patientCode = 1; diff --git a/src/test/java/org/isf/operation/rest/OperationControllerTest.java b/src/test/java/org/isf/operation/rest/OperationControllerTest.java index a825a77f6..ec6e246b6 100644 --- a/src/test/java/org/isf/operation/rest/OperationControllerTest.java +++ b/src/test/java/org/isf/operation/rest/OperationControllerTest.java @@ -63,7 +63,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; -public class OperationControllerTest { +class OperationControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(OperationControllerTest.class); @@ -92,7 +92,7 @@ public class OperationControllerTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new OperationController( @@ -118,7 +118,7 @@ void closeService() throws Exception { } @Test - public void testNewOperation_201() throws Exception { + void testNewOperation_201() throws Exception { String request = "/operations"; Operation operation = OperationHelper.setup(); @@ -148,7 +148,7 @@ public void testNewOperation_201() throws Exception { } @Test - public void testUpdateOperation_200() throws Exception { + void testUpdateOperation_200() throws Exception { String request = "/operations/{code}"; String code = "25"; @@ -175,7 +175,7 @@ public void testUpdateOperation_200() throws Exception { } @Test - public void testGetOperation_200() throws Exception { + void testGetOperation_200() throws Exception { String request = "/operations"; List results = OperationHelper.setupOperationList(3); @@ -197,7 +197,7 @@ public void testGetOperation_200() throws Exception { } @Test - public void testDeleteOperation_200() throws Exception { + void testDeleteOperation_200() throws Exception { String request = "/operations/{code}"; Operation deleteOperation = OperationHelper.setup(); OperationDTO body = operationMapper.map2DTO(deleteOperation); diff --git a/src/test/java/org/isf/patient/rest/PatientControllerTest.java b/src/test/java/org/isf/patient/rest/PatientControllerTest.java index 512f1b86b..632dcec47 100644 --- a/src/test/java/org/isf/patient/rest/PatientControllerTest.java +++ b/src/test/java/org/isf/patient/rest/PatientControllerTest.java @@ -81,7 +81,7 @@ /** * @author ecastaneda1 */ -public class PatientControllerTest { +class PatientControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(PatientControllerTest.class); @@ -101,7 +101,7 @@ public class PatientControllerTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new PatientController(patientBrowserManagerMock, admissionBrowserManagerMock, patientMapper, @@ -126,7 +126,7 @@ void closeService() throws Exception { * @throws Exception When error occurs */ @Test - public void when_post_patients_is_call_without_contentType_header_then_HttpMediaTypeNotSupportedException() throws Exception { + void when_post_patients_is_call_without_contentType_header_then_HttpMediaTypeNotSupportedException() throws Exception { String request = "/patients"; MvcResult result = this.mockMvc @@ -150,7 +150,7 @@ public void when_post_patients_is_call_without_contentType_header_then_HttpMedia * @throws Exception */ @Test - public void when_post_patients_is_call_with_empty_body_then_BadRequest_HttpMessageNotReadableException() throws Exception { + void when_post_patients_is_call_with_empty_body_then_BadRequest_HttpMessageNotReadableException() throws Exception { String request = "/patients"; String empty_body = ""; @@ -178,7 +178,7 @@ public void when_post_patients_is_call_with_empty_body_then_BadRequest_HttpMessa * @throws Exception */ @Test - public void when_post_patients_PatientBrowserManager_getPatient_returns_null_then_OHAPIException_BadRequest() throws Exception { + void when_post_patients_PatientBrowserManager_getPatient_returns_null_then_OHAPIException_BadRequest() throws Exception { String request = "/patients"; PatientDTO newPatientDTO = PatientHelper.setup(patientMapper); @@ -208,7 +208,7 @@ public void when_post_patients_PatientBrowserManager_getPatient_returns_null_the * @throws Exception */ @Test - public void when_post_patients_PatientBrowserManager_newPatient_returns_false_then_Created() throws Exception { + void when_post_patients_PatientBrowserManager_newPatient_returns_false_then_Created() throws Exception { Integer code = 12345; String request = "/patients"; PatientDTO newPatientDTO = PatientHelper.setup(patientMapper); @@ -238,7 +238,7 @@ public void when_post_patients_PatientBrowserManager_newPatient_returns_false_th * @throws Exception */ @Test - public void when_post_patients_and_both_calls_to_PatientBrowserManager_success_then_Created() throws Exception { + void when_post_patients_and_both_calls_to_PatientBrowserManager_success_then_Created() throws Exception { Integer code = 12345; String request = "/patients"; PatientDTO newPatientDTO = PatientHelper.setup(patientMapper); @@ -265,7 +265,7 @@ public void when_post_patients_and_both_calls_to_PatientBrowserManager_success_t * @throws Exception */ @Test - public void when_put_update_patient_with_valid_body_and_existent_code_then_BadRequest() throws Exception { + void when_put_update_patient_with_valid_body_and_existent_code_then_BadRequest() throws Exception { String request = "/patients/{code}"; Integer code = 12345; @@ -305,7 +305,7 @@ public void when_put_update_patient_with_valid_body_and_existent_code_then_BadRe * @throws Exception */ @Test - public void when_put_update_patient_with_invalid_body_and_existent_code_then_HttpMessageNotReadableException_BadRequest() throws Exception { + void when_put_update_patient_with_invalid_body_and_existent_code_then_HttpMessageNotReadableException_BadRequest() throws Exception { Integer code = 12345; String request = "/patients/{code}"; @@ -331,7 +331,7 @@ public void when_put_update_patient_with_invalid_body_and_existent_code_then_Htt * @throws Exception */ @Test - public void when_put_update_patient_with_valid_body_and_unexistent_code_then_OHAPIException_BadRequest() throws Exception { + void when_put_update_patient_with_valid_body_and_unexistent_code_then_OHAPIException_BadRequest() throws Exception { String request = "/patients/{code}"; Integer code = 123; @@ -361,7 +361,7 @@ public void when_put_update_patient_with_valid_body_and_unexistent_code_then_OHA * @throws Exception */ @Test - public void when_get_patients_non_parameters_then_return_list_of_PatientDTO_page_0_default_size_and_OK() throws Exception { + void when_get_patients_non_parameters_then_return_list_of_PatientDTO_page_0_default_size_and_OK() throws Exception { String request = "/patients"; int expectedPageSize = Integer.parseInt(PatientController.DEFAULT_PAGE_SIZE); @@ -393,7 +393,7 @@ public void when_get_patients_non_parameters_then_return_list_of_PatientDTO_page * @throws Exception */ @Test - public void when_get_patients_with_existent_code_and_not_admitted_then_response_PatientDTO_and_OK() throws Exception { + void when_get_patients_with_existent_code_and_not_admitted_then_response_PatientDTO_and_OK() throws Exception { int code = 123; String request = "/patients/{code}"; Patient patient = PatientHelper.setup(); @@ -423,7 +423,7 @@ public void when_get_patients_with_existent_code_and_not_admitted_then_response_ * @throws Exception */ @Test - public void when_get_patients_with_existent_code_and_admitted_then_response_PatientDTO_and_OK() throws Exception { + void when_get_patients_with_existent_code_and_admitted_then_response_PatientDTO_and_OK() throws Exception { int code = 123; String request = "/patients/{code}"; Patient patient = PatientHelper.setup(); @@ -456,7 +456,7 @@ public void when_get_patients_with_existent_code_and_admitted_then_response_Pati * @throws Exception */ @Test - public void when_get_patients_search_without_name_and_unexistent_code_then_response_null_and_NO_Content() throws Exception { + void when_get_patients_search_without_name_and_unexistent_code_then_response_null_and_NO_Content() throws Exception { Integer code = 1000; String request = "/patients/search"; @@ -478,7 +478,7 @@ public void when_get_patients_search_without_name_and_unexistent_code_then_respo * @throws Exception */ @Test - public void when_get_patients_search_without_name_and_without_code_then_response_null_and_NO_Content() throws Exception { + void when_get_patients_search_without_name_and_without_code_then_response_null_and_NO_Content() throws Exception { String request = "/patients/search"; this.mockMvc @@ -496,7 +496,7 @@ public void when_get_patients_search_without_name_and_without_code_then_response * @throws Exception */ @Test - public void when_get_patients_search_with_unexistent_name_and_without_code_then_response_null_and_NO_Content() throws Exception { + void when_get_patients_search_with_unexistent_name_and_without_code_then_response_null_and_NO_Content() throws Exception { String name = null; String request = "/patients/search"; @@ -517,7 +517,7 @@ public void when_get_patients_search_with_unexistent_name_and_without_code_then_ * @throws Exception */ @Test - public void when_delete_patients_with_existent_code_then_response_true_and_OK() throws Exception { + void when_delete_patients_with_existent_code_then_response_true_and_OK() throws Exception { Integer code = 123; String request = "/patients/{code}"; Patient patient = PatientHelper.setup(); @@ -540,7 +540,7 @@ public void when_delete_patients_with_existent_code_then_response_true_and_OK() * @throws Exception */ @Test - public void when_delete_patients_with_unexistent_code_then_response_Not_Found() throws Exception { + void when_delete_patients_with_unexistent_code_then_response_Not_Found() throws Exception { Integer code = 111; String request = "/patients/{code}"; @@ -560,7 +560,7 @@ public void when_delete_patients_with_unexistent_code_then_response_Not_Found() * @throws Exception */ @Test - public void when_delete_patients_with_existent_code_but_fail_deletion_then_OHAPIException_BadRequest() throws Exception { + void when_delete_patients_with_existent_code_but_fail_deletion_then_OHAPIException_BadRequest() throws Exception { Integer code = 123; String request = "/patients/{code}"; Patient patient = PatientHelper.setup(); diff --git a/src/test/java/org/isf/security/JWTFilterTest.java b/src/test/java/org/isf/security/JWTFilterTest.java index a88a97f39..d6c5336be 100644 --- a/src/test/java/org/isf/security/JWTFilterTest.java +++ b/src/test/java/org/isf/security/JWTFilterTest.java @@ -43,7 +43,7 @@ import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.security.core.Authentication; -public class JWTFilterTest { +class JWTFilterTest { @Mock private TokenProvider tokenProvider; @@ -58,14 +58,14 @@ public class JWTFilterTest { private MockHttpServletResponse response; @BeforeEach - public void setUp() { + void setUp() { MockitoAnnotations.openMocks(this); request = new MockHttpServletRequest(); response = new MockHttpServletResponse(); } @Test - public void testDoFilter_ValidToken() throws ServletException, IOException { + void testDoFilter_ValidToken() throws ServletException, IOException { String validToken = "valid.token"; Authentication mockAuthentication = mock(Authentication.class); @@ -81,7 +81,7 @@ public void testDoFilter_ValidToken() throws ServletException, IOException { } @Test - public void testDoFilter_ExpiredToken() throws ServletException, IOException { + void testDoFilter_ExpiredToken() throws ServletException, IOException { String expiredToken = "expired.token"; when(tokenProvider.validateToken(expiredToken)).thenReturn(TokenValidationResult.EXPIRED); @@ -93,7 +93,7 @@ public void testDoFilter_ExpiredToken() throws ServletException, IOException { } @Test - public void testDoFilter_MalformedToken() throws ServletException, IOException { + void testDoFilter_MalformedToken() throws ServletException, IOException { String malformedToken = "malformed.token"; when(tokenProvider.validateToken(malformedToken)).thenReturn(TokenValidationResult.MALFORMED); @@ -105,13 +105,13 @@ public void testDoFilter_MalformedToken() throws ServletException, IOException { } @Test - public void testDoFilter_NoToken() throws ServletException, IOException { + void testDoFilter_NoToken() throws ServletException, IOException { jwtFilter.doFilter(request, response, filterChain); verify(filterChain).doFilter(request, response); // Ensure the filter chain continues even without a token } @Test - public void testDoFilter_InvalidSignatureToken() throws ServletException, IOException { + void testDoFilter_InvalidSignatureToken() throws ServletException, IOException { String invalidSignatureToken = "eyJhbGciOiJIUzI1NiJ9.MISSING_PART.HMAC_SIGNATURE"; when(tokenProvider.validateToken(invalidSignatureToken)).thenReturn(TokenValidationResult.INVALID_SIGNATURE); @@ -123,7 +123,7 @@ public void testDoFilter_InvalidSignatureToken() throws ServletException, IOExce } @Test - public void testDoFilter_UnsupportedToken() throws ServletException, IOException { + void testDoFilter_UnsupportedToken() throws ServletException, IOException { String unsupportedToken = "unsupported.token"; when(tokenProvider.validateToken(unsupportedToken)).thenReturn(TokenValidationResult.UNSUPPORTED); @@ -135,7 +135,7 @@ public void testDoFilter_UnsupportedToken() throws ServletException, IOException } @Test - public void testDoFilter_EmptyClaimsToken() throws ServletException, IOException { + void testDoFilter_EmptyClaimsToken() throws ServletException, IOException { String emptyClaimsToken = "empty.claims.token"; when(tokenProvider.validateToken(emptyClaimsToken)).thenReturn(TokenValidationResult.EMPTY_CLAIMS); @@ -147,7 +147,7 @@ public void testDoFilter_EmptyClaimsToken() throws ServletException, IOException } @Test - public void testDoFilter_UnexpectedResult() throws ServletException, IOException { + void testDoFilter_UnexpectedResult() throws ServletException, IOException { String unexpectedToken = "unexpected.token"; when(tokenProvider.validateToken(unexpectedToken)).thenAnswer(invocation -> { // Return an unexpected result @@ -162,7 +162,7 @@ public void testDoFilter_UnexpectedResult() throws ServletException, IOException } @Test - public void testDoFilter_NullValidationResult() throws ServletException, IOException { + void testDoFilter_NullValidationResult() throws ServletException, IOException { String tokenWithNullValidationResult = "null.validation.token"; when(tokenProvider.validateToken(tokenWithNullValidationResult)).thenReturn(null); @@ -174,7 +174,7 @@ public void testDoFilter_NullValidationResult() throws ServletException, IOExcep } @Test - public void testDoFilter_ValidButExpiredToken() throws ServletException, IOException { + void testDoFilter_ValidButExpiredToken() throws ServletException, IOException { String validTokenButExpired = "valid.token.but.expired"; Authentication mockAuthentication = mock(Authentication.class); diff --git a/src/test/java/org/isf/security/TokenProviderTest.java b/src/test/java/org/isf/security/TokenProviderTest.java index 413c60ec9..dcefc9d67 100644 --- a/src/test/java/org/isf/security/TokenProviderTest.java +++ b/src/test/java/org/isf/security/TokenProviderTest.java @@ -65,7 +65,7 @@ import io.jsonwebtoken.SignatureAlgorithm; @SpringBootTest(classes = OpenHospitalApiApplication.class) -public class TokenProviderTest { +class TokenProviderTest { @Autowired private TokenProvider tokenProvider; @@ -77,12 +77,12 @@ public class TokenProviderTest { protected PermissionManager permissionManager; @BeforeEach - public void setUp() { + void setUp() { tokenProvider.init(); } @Test - public void testGenerateJwtToken() throws NoSuchFieldException, IllegalAccessException { + void testGenerateJwtToken() throws NoSuchFieldException, IllegalAccessException { Authentication authentication = createAuthentication(); Key key = extractKeyFromTokenProvider(); @@ -98,7 +98,7 @@ public void testGenerateJwtToken() throws NoSuchFieldException, IllegalAccessExc } @Test - public void testValidateToken_Valid() { + void testValidateToken_Valid() { Authentication authentication = createAuthentication(); // Generate token @@ -130,7 +130,7 @@ void testIsTokenExpired_NotExpired() { } @Test - public void testValidateToken_Expired() throws Exception { + void testValidateToken_Expired() throws Exception { Key key = extractKeyFromTokenProvider(); // Create an expired token by setting the expiration date in the past @@ -149,7 +149,7 @@ public void testValidateToken_Expired() throws Exception { } @Test - public void testValidateToken_Malformed() { + void testValidateToken_Malformed() { String malformedToken = "malformed.token"; // valid token it must contain two dots "." // Validate the token using tokenProvider @@ -159,7 +159,7 @@ public void testValidateToken_Malformed() { } @Test - public void testValidateToken_InvalidSignature() { + void testValidateToken_InvalidSignature() { String invalidSignatureToken = "eyJhbGciOiJIUzI1NiJ9.MISSING_PART.HMAC_SIGNATURE"; // Validate the token using tokenProvider @@ -169,7 +169,7 @@ public void testValidateToken_InvalidSignature() { } @Test - public void testValidateToken_Unsupported() throws Exception { + void testValidateToken_Unsupported() throws Exception { KeyPair keyPair = generateRsaKeyPair("RSA"); // Create a JWT token signed with RS256 (RSA algorithm) instead of HS512 @@ -185,7 +185,7 @@ public void testValidateToken_Unsupported() throws Exception { } @Test - public void testValidateToken_EmptyClaims() throws Exception { + void testValidateToken_EmptyClaims() throws Exception { Key key = extractKeyFromTokenProvider(); // Create a token with empty claims @@ -202,7 +202,7 @@ public void testValidateToken_EmptyClaims() throws Exception { } @Test - public void testGetAuthentication() { + void testGetAuthentication() { Authentication authentication = createAuthentication(); // Generate token @@ -228,7 +228,7 @@ public void testGetAuthentication() { } @Test - public void testGetAuthentication_EmptyAuthorities() { + void testGetAuthentication_EmptyAuthorities() { // Create an Authentication with empty authorities List authorities = List.of(); Authentication authentication = new UsernamePasswordAuthenticationToken("testuser", "password", authorities); @@ -243,13 +243,13 @@ public void testGetAuthentication_EmptyAuthorities() { } @Test - public void testSetJwtParser() { + void testSetJwtParser() { JwtParser mockJwtParser = mock(JwtParser.class); tokenProvider.setJwtParser(mockJwtParser); } @Test - public void testGetUsernameFromToken() { + void testGetUsernameFromToken() { Authentication authentication = createAuthentication(); // Generate token @@ -260,7 +260,7 @@ public void testGetUsernameFromToken() { } @Test - public void testGetAllClaimsFromToken() { + void testGetAllClaimsFromToken() { Authentication authentication = createAuthentication(); // Generate token @@ -272,7 +272,7 @@ public void testGetAllClaimsFromToken() { } @Test - public void testGetExpirationDateFromToken() { + void testGetExpirationDateFromToken() { Authentication authentication = createAuthentication(); // Generate token @@ -284,7 +284,7 @@ public void testGetExpirationDateFromToken() { } @Test - public void testGetClaimFromToken() { + void testGetClaimFromToken() { Authentication authentication = createAuthentication(); // Generate token @@ -298,7 +298,7 @@ public void testGetClaimFromToken() { } @Test - public void testIsTokenExpired() throws Exception { + void testIsTokenExpired() throws Exception { Authentication authentication = createAuthentication(); Key key = extractKeyFromTokenProvider(); @@ -324,7 +324,7 @@ public void testIsTokenExpired() throws Exception { } @Test - public void testGenerateJwtToken_WithRememberMe() { + void testGenerateJwtToken_WithRememberMe() { Authentication authentication = createAuthentication(); boolean rememberMe = true; diff --git a/src/test/java/org/isf/supplier/rest/SupplierControllerTest.java b/src/test/java/org/isf/supplier/rest/SupplierControllerTest.java index 52ad5e979..5ee8a1f17 100644 --- a/src/test/java/org/isf/supplier/rest/SupplierControllerTest.java +++ b/src/test/java/org/isf/supplier/rest/SupplierControllerTest.java @@ -63,8 +63,8 @@ */ @SpringBootTest(classes = OpenHospitalApiApplication.class) @AutoConfigureMockMvc -public class SupplierControllerTest { - private final Logger LOGGER = LoggerFactory.getLogger(SupplierControllerTest.class); +class SupplierControllerTest { + private static final Logger LOGGER = LoggerFactory.getLogger(SupplierControllerTest.class); @Autowired private MockMvc mvc; diff --git a/src/test/java/org/isf/usergroups/rest/UserGroupControllerTest.java b/src/test/java/org/isf/usergroups/rest/UserGroupControllerTest.java index 5c190ce22..069991636 100644 --- a/src/test/java/org/isf/usergroups/rest/UserGroupControllerTest.java +++ b/src/test/java/org/isf/usergroups/rest/UserGroupControllerTest.java @@ -72,9 +72,9 @@ @SpringBootTest(classes = OpenHospitalApiApplication.class) @AutoConfigureMockMvc -public class UserGroupControllerTest { +class UserGroupControllerTest { - private final Logger LOGGER = LoggerFactory.getLogger(UserGroupControllerTest.class); + private static final Logger LOGGER = LoggerFactory.getLogger(UserGroupControllerTest.class); @Autowired private MockMvc mvc; diff --git a/src/test/java/org/isf/users/rest/UserControllerTest.java b/src/test/java/org/isf/users/rest/UserControllerTest.java index f7334ed87..b65ad3403 100644 --- a/src/test/java/org/isf/users/rest/UserControllerTest.java +++ b/src/test/java/org/isf/users/rest/UserControllerTest.java @@ -67,9 +67,9 @@ @SpringBootTest(classes = OpenHospitalApiApplication.class) @AutoConfigureMockMvc -public class UserControllerTest { +class UserControllerTest { - private final Logger LOGGER = LoggerFactory.getLogger(UserControllerTest.class); + private static final Logger LOGGER = LoggerFactory.getLogger(UserControllerTest.class); @Autowired private MockMvc mvc; @@ -378,7 +378,7 @@ void shouldUpdateUserWithoutUpdatingPassword() throws Exception { class UpdateProfileTests { @BeforeEach - public void setup() throws OHServiceException { + void setup() throws OHServiceException { var permission = new Permission(); permission.setName("users.read"); permission.setDescription("Allow to read users"); diff --git a/src/test/java/org/isf/usersettings/rest/UserSettingControllerTest.java b/src/test/java/org/isf/usersettings/rest/UserSettingControllerTest.java index ebff82b7a..8ac228ce4 100644 --- a/src/test/java/org/isf/usersettings/rest/UserSettingControllerTest.java +++ b/src/test/java/org/isf/usersettings/rest/UserSettingControllerTest.java @@ -63,9 +63,9 @@ @SpringBootTest(classes = OpenHospitalApiApplication.class) @AutoConfigureMockMvc -public class UserSettingControllerTest { +class UserSettingControllerTest { - private final Logger LOGGER = LoggerFactory.getLogger(UserSettingControllerTest.class); + private static final Logger LOGGER = LoggerFactory.getLogger(UserSettingControllerTest.class); @Autowired private MockMvc mvc; diff --git a/src/test/java/org/isf/vaccine/rest/VaccineControllerTest.java b/src/test/java/org/isf/vaccine/rest/VaccineControllerTest.java index d6e00cd66..e20d03101 100644 --- a/src/test/java/org/isf/vaccine/rest/VaccineControllerTest.java +++ b/src/test/java/org/isf/vaccine/rest/VaccineControllerTest.java @@ -70,7 +70,7 @@ public class VaccineControllerTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new VaccineController(vaccineBrowserManagerMock, vaccineMapper)) @@ -88,7 +88,7 @@ void closeService() throws Exception { } @Test - public void testGetVaccines_200() throws Exception { + void testGetVaccines_200() throws Exception { String request = "/vaccines"; List vaccinesList = VaccineHelper.setupVaccineList(4); @@ -110,7 +110,7 @@ public void testGetVaccines_200() throws Exception { } @Test - public void testGetVaccinesByVaccineTypeCode_200() throws Exception { + void testGetVaccinesByVaccineTypeCode_200() throws Exception { String request = "/vaccines/type-code/{vaccineTypeCode}"; List vaccinesList = VaccineHelper.setupVaccineList(4); @@ -131,7 +131,7 @@ public void testGetVaccinesByVaccineTypeCode_200() throws Exception { } @Test - public void testNewVaccine_201() throws Exception { + void testNewVaccine_201() throws Exception { String request = "/vaccines"; String code = "ZZ"; Vaccine vaccine = VaccineHelper.setup(code); @@ -154,7 +154,7 @@ public void testNewVaccine_201() throws Exception { } @Test - public void testUpdateVaccine_200() throws Exception { + void testUpdateVaccine_200() throws Exception { String request = "/vaccines"; String code = "ZZ"; Vaccine vaccine = VaccineHelper.setup(code); @@ -177,7 +177,7 @@ public void testUpdateVaccine_200() throws Exception { } @Test - public void testDeleteVaccine_200() throws Exception { + void testDeleteVaccine_200() throws Exception { String request = "/vaccines/{code}"; String basecode = "0"; @@ -201,7 +201,7 @@ public void testDeleteVaccine_200() throws Exception { } @Test - public void testCheckVaccineCode_200() throws Exception { + void testCheckVaccineCode_200() throws Exception { String request = "/vaccines/check/{code}"; String code = "AA"; diff --git a/src/test/java/org/isf/vactype/rest/VaccineTypeControllerTest.java b/src/test/java/org/isf/vactype/rest/VaccineTypeControllerTest.java index e12162f7c..4df8324d0 100644 --- a/src/test/java/org/isf/vactype/rest/VaccineTypeControllerTest.java +++ b/src/test/java/org/isf/vactype/rest/VaccineTypeControllerTest.java @@ -56,7 +56,7 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -public class VaccineTypeControllerTest { +class VaccineTypeControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(VaccineTypeControllerTest.class); @@ -70,7 +70,7 @@ public class VaccineTypeControllerTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new VaccineTypeController(vaccineTypeBrowserManagerMock, vaccineTypeMapper)) @@ -88,7 +88,7 @@ void closeService() throws Exception { } @Test - public void testGetVaccineType_200() throws Exception { + void testGetVaccineType_200() throws Exception { String request = "/vaccinetypes"; List vaccinesTypeList = VaccineTypeHelper.setupVaccineList(4); @@ -110,7 +110,7 @@ public void testGetVaccineType_200() throws Exception { } @Test - public void testNewVaccineType_200() throws Exception { + void testNewVaccineType_200() throws Exception { String request = "/vaccinetypes"; String code = "ZZ"; VaccineTypeDTO body = vaccineTypeMapper.map2DTO(VaccineTypeHelper.setup(code)); @@ -133,7 +133,7 @@ public void testNewVaccineType_200() throws Exception { } @Test - public void testUpdateVaccineType_200() throws Exception { + void testUpdateVaccineType_200() throws Exception { String request = "/vaccinetypes"; String code = "ZZ"; VaccineTypeDTO body = vaccineTypeMapper.map2DTO(VaccineTypeHelper.setup(code)); @@ -156,7 +156,7 @@ public void testUpdateVaccineType_200() throws Exception { } @Test - public void testDeleteVaccineType_200() throws Exception { + void testDeleteVaccineType_200() throws Exception { String request = "/vaccinetypes/{code}"; String basecode = "0"; @@ -180,7 +180,7 @@ public void testDeleteVaccineType_200() throws Exception { } @Test - public void testCheckVaccineTypeCode_200() throws Exception { + void testCheckVaccineTypeCode_200() throws Exception { String request = "/vaccinetypes/check/{code}"; String code = "AA"; diff --git a/src/test/java/org/isf/visits/rest/VisitsControllerTest.java b/src/test/java/org/isf/visits/rest/VisitsControllerTest.java index f31d0b153..e6f925129 100644 --- a/src/test/java/org/isf/visits/rest/VisitsControllerTest.java +++ b/src/test/java/org/isf/visits/rest/VisitsControllerTest.java @@ -56,7 +56,7 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -public class VisitsControllerTest { +class VisitsControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(VisitsControllerTest.class); @@ -70,7 +70,7 @@ public class VisitsControllerTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new VisitsController(visitManagerMock, visitMapper)) @@ -89,7 +89,7 @@ void closeService() throws Exception { } @Test - public void testGetVisit_200() throws Exception { + void testGetVisit_200() throws Exception { String request = "/visits/patient/{patID}"; int patID = 0; @@ -112,7 +112,7 @@ public void testGetVisit_200() throws Exception { } @Test - public void testNewVisit_201() throws Exception { + void testNewVisit_201() throws Exception { String request = "/visits"; int id = 1; VisitDTO body = visitMapper.map2DTO(VisitHelper.setup(id)); @@ -134,7 +134,7 @@ public void testNewVisit_201() throws Exception { } @Test - public void testNewVisits_201() throws Exception { + void testNewVisits_201() throws Exception { String request = "/visits/insertList"; List visitsList = VisitHelper.setupVisitList(4); @@ -159,7 +159,7 @@ public void testNewVisits_201() throws Exception { } @Test - public void testDeleteVisitsRelatedToPatient_200() throws Exception { + void testDeleteVisitsRelatedToPatient_200() throws Exception { String request = "/visits/delete/{patId}"; int id = 1; diff --git a/src/test/java/org/isf/ward/rest/WardControllerTest.java b/src/test/java/org/isf/ward/rest/WardControllerTest.java index f45c3b229..99f3b5987 100644 --- a/src/test/java/org/isf/ward/rest/WardControllerTest.java +++ b/src/test/java/org/isf/ward/rest/WardControllerTest.java @@ -56,7 +56,7 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -public class WardControllerTest { +class WardControllerTest { private static final Logger LOGGER = LoggerFactory.getLogger(WardControllerTest.class); @@ -70,7 +70,7 @@ public class WardControllerTest { private AutoCloseable closeable; @BeforeEach - public void setup() { + void setup() { closeable = MockitoAnnotations.openMocks(this); this.mockMvc = MockMvcBuilders .standaloneSetup(new WardController(wardBrowserManagerMock, wardMapper)) @@ -88,7 +88,7 @@ void closeService() throws Exception { } @Test - public void testGetWards_200() throws Exception { + void testGetWards_200() throws Exception { String request = "/wards"; List wardList = WardHelper.setupWardList(4); @@ -110,7 +110,7 @@ public void testGetWards_200() throws Exception { } @Test - public void testGetWardsNoMaternity_200() throws Exception { + void testGetWardsNoMaternity_200() throws Exception { String request = "/wardsNoMaternity"; List wardList = WardHelper.setupWardList(4); @@ -133,7 +133,7 @@ public void testGetWardsNoMaternity_200() throws Exception { } @Test - public void testGetCurrentOccupation() throws Exception { + void testGetCurrentOccupation() throws Exception { String request = "/wards/occupation/{code}"; int code = 4; @@ -160,7 +160,7 @@ public void testGetCurrentOccupation() throws Exception { } @Test - public void testNewWard_200() throws Exception { + void testNewWard_200() throws Exception { String request = "/wards"; int code = 1; Ward ward = WardHelper.setup(code); @@ -183,7 +183,7 @@ public void testNewWard_200() throws Exception { } @Test - public void testUpdateWard_200() throws Exception { + void testUpdateWard_200() throws Exception { String request = "/wards"; int code = 1; Ward ward = WardHelper.setup(code); @@ -206,7 +206,7 @@ public void testUpdateWard_200() throws Exception { } @Test - public void testDeleteWard() throws Exception { + void testDeleteWard() throws Exception { String request = "/wards/{code}"; int basecode = 1; @@ -230,7 +230,7 @@ public void testDeleteWard() throws Exception { } @Test - public void testCheckWardCode() throws Exception { + void testCheckWardCode() throws Exception { String request = "/wards/check/{code}"; int basecode = 1; @@ -254,7 +254,7 @@ public void testCheckWardCode() throws Exception { } @Test - public void testCheckWardMaternityCode_true_200() throws Exception { + void testCheckWardMaternityCode_true_200() throws Exception { String request = "/wards/check/maternity/{createIfNotExist}"; Boolean createIfNotExist = true; @@ -274,7 +274,7 @@ public void testCheckWardMaternityCode_true_200() throws Exception { } @Test - public void testCheckWardMaternityCode_false_200() throws Exception { + void testCheckWardMaternityCode_false_200() throws Exception { String request = "/wards/check/maternity/{createIfNotExist}"; Boolean createIfNotExist = false; From 43774757ee69062ad98208c1d3e334f2f28a84b3 Mon Sep 17 00:00:00 2001 From: Alessandro Domanico Date: Sun, 8 Dec 2024 20:55:19 +0200 Subject: [PATCH 2/2] OP-1373 remove warns at api startup (#512) * Change log level for JWT token * Resolving AuthenticationProvider WARN We don't need at the moment to define an authenticationProvider because we have only one UserDetailsService implementation (org.isf.security.UserDetailsServiceImpl) and only one PasswordEncoder bean (BCryptPasswordEncoder), so Spring Security uses the default DaoAuthenticationProvider In the future, if we add more UserDetailsService implementations for multiple authentication data sources (e.g. Database, LDAP, Third-Party) we must define each provider and instruct the AuthenticationManager in which one to use for each case. * Disable Mustache Template WARN * Disable WARN - spring.jpa.open-in-view is enabled by default. --- rsc/application.properties.dist | 2 ++ .../java/org/isf/config/SecurityConfig.java | 13 -------- .../org/isf/security/jwt/TokenProvider.java | 32 +++++++++---------- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/rsc/application.properties.dist b/rsc/application.properties.dist index 7914e19aa..0807834bb 100644 --- a/rsc/application.properties.dist +++ b/rsc/application.properties.dist @@ -12,6 +12,8 @@ server.servlet.session.cookie.http-only=true #server.servlet.session.cookie.secure=true # only over HTTPS spring.pid.fail-on-write-error=true spring.pid.file=OH_API_PID +spring.mustache.check-template-location=false +spring.jpa.open-in-view=false ### In production change to http:// cors.allowed.origins=http://API_HOST:API_PORT,http://UI_HOST:UI_PORT diff --git a/src/main/java/org/isf/config/SecurityConfig.java b/src/main/java/org/isf/config/SecurityConfig.java index b65f8be6b..c8bd41a29 100644 --- a/src/main/java/org/isf/config/SecurityConfig.java +++ b/src/main/java/org/isf/config/SecurityConfig.java @@ -36,12 +36,10 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; import org.springframework.security.authorization.AuthorizationDecision; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.http.SessionCreationPolicy; -import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.SecurityFilterChain; @@ -56,9 +54,6 @@ @EnableWebSecurity public class SecurityConfig { - @Autowired - private UserDetailsService userDetailsService; - private final TokenProvider tokenProvider; @Autowired @@ -75,14 +70,6 @@ public SecurityConfig(TokenProvider tokenProvider, PermissionManager permissionM @Autowired private CustomLogoutHandler customLogoutHandler; - @Bean - public DaoAuthenticationProvider authenticationProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - authProvider.setUserDetailsService(userDetailsService); - authProvider.setPasswordEncoder(encoder()); - return authProvider; - } - @Bean public PasswordEncoder encoder() { return new BCryptPasswordEncoder(); diff --git a/src/main/java/org/isf/security/jwt/TokenProvider.java b/src/main/java/org/isf/security/jwt/TokenProvider.java index c05b840c4..895c81167 100644 --- a/src/main/java/org/isf/security/jwt/TokenProvider.java +++ b/src/main/java/org/isf/security/jwt/TokenProvider.java @@ -79,7 +79,7 @@ public class TokenProvider implements Serializable { @PostConstruct public void init() { String secret = env.getProperty("jwt.token.secret"); - LOGGER.info("Initializing JWT key with secret: {}", secret); + LOGGER.debug("Initializing JWT key with secret: {}", secret); byte[] keyBytes = secret.getBytes(StandardCharsets.UTF_8); this.key = Keys.hmacShaKeyFor(keyBytes); @@ -131,8 +131,8 @@ public Boolean isTokenExpired(String token) { public String generateJwtToken(Authentication authentication, boolean rememberMe) { final String authorities = authentication.getAuthorities().stream() - .map(GrantedAuthority::getAuthority) - .collect(Collectors.joining(",")); + .map(GrantedAuthority::getAuthority) + .collect(Collectors.joining(",")); long now = System.currentTimeMillis(); Date validity; @@ -143,21 +143,21 @@ public String generateJwtToken(Authentication authentication, boolean rememberMe } return Jwts.builder() - .setSubject(authentication.getName()) - .claim(AUTHORITIES_KEY, authorities) - .setIssuedAt(new Date()) - .signWith(key, SignatureAlgorithm.HS512) - .setExpiration(validity) - .compact(); + .setSubject(authentication.getName()) + .claim(AUTHORITIES_KEY, authorities) + .setIssuedAt(new Date()) + .signWith(key, SignatureAlgorithm.HS512) + .setExpiration(validity) + .compact(); } public String generateRefreshToken(Authentication authentication) { return Jwts.builder() - .setSubject(authentication.getName()) - .setIssuedAt(new Date()) - .signWith(key, SignatureAlgorithm.HS512) - .setExpiration(new Date(System.currentTimeMillis() + this.tokenValidityInMillisecondsForRememberMe)) - .compact(); + .setSubject(authentication.getName()) + .setIssuedAt(new Date()) + .signWith(key, SignatureAlgorithm.HS512) + .setExpiration(new Date(System.currentTimeMillis() + this.tokenValidityInMillisecondsForRememberMe)) + .compact(); } public Authentication getAuthentication(String token) { @@ -173,8 +173,8 @@ public Authentication getAuthentication(String token) { } final Collection< ? extends GrantedAuthority> authorities = Arrays.stream(claims.get(AUTHORITIES_KEY).toString().split(",")) - .map(SimpleGrantedAuthority::new) - .collect(Collectors.toList()); + .map(SimpleGrantedAuthority::new) + .collect(Collectors.toList()); User principal = new User(claims.getSubject(), "", authorities);