[R1] Unit test for add doctor use case
This commit is contained in:
parent
c5548d598a
commit
78cb5ace54
@ -0,0 +1,57 @@
|
|||||||
|
package com.mirna.hospitalmanagementapi.unit.application.usecase.doctor;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.TestInstance;
|
||||||
|
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import com.mirna.hospitalmanagementapi.HospitalManagementApiApplication;
|
||||||
|
import com.mirna.hospitalmanagementapi.application.usecase.doctor.AddDoctorUseCase;
|
||||||
|
import com.mirna.hospitalmanagementapi.domain.dtos.AddressDTO;
|
||||||
|
import com.mirna.hospitalmanagementapi.domain.dtos.DoctorDTO;
|
||||||
|
import com.mirna.hospitalmanagementapi.domain.entities.Doctor;
|
||||||
|
import com.mirna.hospitalmanagementapi.domain.enums.Specialty;
|
||||||
|
import com.mirna.hospitalmanagementapi.domain.repositories.DoctorRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Mirna Gama
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
@SpringBootTest(classes = HospitalManagementApiApplication.class)
|
||||||
|
@TestInstance(Lifecycle.PER_CLASS)
|
||||||
|
public class AddDoctorUseCaseTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AddDoctorUseCase addDoctor;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DoctorRepository doctorRepository;
|
||||||
|
|
||||||
|
@AfterAll
|
||||||
|
public void terminate() {
|
||||||
|
doctorRepository.deleteAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should execute save method successfully
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
@DisplayName("Should execute save method")
|
||||||
|
public void testAddDoctor() throws Exception {
|
||||||
|
DoctorDTO doctorDTO = new DoctorDTO("test", "test@gmail.com", "123456", "99999999", Specialty.ORTHOPEDICS,
|
||||||
|
new AddressDTO("TEST STREET", "NEIGHBORHOOD", "12345678", "CITY", "ST", null, null));
|
||||||
|
|
||||||
|
Doctor doctor = new Doctor(doctorDTO);
|
||||||
|
|
||||||
|
doctor = addDoctor.execute(doctor);
|
||||||
|
|
||||||
|
assertNotNull(doctor.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user