Skip to content

Commit

Permalink
fix: 세미나 시간 타입 변경 (#91)
Browse files Browse the repository at this point in the history
* fix: 세미나 시간 LocalDateTime으로 변경

* test: 테스트 수정
  • Loading branch information
leeeryboy authored Sep 11, 2023
1 parent ea640a4 commit cba2428
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.wafflestudio.csereal.core.resource.attachment.database.AttachmentEnti
import com.wafflestudio.csereal.core.resource.mainImage.database.MainImageEntity
import com.wafflestudio.csereal.core.seminar.dto.SeminarDto
import jakarta.persistence.*
import java.time.LocalDateTime

@Entity(name = "seminar")
class SeminarEntity(
Expand Down Expand Up @@ -35,8 +36,8 @@ class SeminarEntity(
var affiliation: String,
var affiliationURL: String?,

var startDate: String?,
var endDate: String?,
var startDate: LocalDateTime?,
var endDate: LocalDateTime?,

var location: String,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.querydsl.core.BooleanBuilder
import com.querydsl.jpa.impl.JPAQueryFactory
import com.wafflestudio.csereal.common.CserealException
import com.wafflestudio.csereal.common.utils.FixedPageRequest
import com.wafflestudio.csereal.common.utils.cleanTextFromHtml
import com.wafflestudio.csereal.core.resource.mainImage.service.MainImageService
import com.wafflestudio.csereal.core.seminar.database.QSeminarEntity.seminarEntity
import com.wafflestudio.csereal.core.seminar.dto.SeminarSearchDto
Expand Down Expand Up @@ -75,11 +74,7 @@ class SeminarRepositoryImpl(
var isYearLast = false
if (i == seminarEntityList.size - 1) {
isYearLast = true
} else if (seminarEntityList[i].startDate?.substring(0, 4) != seminarEntityList[i + 1].startDate?.substring(
0,
4
)
) {
} else if (seminarEntityList[i].startDate?.year != seminarEntityList[i + 1].startDate?.year) {
isYearLast = true
}

Expand All @@ -100,6 +95,6 @@ class SeminarRepositoryImpl(
)
}

return SeminarSearchResponse(total!!, seminarSearchDtoList)
return SeminarSearchResponse(total, seminarSearchDtoList)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ data class SeminarDto(
val speakerTitle: String?,
val affiliation: String,
val affiliationURL: String?,
val startDate: String?,
val endDate: String?,
val startDate: LocalDateTime?,
val endDate: LocalDateTime?,
val location: String,
val host: String?,
val additionalNote: String?,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package com.wafflestudio.csereal.core.seminar.dto

import com.querydsl.core.annotations.QueryProjection
import java.time.LocalDateTime

data class SeminarSearchDto @QueryProjection constructor(
val id: Long,
val title: String,
val description: String,
val name: String,
val affiliation: String,
val startDate: String?,
val startDate: LocalDateTime?,
val location: String,
val imageURL: String?,
val isYearLast: Boolean,
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import io.kotest.matchers.shouldNotBe
import jakarta.transaction.Transactional
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.data.repository.findByIdOrNull
import java.time.LocalDateTime

@SpringBootTest
@Transactional
class SeminarServiceTest (
class SeminarServiceTest(
private val seminarService: SeminarService,
private val seminarRepository: SeminarRepository,
): BehaviorSpec() {
) : BehaviorSpec() {
init {

beforeContainer {
Expand All @@ -27,42 +28,42 @@ class SeminarServiceTest (

Given("세미나를 생성하려고 할 때") {
val seminarDTO = SeminarDto(
id = -1,
title = "title",
description = """
id = -1,
title = "title",
description = """
<h1>Hello, World!</h1>
<p>This is seminar description.</p>
<h3>Goodbye, World!</h3>
""".trimIndent(),
introduction = """
introduction = """
<h1>Hello, World!</h1>
<p>This is seminar introduction.</p>
<h3>Goodbye, World!</h3>
""".trimIndent(),
name = "name",
speakerURL = "speakerURL",
speakerTitle = "speakerTitle",
affiliation = "affiliation",
affiliationURL = "affiliationURL",
startDate = "startDate",
endDate = "endDate",
location = "location",
host = "host",
additionalNote = """
name = "name",
speakerURL = "speakerURL",
speakerTitle = "speakerTitle",
affiliation = "affiliation",
affiliationURL = "affiliationURL",
startDate = LocalDateTime.now(),
endDate = LocalDateTime.now(),
location = "location",
host = "host",
additionalNote = """
<h1>Hello, World!</h1>
<p>This is seminar additionalNote.</p>
<h3>Goodbye, World!</h3>
""".trimIndent(),
createdAt = null,
modifiedAt = null,
isPrivate = false,
isImportant = false,
prevId = null,
prevTitle = null,
nextId = null,
nextTitle = null,
imageURL = null,
attachments = null
createdAt = null,
modifiedAt = null,
isPrivate = false,
isImportant = false,
prevId = null,
prevTitle = null,
nextId = null,
nextTitle = null,
imageURL = null,
attachments = null
)
When("간단한 세미나 DTO가 주어지면") {
val resultSeminarDTO = seminarService.createSeminar(seminarDTO, null, null)
Expand All @@ -83,58 +84,58 @@ class SeminarServiceTest (

Given("기존 간단한 세미나의 Description을 수정하려고 할 때") {
val originalSeminar = seminarRepository.save(
SeminarEntity(
title = "title",
description = """
SeminarEntity(
title = "title",
description = """
<h1>Hello, World!</h1>
<p>This is seminar description.</p>
<h3>Goodbye, World!</h3>
""".trimIndent(),
plainTextDescription = "Hello, World! This is seminar description. Goodbye, World!",
introduction = """
plainTextDescription = "Hello, World! This is seminar description. Goodbye, World!",
introduction = """
<h1>Hello, World!</h1>
<p>This is seminar introduction.</p>
<h3>Goodbye, World!</h3>
""".trimIndent(),
plainTextIntroduction = "Hello, World! This is seminar introduction. Goodbye, World!",
name = "name",
speakerURL = "speakerURL",
speakerTitle = "speakerTitle",
affiliation = "affiliation",
affiliationURL = "affiliationURL",
startDate = "startDate",
endDate = "endDate",
location = "location",
host = "host",
additionalNote = """
plainTextIntroduction = "Hello, World! This is seminar introduction. Goodbye, World!",
name = "name",
speakerURL = "speakerURL",
speakerTitle = "speakerTitle",
affiliation = "affiliation",
affiliationURL = "affiliationURL",
startDate = LocalDateTime.now(),
endDate = LocalDateTime.now(),
location = "location",
host = "host",
additionalNote = """
<h1>Hello, World!</h1>
<p>This is seminar additionalNote.</p>
<h3>Goodbye, World!</h3>
""".trimIndent(),
plainTextAdditionalNote = "Hello, World! This is seminar additionalNote. Goodbye, World!",
isPrivate = false,
isImportant = false,
)
plainTextAdditionalNote = "Hello, World! This is seminar additionalNote. Goodbye, World!",
isPrivate = false,
isImportant = false,
)
)
val originalId = originalSeminar.id

When("수정된 DTO를 이용하여 수정하면") {
val modifiedSeminarDTO = SeminarDto.of(
originalSeminar, null, emptyList(), null
originalSeminar, null, emptyList(), null
).copy(
description = """
description = """
<h1>Hello, World!</h1>
<p>This is modified seminar description.</p>
<h3>Goodbye, World!</h3>
<p>And this is a new line.</p>
""".trimIndent(),
introduction = """
introduction = """
<h1>Hello, World!</h1>
<p>This is modified seminar introduction.</p>
<h3>Goodbye, World!</h3>
<p>And this is a new line.</p>
""".trimIndent(),
additionalNote = """
additionalNote = """
<h1>Hello, World!</h1>
<p>This is modified seminar additionalNote.</p>
<h3>Goodbye, World!</h3>
Expand All @@ -143,11 +144,11 @@ class SeminarServiceTest (
)

val modifiedSeminarDto = seminarService.updateSeminar(
originalSeminar.id,
modifiedSeminarDTO,
null,
null,
emptyList()
originalSeminar.id,
modifiedSeminarDTO,
null,
null,
emptyList()
)

Then("같은 Entity가 수정되어야 한다.") {
Expand All @@ -165,4 +166,4 @@ class SeminarServiceTest (
}
}
}
}
}

0 comments on commit cba2428

Please sign in to comment.