Skip to content

Commit

Permalink
Remove optional types in event store interface
Browse files Browse the repository at this point in the history
  • Loading branch information
matus-tomlein committed Jan 25, 2024
1 parent 1789fe5 commit df6cef3
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class EventStoreTest {
@Throws(InterruptedException::class)
fun testRemoveRangeOfEvents() {
val eventStore = eventStore()
val idList: MutableList<Long?> = ArrayList()
val idList: MutableList<Long> = ArrayList()
idList.add(eventStore.insertEvent(payload()))
idList.add(eventStore.insertEvent(payload()))
idList.add(eventStore.insertEvent(payload()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MockEventStore : EventStore {
}
}

override fun removeEvents(ids: MutableList<Long?>): Boolean {
override fun removeEvents(ids: MutableList<Long>): Boolean {
var result = true
for (id in ids) {
val removed = removeEvent(id!!)
Expand All @@ -60,11 +60,11 @@ class MockEventStore : EventStore {
return db.size.toLong()
}

override fun getEmittableEvents(queryLimit: Int): List<EmitterEvent?> {
override fun getEmittableEvents(queryLimit: Int): List<EmitterEvent> {
synchronized(this) {
val eventIds: MutableList<Long> = ArrayList()
val eventPayloads: MutableList<String> = ArrayList()
var events: MutableList<EmitterEvent?> = ArrayList()
var events: MutableList<EmitterEvent> = ArrayList()
for ((key, value) in db) {
val payloadCopy: Payload = TrackerPayload()
payloadCopy.addMap(value!!.map)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ class Emitter(
var successCount = 0
var failedWillRetryCount = 0
var failedWontRetryCount = 0
val removableEvents: MutableList<Long?> = ArrayList()
val removableEvents: MutableList<Long> = ArrayList()

for (res in results) {
if (res.isSuccessful) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class SQLiteEventStore(context: Context, private val namespace: String) : EventS
return retval == 1
}

override fun removeEvents(ids: MutableList<Long?>): Boolean {
override fun removeEvents(ids: MutableList<Long>): Boolean {
if (ids.isEmpty()) {
return false
}
Expand Down Expand Up @@ -215,12 +215,12 @@ class SQLiteEventStore(context: Context, private val namespace: String) : EventS
}
}

override fun getEmittableEvents(queryLimit: Int): List<EmitterEvent?> {
override fun getEmittableEvents(queryLimit: Int): List<EmitterEvent> {
if (!databaseOpen) {
return emptyList<EmitterEvent>()
}
insertWaitingEventsIfReady()
val events = ArrayList<EmitterEvent?>()
val events = ArrayList<EmitterEvent>()

// FIFO Pattern for sending events
for (eventMetadata in getDescEventsInRange(queryLimit)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface EventStore {
* @param ids the events' identifiers in the store.
* @return a boolean of success to remove.
*/
fun removeEvents(ids: MutableList<Long?>): Boolean
fun removeEvents(ids: MutableList<Long>): Boolean

/**
* Empties the store of all the events.
Expand All @@ -54,5 +54,5 @@ interface EventStore {
* Returns a list of [EmitterEvent] objects which contain events and related IDs.
* @return EmitterEvent objects containing eventIds and event payloads.
*/
fun getEmittableEvents(queryLimit: Int): List<EmitterEvent?>
fun getEmittableEvents(queryLimit: Int): List<EmitterEvent>
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import java.util.*
class RequestResult(
val statusCode: Int,
val oversize: Boolean,
val eventIds: List<Long?>
val eventIds: List<Long>
) {
/**
* @return the requests success status
Expand Down

0 comments on commit df6cef3

Please sign in to comment.