Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1-create-table-for-medtype' into…
Browse files Browse the repository at this point in the history
… web_admin_panel
  • Loading branch information
beyzaaydeniz committed Jan 2, 2024
2 parents e109d98 + 7afcf92 commit 013bdbc
Show file tree
Hide file tree
Showing 18 changed files with 1,057 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;

public class ScheduleDTO {
private Integer scheduleID;
@JsonFormat(pattern = "dd-MM-yyyy HH:mm")
@DateTimeFormat(pattern = "dd-MM-yyyy HH:mm")
private LocalDateTime beginningDate;
@JsonFormat(pattern = "dd-MM-yyyy")
@DateTimeFormat(pattern = "dd-MM-yyyy")
private LocalDate beginningDate;
private Integer doseFrequency;
private Integer doseCount;
public ScheduleDTO(){

}
public ScheduleDTO(Integer scheduleID, List<MedicationDTO> medications,
LocalDateTime beginningDate, Integer doseFrequency, Integer doseCount) {
LocalDate beginningDate, Integer doseFrequency, Integer doseCount) {
this.scheduleID = scheduleID;
this.beginningDate = beginningDate;
this.doseFrequency = doseFrequency;
Expand All @@ -33,11 +33,11 @@ public void setScheduleID(Integer scheduleID) {
this.scheduleID = scheduleID;
}

public LocalDateTime getBeginningDate() {
public LocalDate getBeginningDate() {
return beginningDate;
}

public void setBeginningDate(LocalDateTime beginningDate) {
public void setBeginningDate(LocalDate beginningDate) {
this.beginningDate = beginningDate;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.production.ehayvanbackendapi.DTO.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.production.ehayvanbackendapi.DTO.AppointmentDTO;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
Expand All @@ -14,6 +15,13 @@ public class CreateOrUpdateAppointmentDTO {
private Integer vetID;
private Integer petOwnerID;

public CreateOrUpdateAppointmentDTO(AppointmentDTO appointmentDTO) {
this.petID = appointmentDTO.getPetID();
this.vetID = appointmentDTO.getVetID();
this.petOwnerID = appointmentDTO.getPetOwnerID();
this.appointmentDate = appointmentDTO.getAppointmentDate();
}

public LocalDateTime getAppointmentDate() {
return appointmentDate;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.production.ehayvanbackendapi.DTO.request;

import com.production.ehayvanbackendapi.DTO.MedicationDTO;

public class CreateOrUpdateMedicationDTO {
private String medicationName;
private Integer medTypeID;
Expand All @@ -13,6 +15,13 @@ public CreateOrUpdateMedicationDTO(String medicationName, Integer medTypeID, Cre
this.petID = petID;
}

public CreateOrUpdateMedicationDTO(MedicationDTO medicationDTO) {
this.medicationName = medicationDTO.getMedicationName();
this.medTypeID = medicationDTO.getMedTypeID();
this.scheduleID = new CreateOrUpdateScheduleDTO(medicationDTO.getScheduleID());
this.petID = medicationDTO.getPetID();
}

public String getMedicationName() {
return medicationName;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
package com.production.ehayvanbackendapi.DTO.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.production.ehayvanbackendapi.DTO.ScheduleDTO;
import org.springframework.cglib.core.Local;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.time.LocalDate;
import java.util.Date;

public class CreateOrUpdateScheduleDTO {

@JsonFormat(pattern = "dd-MM-yyyy HH:mm")
@DateTimeFormat(pattern = "dd-MM-yyyy HH:mm")
private LocalDateTime beginningDate;
@JsonFormat(pattern = "dd-MM-yyyy")
@DateTimeFormat(pattern = "dd-MM-yyyy")
private LocalDate beginningDate;
private Integer doseFrequency;
private Integer doseCount;

public LocalDateTime getBeginningDate() {
public CreateOrUpdateScheduleDTO() {

}

public CreateOrUpdateScheduleDTO(ScheduleDTO scheduleDTO) {
this.beginningDate = scheduleDTO.getBeginningDate();
this.doseFrequency = scheduleDTO.getDoseFrequency();
this.doseCount = scheduleDTO.getDoseCount();
}

public LocalDate getBeginningDate() {
return beginningDate;
}

public void setBeginningDate(LocalDateTime beginningDate) {
public void setBeginningDate(LocalDate beginningDate) {
this.beginningDate = beginningDate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.springframework.cglib.core.Local;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;

Expand All @@ -19,10 +19,10 @@ public class Schedule {
private Integer ScheduleID;
@OneToMany(mappedBy = "ScheduleID", cascade = CascadeType.ALL)
private List<Medication> medications;
@JsonFormat(pattern = "dd-MM-yyyy HH:mm")
@DateTimeFormat(pattern = "dd-MM-yyyy HH:mm")
@JsonFormat(pattern = "dd-MM-yyyy")
@DateTimeFormat(pattern = "dd-MM-yyyy")
@Column(nullable = false)
private LocalDateTime beginningDate;
private LocalDate beginningDate;
@Column(nullable = false)
private Integer doseFrequency;
@Column(nullable = false)
Expand All @@ -34,10 +34,10 @@ public Integer getScheduleID() {
public void setScheduleID(Integer scheduleID) {
ScheduleID = scheduleID;
}
public LocalDateTime getBeginningDate() {
public LocalDate getBeginningDate() {
return beginningDate;
}
public void setBeginningDate(LocalDateTime beginningDate) {
public void setBeginningDate(LocalDate beginningDate) {
this.beginningDate = beginningDate;
}
public Integer getDoseFrequency() {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.PostgreSQLDialect
spring.security.user.name=test
spring.security.user.password=password
spring.datasource.hikari.maximum-pool-size=2
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.time.Month;

import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
Expand Down Expand Up @@ -61,6 +64,9 @@ public void setUp() {
public void onEachTestStart() {
testCreateOrUpdateScheduleDTO = new CreateOrUpdateScheduleDTO();
testCreateOrUpdateMedicationDTO = new CreateOrUpdateMedicationDTO("elma", 1, testCreateOrUpdateScheduleDTO, 1);
testCreateOrUpdateMedicationDTO.getScheduleID().setBeginningDate(LocalDate.of(2034, Month.JANUARY, 1));
testCreateOrUpdateMedicationDTO.getScheduleID().setDoseCount(54);
testCreateOrUpdateMedicationDTO.getScheduleID().setDoseFrequency(100);
}

@AfterEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.sql.Date;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.List;

@SpringBootTest
Expand All @@ -30,13 +31,13 @@ void createEntity() {

Appointment test_appointment = new Appointment();
test_appointment.setAppointmentID(1773);
test_appointment.setAppointmentDate(LocalDateTime.now());
test_appointment.setAppointmentDate(LocalDateTime.of(2034, Month.JANUARY, 4, 9, 5));
test_appointment.setPetID(test_pet);
test_appointment.setVetID(test_veterinarian);
test_appointment.setPetOwnerID(test_pet_owner);

assertThat(test_appointment.getAppointmentID()).isEqualTo(1773);
assertThat(test_appointment.getAppointmentDate()).isEqualTo(LocalDate.now());
assertThat(test_appointment.getAppointmentDate()).isEqualTo(LocalDateTime.of(2034, Month.JANUARY, 4, 9, 5));
assertThat(test_appointment.getPetID().getAppointments().size()).isEqualTo(4);
assertThat(test_appointment.getVetID().getAppointments().size()).isEqualTo(2);
assertThat(test_appointment.getPetOwnerID().getAppointments().size()).isEqualTo(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.time.LocalDate;
import java.util.Date;
import java.util.List;

Expand All @@ -17,13 +18,13 @@ void createEntity() {
Schedule test_schedule = new Schedule();
test_schedule.setDoseCount(15);
test_schedule.setScheduleID(1915);
// test_schedule.setBeginningDate(new Date(3451));
test_schedule.setBeginningDate(LocalDate.ofEpochDay(3451));
test_schedule.setMedications(List.of(new Medication()));
test_schedule.setDoseFrequency(20);

assertThat(test_schedule.getDoseCount()).isEqualTo(15);
assertThat(test_schedule.getScheduleID()).isEqualTo(1915);
assertThat(test_schedule.getBeginningDate()).isEqualTo(new Date(3451));
assertThat(test_schedule.getBeginningDate()).isEqualTo(LocalDate.ofEpochDay(3451));
assertThat(test_schedule.getDoseFrequency()).isEqualTo(20);
}

Expand Down
Loading

0 comments on commit 013bdbc

Please sign in to comment.