Skip to content

Commit 0af790a

Browse files
author
Gerrit Garbereder
committed
Add Activity Exceptions
1 parent 1c7c4bf commit 0af790a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.garbereder.tasktracker.entities
2+
3+
class ActivityNotFoundException(activity: Activity): Exception("Could not find activity: $activity") {
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.garbereder.tasktracker.entities
2+
3+
import kotlinx.datetime.Clock
4+
import kotlinx.datetime.TimeZone
5+
import kotlinx.datetime.toLocalDateTime
6+
import kotlin.test.Test
7+
import kotlin.test.assertEquals
8+
9+
class ActivityNotFoundExceptionTests {
10+
11+
@Test
12+
fun testMessage() {
13+
val task = Task("TaskId", "TaskName")
14+
val start = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault())
15+
val end = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault())
16+
val activity = Activity("1", start, end, task )
17+
val ex = ActivityNotFoundException(activity)
18+
assertEquals("Could not find activity: Activity(id=1, start=${start}, end=${end}, task=${task})", ex.message)
19+
}
20+
21+
}

0 commit comments

Comments
 (0)