-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Suppress notifications when updating own work day (#390) * LocalDate#parse -> LocalDate#of for tests
- Loading branch information
Showing
15 changed files
with
334 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/test/kotlin/community/flock/eco/workday/forms/WorkDayFormFixture.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package community.flock.eco.workday.forms | ||
|
||
import java.time.LocalDate | ||
|
||
fun aWorkDayForm() = | ||
WorkDayForm( | ||
from = LocalDate.of(2020, 1, 1), | ||
to = LocalDate.of(2020, 3, 31), | ||
assignmentCode = "some-assignment-code", | ||
hours = 50.0, | ||
sheets = | ||
listOf( | ||
aWorkDaySheetForm(), | ||
), | ||
) |
5 changes: 5 additions & 0 deletions
5
src/test/kotlin/community/flock/eco/workday/forms/WorkDaySheetFormFixture.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package community.flock.eco.workday.forms | ||
|
||
import java.util.UUID | ||
|
||
fun aWorkDaySheetForm() = WorkDaySheetForm("some-work-day-sheet", UUID.fromString("e03c0587-bb84-49f7-aaa8-34cfc76b4c8b")) |
15 changes: 15 additions & 0 deletions
15
src/test/kotlin/community/flock/eco/workday/model/AssignmentFixture.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package community.flock.eco.workday.model | ||
|
||
import java.time.LocalDate | ||
|
||
fun anAssignment( | ||
person: Person = aPerson(), | ||
client: Client = aClient(), | ||
) = Assignment( | ||
from = LocalDate.of(2024, 1, 1), | ||
to = LocalDate.of(2024, 12, 31), | ||
hourlyRate = 100.0, | ||
hoursPerWeek = 40, | ||
client = client, | ||
person = person, | ||
) |
8 changes: 8 additions & 0 deletions
8
src/test/kotlin/community/flock/eco/workday/model/ClientFixture.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package community.flock.eco.workday.model | ||
|
||
fun aClient() = | ||
Client( | ||
id = 5, | ||
code = "27620486-77f5-4484-b155-6e318bd24921", | ||
name = "DHL", | ||
) |
19 changes: 19 additions & 0 deletions
19
src/test/kotlin/community/flock/eco/workday/model/WorkDayFixture.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package community.flock.eco.workday.model | ||
|
||
import java.time.LocalDate | ||
|
||
fun aWorkDay(assignment: Assignment = anAssignment()) = | ||
WorkDay( | ||
id = 3, | ||
code = "41b23e2e-bb80-45d3-aac5-f764aa7b2fc3", | ||
from = LocalDate.of(2024, 1, 1), | ||
to = LocalDate.of(2024, 1, 31), | ||
hours = 160.0, | ||
days = listOf(), | ||
assignment = assignment, | ||
status = Status.REQUESTED, | ||
sheets = | ||
listOf( | ||
aWorkDaySheet(), | ||
), | ||
) |
5 changes: 5 additions & 0 deletions
5
src/test/kotlin/community/flock/eco/workday/model/WorkDaySheetFixture.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package community.flock.eco.workday.model | ||
|
||
import java.util.UUID | ||
|
||
fun aWorkDaySheet() = WorkDaySheet("some-sheet", UUID.fromString("51b23e2e-bb80-45d3-aac5-f764aa7b2fc3")) |
77 changes: 77 additions & 0 deletions
77
src/test/kotlin/community/flock/eco/workday/services/WorkDayServiceIntegrationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package community.flock.eco.workday.services | ||
|
||
import community.flock.eco.workday.ApplicationConfiguration | ||
import community.flock.eco.workday.config.AppTestConfig | ||
import community.flock.eco.workday.forms.WorkDayForm | ||
import community.flock.eco.workday.helpers.CreateHelper | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa | ||
import org.springframework.boot.test.autoconfigure.web.client.AutoConfigureWebClient | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.context.annotation.Import | ||
import org.springframework.test.context.ActiveProfiles | ||
import java.time.LocalDate | ||
import javax.transaction.Transactional | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertNotNull | ||
import kotlin.test.assertNull | ||
|
||
@SpringBootTest(classes = [ApplicationConfiguration::class, AppTestConfig::class]) | ||
@AutoConfigureTestDatabase | ||
@AutoConfigureDataJpa | ||
@AutoConfigureWebClient | ||
@Transactional | ||
@Import(CreateHelper::class) | ||
@ActiveProfiles(profiles = ["test"]) | ||
class WorkDayServiceIntegrationTest( | ||
@Autowired private val workDayService: WorkDayService, | ||
@Autowired private val createHelper: CreateHelper, | ||
) { | ||
@Test | ||
fun `Create, update and delete work day`() { | ||
val from = LocalDate.of(2020, 1, 1) | ||
val to = LocalDate.of(2020, 3, 31) | ||
val client = createHelper.createClient() | ||
val person = createHelper.createPerson() | ||
val assignment = createHelper.createAssignment(client, person, from, to) | ||
|
||
val createForm = | ||
WorkDayForm( | ||
from = from, | ||
to = to, | ||
assignmentCode = assignment.code, | ||
hours = 50.0, | ||
sheets = listOf(), | ||
) | ||
|
||
val created = workDayService.create(createForm) | ||
assertNotNull(created.id) | ||
assertEquals(50.0, created.hours) | ||
|
||
val updateForm = | ||
WorkDayForm( | ||
from = from, | ||
to = to, | ||
assignmentCode = assignment.code, | ||
hours = 25.0, | ||
sheets = listOf(), | ||
) | ||
val updated = | ||
workDayService.update( | ||
workDayCode = created.code, | ||
form = updateForm, | ||
isOwnWorkDay = false, | ||
) | ||
assertNotNull(updated.id) | ||
assertEquals(25.0, updated.hours) | ||
assertEquals(created.code, updated.code) | ||
|
||
assertNotNull(workDayService.findByCode(created.code)) | ||
|
||
workDayService.deleteByCode(created.code) | ||
|
||
assertNull(workDayService.findByCode(created.code)) | ||
} | ||
} |
Oops, something went wrong.