Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luismendes070/desafio-parcelas
https://github.com/luismendes070/desafio-parcelas/blob/main/credit-application-system/src/test/kotlin/me/dio/credit/application/system/service/CustomerServiceTest.kt
https://github.com/luismendes070/desafio-parcelas
digital-innovation-one dio dio-bootcamp kotlin kotlin-backend mockk openapi spring-boot spring-boot-starter-validation springdoc swagger validation
Last synced: about 2 months ago
JSON representation
https://github.com/luismendes070/desafio-parcelas/blob/main/credit-application-system/src/test/kotlin/me/dio/credit/application/system/service/CustomerServiceTest.kt
- Host: GitHub
- URL: https://github.com/luismendes070/desafio-parcelas
- Owner: luismendes070
- License: apache-2.0
- Created: 2023-12-06T14:51:06.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-08T18:28:12.000Z (about 1 year ago)
- Last Synced: 2024-05-01T19:35:19.384Z (8 months ago)
- Topics: digital-innovation-one, dio, dio-bootcamp, kotlin, kotlin-backend, mockk, openapi, spring-boot, spring-boot-starter-validation, springdoc, swagger, validation
- Language: Kotlin
- Homepage: https://github.com/luismendes070/desafio-parcelas/blob/main/credit-application-system/src/test/kotlin/me/dio/credit/application/system/service/CustomerServiceTest.kt
- Size: 92.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# desafio-parcelas
Modificações
https://github.com/luismendes070/desafio-parcelas/blob/main/credit-application-system/src/test/kotlin/me/dio/credit/application/system/service/CustomerServiceTest.kt@Test
fun `should the date of the first installment must be a maximum of 3 months after the current day`() {
//given
val fakeCustomer: Customer = buildCustomer()
every { customerRepository.save(any()) } returns fakeCustomer
//when
val actual: Customer = customerService.save(fakeCustomer)
//then ChatGPT// Get the current date and time
val currentDate = LocalDateTime.now()// Calculate the date for the first installment (maximum 3 months from now)
val firstInstallmentDate = currentDate.plusMonths(3)// Print the result
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
println("Current Date and Time: ${currentDate.format(formatter)}")
println("First Installment Date: ${firstInstallmentDate.format(formatter)}")// Use AssertJ to make assertions
assertThat(firstInstallmentDate).isAfterOrEqualTo(currentDate)
.isBeforeOrEqualTo(currentDate.plusMonths(3))Assertions.assertThat(actual).isNotNull
Assertions.assertThat(actual).isSameAs(fakeCustomer)
verify(exactly = 1) { customerRepository.save(fakeCustomer) }
}@Test
fun `should the maximum installments allowed will be 48`() {
//given
val fakeCustomer: Customer = buildCustomer()
every { customerRepository.save(any()) } returns fakeCustomer
//when
val actual: Customer = customerService.save(fakeCustomer)// actual.installments = 48
//then
Assertions.assertThat(actual.installments).isSameAs(fakeCustomer.installments)
Assertions.assertThat(actual).isNotNull
Assertions.assertThat(actual).isSameAs(fakeCustomer)
verify(exactly = 1) { customerRepository.save(fakeCustomer) }
}https://github.com/luismendes070/desafio-parcelas/blob/main/credit-application-system/src/main/kotlin/me/dio/credit/application/system/entity/Customer.kt
@Column(nullable = false) var currentDay: LocalDateTime = LocalDateTime.now(),
@Column(nullable = false) var installments: Int = 0,private fun buildCustomer(
currentDay: LocalDateTime = LocalDateTime.now(),
installments: Int = 48,
firstName: String = "Cami",
lastName: String = "Cavalcante",
cpf: String = "28475934625",
email: String = "[email protected]",
password: String = "12345",
zipCode: String = "12345",
street: String = "Rua da Cami",
income: BigDecimal = BigDecimal.valueOf(1000.0),
id: Long = 1L
) = Customer(
currentDay = currentDay,
installments = installments,
firstName = firstName,
lastName = lastName,
cpf = cpf,
email = email,
password = password,
address = Address(
zipCode = zipCode,
street = street,
),
income = income,
id = id
)
IntelliJ plugins
Hiberbee
Rainbow brackets
Mario Progress Bar