-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing department area use cases tests
- Loading branch information
1 parent
4970644
commit 742c187
Showing
4 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
...uv/cacem/monitorenv/domain/use_cases/departmentArea/GetDepartmentAreaByInseeCodeUTests.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,32 @@ | ||
package fr.gouv.cacem.monitorenv.domain.use_cases.departmentArea | ||
|
||
import com.nhaarman.mockitokotlin2.given | ||
import fr.gouv.cacem.monitorenv.domain.entities.departmentArea.DepartmentAreaEntity | ||
import fr.gouv.cacem.monitorenv.domain.repositories.IDepartmentAreaRepository | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.springframework.boot.test.mock.mockito.MockBean | ||
import org.springframework.test.context.junit.jupiter.SpringExtension | ||
|
||
@ExtendWith(SpringExtension::class) | ||
class GetDepartmentAreaByInseeCodeUTests { | ||
@MockBean | ||
private lateinit var departmentAreaRepository: IDepartmentAreaRepository | ||
|
||
@Test | ||
fun `execute should return a department area by its INSEE Code`() { | ||
val departmentAreaId = "1" | ||
val departmentArea = DepartmentAreaEntity( | ||
inseeCode = "1", | ||
geometry = null, | ||
name = "Department Area Name", | ||
) | ||
|
||
given(departmentAreaRepository.findByInseeCode(departmentAreaId)).willReturn(departmentArea) | ||
|
||
val result = GetDepartmentAreaByInseeCode(departmentAreaRepository).execute(departmentAreaId) | ||
|
||
assertThat(result).isEqualTo(departmentArea) | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...tlin/fr/gouv/cacem/monitorenv/domain/use_cases/departmentArea/GetDepartmentAreasUTests.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,39 @@ | ||
package fr.gouv.cacem.monitorenv.domain.use_cases.departmentArea | ||
|
||
import com.nhaarman.mockitokotlin2.given | ||
import fr.gouv.cacem.monitorenv.domain.entities.departmentArea.DepartmentAreaEntity | ||
import fr.gouv.cacem.monitorenv.domain.repositories.IDepartmentAreaRepository | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.springframework.boot.test.mock.mockito.MockBean | ||
import org.springframework.test.context.junit.jupiter.SpringExtension | ||
|
||
@ExtendWith(SpringExtension::class) | ||
class GetDepartmentAreasUTests { | ||
@MockBean | ||
private lateinit var departmentAreaRepository: IDepartmentAreaRepository | ||
|
||
@Test | ||
fun `execute should return all department areas`() { | ||
val departmentAreas = listOf( | ||
DepartmentAreaEntity( | ||
inseeCode = "1", | ||
geometry = null, | ||
name = "DepartmentArea Name", | ||
), | ||
DepartmentAreaEntity( | ||
inseeCode = "2", | ||
geometry = null, | ||
name = "DepartmentArea Name 2", | ||
), | ||
) | ||
|
||
given(departmentAreaRepository.findAll()).willReturn(departmentAreas) | ||
|
||
val result = GetDepartmentAreas(departmentAreaRepository).execute() | ||
|
||
assertThat(result.size).isEqualTo(2) | ||
assertThat(result).isEqualTo(departmentAreas) | ||
} | ||
} |