Skip to content

Commit

Permalink
Add missing department area use cases tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangabriele committed Oct 30, 2023
1 parent 4970644 commit 742c187
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GetAdministrationsUTests {

val result = GetAdministrations(administrationRepository).execute()

assertThat(result.size).isEqualTo(1)
assertThat(result.size).isEqualTo(2)
assertThat(result).isEqualTo(fullAdministrations)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class GetBasesUTests {

val result = GetBases(baseRepository).execute()

assertThat(result.size).isEqualTo(1)
assertThat(result.size).isEqualTo(2)
assertThat(result).isEqualTo(bases)
}
}
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)
}
}
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)
}
}

0 comments on commit 742c187

Please sign in to comment.