-
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.
Add isMeshRequiredForSegment property to gears referential api endpoint
- Loading branch information
1 parent
bf2dcc0
commit a17c229
Showing
10 changed files
with
138 additions
and
9 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
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
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
66 changes: 66 additions & 0 deletions
66
backend/src/test/kotlin/fr/gouv/cnsp/monitorfish/domain/use_cases/gear/GetAllGearsUTests.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,66 @@ | ||
package fr.gouv.cnsp.monitorfish.domain.use_cases.gear | ||
|
||
import com.nhaarman.mockitokotlin2.any | ||
import com.nhaarman.mockitokotlin2.eq | ||
import com.nhaarman.mockitokotlin2.given | ||
import fr.gouv.cnsp.monitorfish.domain.entities.gear.Gear | ||
import fr.gouv.cnsp.monitorfish.domain.entities.gear.GearCodeGroup | ||
import fr.gouv.cnsp.monitorfish.domain.exceptions.CodeNotFoundException | ||
import fr.gouv.cnsp.monitorfish.domain.repositories.FleetSegmentRepository | ||
import fr.gouv.cnsp.monitorfish.domain.repositories.GearCodeGroupRepository | ||
import fr.gouv.cnsp.monitorfish.domain.repositories.GearRepository | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.springframework.boot.test.mock.mockito.MockBean | ||
import org.springframework.test.context.junit.jupiter.SpringExtension | ||
import java.time.Clock | ||
|
||
@ExtendWith(SpringExtension::class) | ||
class GetAllGearsUTests { | ||
@MockBean | ||
private lateinit var gearRepository: GearRepository | ||
|
||
@MockBean | ||
private lateinit var fleetSegmentRepository: FleetSegmentRepository | ||
|
||
@MockBean | ||
private lateinit var gearCodeGroupRepository: GearCodeGroupRepository | ||
|
||
companion object { | ||
val fixedClock: Clock = Clock.systemUTC() | ||
} | ||
|
||
@Test | ||
fun `execute Should return gears augmented with other properties`() { | ||
// Given | ||
given(fleetSegmentRepository.findAllSegmentsGearsWithRequiredMesh(any())).willReturn( | ||
listOf("PTM", "GTN", "PTB", "GNF", "TBB", "TBS", "OTB", "TB", "SDN", "TM", "SSC", "OTM"), | ||
) | ||
given(gearRepository.findAll()).willReturn( | ||
listOf( | ||
Gear("OTB", "Chaluts de fond à panneaux"), | ||
Gear("DRB", "Dragues remorquées par bateau"), | ||
), | ||
) | ||
given(gearCodeGroupRepository.find(eq("OTB"))).willReturn( | ||
GearCodeGroup( | ||
code = "OTB", | ||
groupId = 1, | ||
), | ||
) | ||
given(gearCodeGroupRepository.find(eq("DRB"))).willThrow(CodeNotFoundException("Code not found")) | ||
|
||
// When | ||
val gears = GetAllGears(gearRepository, fleetSegmentRepository, gearCodeGroupRepository, fixedClock).execute() | ||
|
||
// Then | ||
assertThat(gears).hasSize(2) | ||
assertThat(gears.first().code).isEqualTo("OTB") | ||
assertThat(gears.first().groupId).isEqualTo(1) | ||
assertThat(gears.first().isMeshRequiredForSegment).isTrue() | ||
assertThat(gears.last().code).isEqualTo("DRB") | ||
assertThat(gears.last().groupId).isNull() | ||
assertThat(gears.last().isMeshRequiredForSegment).isFalse() | ||
} | ||
} |
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