-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced InMemReferenceLayerRepository to make tests clearer
- Loading branch information
1 parent
0366ed8
commit a9ed746
Showing
4 changed files
with
127 additions
and
138 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
maps/src/test/java/org/odk/collect/maps/layers/InMemReferenceLayerRepository.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,29 @@ | ||
package org.odk.collect.maps.layers | ||
|
||
import java.io.File | ||
|
||
class InMemReferenceLayerRepository : ReferenceLayerRepository { | ||
val sharedLayers = mutableListOf<ReferenceLayer>() | ||
val projectLayers = mutableListOf<ReferenceLayer>() | ||
|
||
override fun getAll(): List<ReferenceLayer> { | ||
return sharedLayers + projectLayers | ||
} | ||
|
||
override fun get(id: String): ReferenceLayer? { | ||
return sharedLayers.find { it.id == id } ?: projectLayers.find { it.id == id } | ||
} | ||
|
||
override fun addLayer(file: File, shared: Boolean) { | ||
if (shared) { | ||
sharedLayers.add(ReferenceLayer(file.absolutePath, file, file.name)) | ||
} else { | ||
projectLayers.add(ReferenceLayer(file.absolutePath, file, file.name)) | ||
} | ||
} | ||
|
||
override fun delete(id: String) { | ||
sharedLayers.removeIf { it.id == id } | ||
projectLayers.removeIf { it.id == id } | ||
} | ||
} |
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
Oops, something went wrong.