Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/anew/test taxi driver info #110

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.hh2.katj.taxidriver.controller

import com.fasterxml.jackson.annotation.JsonProperty
import com.hh2.katj.taxidriver.model.dto.request.AddTotalInfoRequest
import com.hh2.katj.taxidriver.model.dto.request.UpdateStatusRequest
import com.hh2.katj.taxidriver.model.dto.response.TaxiDriverResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.hh2.katj.taxidriver.component.TaxiDriverManager
import com.hh2.katj.taxidriver.model.dto.request.UpdateStatusRequest
import com.hh2.katj.taxidriver.model.dto.response.TaxiDriverResponse
import com.hh2.katj.taxidriver.model.entity.TaxiDriver
import com.hh2.katj.taxidriver.model.entity.TaxiDriverStatus
import org.springframework.stereotype.Service

@Service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,75 @@
package com.hh2.katj.taxidriver.controller

import com.hh2.katj.taxi.model.ChargeType
import com.hh2.katj.taxi.model.FuelType
import com.hh2.katj.taxi.model.Taxi
import com.hh2.katj.taxi.repository.TaxiRepository
import com.hh2.katj.taxidriver.model.entity.TaxiDriverStatus
import com.hh2.katj.taxidriver.fixtures.TaxiDriverTestFixtures.Companion.드라이버_생성
import com.hh2.katj.taxidriver.repository.TaxiDriverRepository
import com.hh2.katj.util.annotation.KATJTestContainerE2E
import com.hh2.katj.util.model.BaseTestEntity
import com.hh2.katj.util.model.Gender
import com.hh2.katj.util.model.RoadAddress
import org.assertj.core.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import java.time.LocalDate

@KATJTestContainerE2E
class TaxiDriverAcceptanceTest(): BaseTestEntity() {
class TaxiDriverAcceptanceTest(
private val taxiDriverRepository: TaxiDriverRepository,
private val taxiRepository: TaxiRepository,
): BaseTestEntity() {

@BeforeEach
fun setUp() {

taxiDriverRepository.deleteAllInBatch()
taxiRepository.deleteAllInBatch()
}

/**
* given: 새로운 택시를 생성하고
* when: 드라이버가 배정되고, 드라이버를 조회하면
* then: 새로운 택시를 조회할 수 있다.
*/
@DisplayName("드라이버 생성")
@DisplayName("드라이버 정보 저장")
@Test
fun createTaxiDriver() {
fun creteTaxi() {
val taxi = Taxi(
carNo = "62거4811",
vin = "KMHDL41BP8A000001",
kind = ChargeType.NORMAL,
manufactureDate = LocalDate.now(),
fuel = FuelType.GASOLINE,
color = "white",
insureYN = true,
accidentYN = true,
)
val address = RoadAddress(
addressName = "address_name_three",
region1depthName = "rg1",
region2depthName = "rg2",
region3depthName = "rg3",
roadName = "road_name",
undergroundYn = "Y",
mainBuildingNo = "mbNo",
subBuildingNo = "subNo",
buildingName = "bName",
zoneNo = "1",
longitude = "x.123",
latitude = "y.321",
)
val taxiDriver = 드라이버_생성(
taxi = taxi,
driverLicenseId = "11",
issueDate = LocalDate.now(),
securityId = "test",
name = "안유진",
status = TaxiDriverStatus.WAITING,
gender = Gender.FEMALE,
address = address,
img = "1111"
)
val securityId = taxiDriver.jsonPath().getString("securityId")

Assertions.assertThat(securityId).isEqualTo("test")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@ package com.hh2.katj.taxidriver.fixtures

import com.hh2.katj.taxi.model.Taxi
import com.hh2.katj.taxidriver.model.entity.TaxiDriverStatus

import com.hh2.katj.util.model.Gender
import com.hh2.katj.util.model.RoadAddress
import io.restassured.RestAssured.given
import io.restassured.http.ContentType
import io.restassured.response.ExtractableResponse
import io.restassured.response.Response
import java.time.LocalDate

class TaxiDriverFixtures {
class TaxiDriverTestFixtures {
companion object {
fun 택시드라이버_생성(taxi: Taxi, driverLicenseId: String, issueDate: LocalDate, securityId: String, name: String, status: TaxiDriverStatus, gender: Gender, address: RoadAddress, img: String): String {

fun 드라이버_생성(taxi: Taxi,
driverLicenseId: String,
issueDate: LocalDate,
securityId: String,
name: String,
status: TaxiDriverStatus,
gender: Gender,
address: RoadAddress,
img: String): ExtractableResponse<Response> {
val params: MutableMap<String, Any> = mutableMapOf()

params.put("taxi", taxi)
Expand All @@ -26,10 +36,11 @@ class TaxiDriverFixtures {

return given().log().all()
.body(params).contentType(ContentType.JSON)
.`when`()
.post("/taxiDriver")
.then().log().all()
.extract().jsonPath().getString("id")
.`when`()
.post("/taxidriver/enroll")
.then().log().all()
.extract()

}
}
}
Loading
Loading