-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tech - Correction du cache des unités de contrôles (#3661)
## Linked issues - Resolve #3594 - Le cache ne gère pas les `Deferred`, il faut le gérer manuellement ---- - [ ] Tests E2E (Cypress)
- Loading branch information
Showing
6 changed files
with
87 additions
and
17 deletions.
There are no files selected for viewing
4 changes: 1 addition & 3 deletions
4
...end/src/main/kotlin/fr/gouv/cnsp/monitorfish/domain/repositories/ControlUnitRepository.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 |
---|---|---|
@@ -1,9 +1,7 @@ | ||
package fr.gouv.cnsp.monitorfish.domain.repositories | ||
|
||
import fr.gouv.cnsp.monitorfish.domain.entities.mission.ControlUnit | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Deferred | ||
|
||
interface ControlUnitRepository { | ||
fun findAll(scope: CoroutineScope): Deferred<List<ControlUnit>> | ||
fun findAll(): List<ControlUnit> | ||
} |
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
63 changes: 63 additions & 0 deletions
63
...tlin/fr/gouv/cnsp/monitorfish/infrastructure/monitorenv/APIControlUnitRepositoryITests.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,63 @@ | ||
package fr.gouv.cnsp.monitorfish.infrastructure.monitorenv | ||
|
||
import fr.gouv.cnsp.monitorfish.config.ApiClient | ||
import fr.gouv.cnsp.monitorfish.config.MonitorenvProperties | ||
import io.ktor.client.engine.mock.* | ||
import io.ktor.http.* | ||
import io.ktor.utils.io.* | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
|
||
class APIControlUnitRepositoryITests { | ||
@Test | ||
fun `findAll Should return control units`() { | ||
// Given | ||
val mockEngine = | ||
MockEngine { _ -> | ||
respond( | ||
content = | ||
ByteReadChannel( | ||
"""[ | ||
{ | ||
"id": 10016, | ||
"administration": "Douane", | ||
"isArchived": false, | ||
"name": "BSN Ste Maxime", | ||
"resources": [], | ||
"contact": null | ||
}, | ||
{ | ||
"id": 10017, | ||
"administration": "Douane", | ||
"isArchived": false, | ||
"name": "DF 25 Libecciu", | ||
"resources": [], | ||
"contact": null | ||
}, | ||
{ | ||
"id": 10018, | ||
"administration": "Douane", | ||
"isArchived": false, | ||
"name": "DF 61 Port-de-Bouc", | ||
"resources": [], | ||
"contact": null | ||
} | ||
]""", | ||
), | ||
status = HttpStatusCode.OK, | ||
headers = headersOf(HttpHeaders.ContentType, "application/json"), | ||
) | ||
} | ||
val apiClient = ApiClient(mockEngine) | ||
val monitorenvProperties = MonitorenvProperties() | ||
monitorenvProperties.url = "http://test" | ||
|
||
// When | ||
val controlUnits = | ||
APIControlUnitRepository(monitorenvProperties, apiClient) | ||
.findAll() | ||
|
||
assertThat(controlUnits).hasSize(3) | ||
assertThat(controlUnits.first().id).isEqualTo(10016) | ||
} | ||
} |