Skip to content

Commit

Permalink
Merge pull request #27 from hossain-khan/feat/semantic-data-tests
Browse files Browse the repository at this point in the history
[ADDED] Semantic data timeline tests
  • Loading branch information
hossain-khan authored Mar 15, 2024
2 parents 7a76381 + 04e28af commit c64dc4d
Show file tree
Hide file tree
Showing 4 changed files with 38,005 additions and 31 deletions.
4 changes: 2 additions & 2 deletions parser/src/main/kotlin/model/Records.kt
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ data class Activity(
/**
* Type of activity detected.
*/
val type: String,
val type: String?,
/**
* Value from 0 to 100 indicating the likelihood that the user is performing this activity.
* The larger the value, the more consistent the data used to perform the classification is with the detected activity.
* Multiple activities may have high confidence values. For example, the `ON_FOOT` may have a confidence of 100 while the `RUNNING` activity may have a confidence of 95. The sum of the confidences of all detected activities for a classification does not have to be <= 100 since some activities are not mutually exclusive (for example, you can be walking while in a bus) and some activities are hierarchical (`ON_FOOT` is a generalization of `WALKING` and `RUNNING`).
*/
val confidence: Int,
val confidence: Int?,
)
48 changes: 19 additions & 29 deletions parser/src/main/kotlin/model/Semantic.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,19 @@ import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class TimelineObjects(
/** The type of the TimelineObjects */
@Json(name = "type")
val type: String,
/** The title of the TimelineObjects */
@Json(name = "title")
val title: String,
/** The description of the TimelineObjects */
@Json(name = "description")
val description: String,
/** The properties of the TimelineObjects */
@Json(name = "properties")
val properties: TimelineObjectsProperties,
data class SemanticTimeline(
@Json(name = "timelineObjects")
val timelineObjects: List<TimelineObjectsProperties> = emptyList(),
)

@JsonClass(generateAdapter = true)
data class TimelineObjectsProperties(
/** The activity segment of the TimelineObjectsProperties */
@Json(name = "activitySegment")
val activitySegment: ActivitySegment,
val activitySegment: ActivitySegment?,
/** The place visit of the TimelineObjectsProperties */
@Json(name = "placeVisit")
val placeVisit: PlaceVisit,
val placeVisit: PlaceVisit?,
)

@JsonClass(generateAdapter = true)
Expand All @@ -42,37 +32,37 @@ data class ActivitySegment(
val duration: Duration,
/** The distance of the activity */
@Json(name = "distance")
val distance: Int,
val distance: Int?,
/** The type of the activity */
@Json(name = "activityType")
val activityType: String,
/** The list of activities */
@Json(name = "activities")
val activities: List<Activity>,
val activities: List<Activity> = emptyList(),
/** The confidence of the activity */
@Json(name = "confidence")
val confidence: String,
/** The waypoint path of the activity */
@Json(name = "waypointPath")
val waypointPath: WaypointPath,
val waypointPath: WaypointPath?,
/** The simplified raw path of the activity */
@Json(name = "simplifiedRawPath")
val simplifiedRawPath: SimplifiedRawPath,
val simplifiedRawPath: SimplifiedRawPath?,
/** The transit path of the activity */
@Json(name = "transitPath")
val transitPath: TransitPath,
val transitPath: TransitPath?,
/** The parking event of the activity */
@Json(name = "parkingEvent")
val parkingEvent: ParkingEvent,
val parkingEvent: ParkingEvent?,
/** The edit confirmation status of the activity */
@Json(name = "editConfirmationStatus")
val editConfirmationStatus: String,
val editConfirmationStatus: String?,
/** The edit action metadata of the activity */
@Json(name = "editActionMetadata")
val editActionMetadata: EditActionMetadata,
val editActionMetadata: EditActionMetadata?,
/** The last edited timestamp of the activity */
@Json(name = "lastEditedTimestamp")
val lastEditedTimestamp: String,
val lastEditedTimestamp: String?,
)

@JsonClass(generateAdapter = true)
Expand All @@ -85,13 +75,13 @@ data class Location(
val longitudeE7: Int,
/** Google Maps Place ID of the location */
@Json(name = "placeId")
val placeId: String,
val placeId: String?,
/** Address of the location */
@Json(name = "address")
val address: String,
val address: String?,
/** Name of the location */
@Json(name = "name")
val name: String,
val name: String?,
)

@JsonClass(generateAdapter = true)
Expand Down Expand Up @@ -155,7 +145,7 @@ data class ParkingEvent(
val location: Location,
/** The duration of the parking event */
@Json(name = "duration")
val duration: Duration,
val duration: Duration?,
)

@JsonClass(generateAdapter = true)
Expand Down Expand Up @@ -198,7 +188,7 @@ data class Point(
val lngE7: Int,
/** The timestamp of the point */
@Json(name = "timestamp")
val timestamp: String,
val timestamp: String?,
)

@JsonClass(generateAdapter = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package dev.hossain.timeline.model

import com.google.common.truth.Truth.assertThat
import com.squareup.moshi.Moshi
import kotlin.test.Test

/**
* Test cases for [Settings]
*/
class SemanticTimelineTest {
private val moshi: Moshi = Moshi.Builder().build()

@Test
fun `given records json should parse all records`() {
val json = javaClass.getResourceAsStream("/semantic-2021-august.json")!!.bufferedReader().readText()
val timeline = moshi.adapter(SemanticTimeline::class.java).fromJson(json)!!

assertThat(timeline.timelineObjects).hasSize(125)
}
}
Loading

0 comments on commit c64dc4d

Please sign in to comment.