Skip to content

Commit

Permalink
Merge pull request #17 from FIAP-3SOAT-G15/improve-tests
Browse files Browse the repository at this point in the history
Improve tests
  • Loading branch information
wellyfrs authored Jul 26, 2024
2 parents beaa3ed + 5da47fc commit ffa94d4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ interface DoctorMapper {
}

fun convertAvailable(availableTimes: AvailableTimes): String {
val mapper = ObjectMapper().registerModule(JavaTimeModule());
return mapper.writeValueAsString(availableTimes);
val mapper = ObjectMapper().registerModule(JavaTimeModule())
return mapper.writeValueAsString(availableTimes)
}

fun convertAvailable(availableTimes: String): AvailableTimes {
val mapper = ObjectMapper().registerModule(JavaTimeModule());
return mapper.readValue(availableTimes, AvailableTimes::class.java);
val mapper = ObjectMapper().registerModule(JavaTimeModule())
return mapper.readValue(availableTimes, AvailableTimes::class.java)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import io.restassured.RestAssured.given
import io.restassured.http.ContentType
import io.restassured.response.Response
import org.assertj.core.api.Assertions.assertThat
import org.hamcrest.CoreMatchers.equalTo
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.HttpStatus

Expand Down Expand Up @@ -59,17 +58,8 @@ class RegisterDoctorIntegrationTest: IntegrationTest() {
response
.then()
.statusCode(HttpStatus.OK.value())
.body(
"crm", equalTo(doctorRequest.crm),
"document", equalTo(doctorRequest.document),
"specialty", equalTo(doctorRequest.specialty),
"name", equalTo(doctorRequest.name),
"email", equalTo(doctorRequest.email),
"phoneNumber", equalTo(doctorRequest.phoneNumber),
"serviceZipCode", equalTo(doctorRequest.serviceZipCode),
"serviceAddress", equalTo(doctorRequest.serviceAddress),
"availableTimes", equalTo(doctorRequest.availableTimes.toDomain()),
"appointmentPrice", equalTo(doctorRequest.appointmentPrice),
)
.extract()
.`as`(Doctor::class.java)
.also { assertThat(it).isEqualTo(doctorRequest.toDomain()) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package com.fiap.healthmed.it
import com.fiap.healthmed.adapter.gateway.PatientGateway
import com.fiap.healthmed.domain.Patient
import com.fiap.healthmed.driver.web.request.PatientRequest
import com.fiap.healthmed.driver.web.request.toDomain
import io.cucumber.java.en.Given
import io.cucumber.java.en.Then
import io.cucumber.java.en.When
import io.restassured.RestAssured.given
import io.restassured.http.ContentType
import io.restassured.response.Response
import org.assertj.core.api.Assertions.assertThat
import org.hamcrest.CoreMatchers.equalTo
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.HttpStatus

Expand Down Expand Up @@ -54,13 +54,10 @@ class RegisterPatientIntegrationTest: IntegrationTest() {
response
.then()
.statusCode(HttpStatus.OK.value())
.body(
"document", equalTo(patientRequest.document),
"name", equalTo(patientRequest.name),
"email", equalTo(patientRequest.email),
"phoneNumber", equalTo(patientRequest.phoneNumber),
"zipCode", equalTo(patientRequest.zipCode),
"address", equalTo(patientRequest.address),
)
.extract()
.`as`(Patient::class.java)
.also {
assertThat(it).isEqualTo(patientRequest.toDomain())
}
}
}
14 changes: 7 additions & 7 deletions src/test/resources/features/Doctor.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Feature: Doctor
#
# @database
# Scenario: Registering doctor
# Given valid data for doctor
# When request to register doctor
# Then doctor should be registered
Feature: Doctor

@database
Scenario: Registering doctor
Given valid data for doctor
When request to register doctor
Then doctor should be registered

0 comments on commit ffa94d4

Please sign in to comment.