diff --git a/src/main/java/com/rte_france/antares/datamanager_back/controller/TrajectoryController.java b/src/main/java/com/rte_france/antares/datamanager_back/controller/TrajectoryController.java index 160b222..ff11c0e 100644 --- a/src/main/java/com/rte_france/antares/datamanager_back/controller/TrajectoryController.java +++ b/src/main/java/com/rte_france/antares/datamanager_back/controller/TrajectoryController.java @@ -64,4 +64,10 @@ public ResponseEntity uploadTrajectory(@RequestParam("trajectoryT throws IOException { return new ResponseEntity<>(toTrajectoryDTO(trajectoryService.processTrajectory(trajectoryType, trajectoryToUse, horizon)), HttpStatus.CREATED); } + + @GetMapping + public List getTrajectoriesByStudyIdAndType(@RequestParam("studyIds") List trajectoryIds, + @RequestParam("trajectoryType") String trajectoryType) { + return trajectoryService.findTrajectoriesByTypeAndIds(trajectoryType, trajectoryIds); + } } diff --git a/src/main/java/com/rte_france/antares/datamanager_back/dto/TrajectoryDTO.java b/src/main/java/com/rte_france/antares/datamanager_back/dto/TrajectoryDTO.java index 570d658..7ad3b1a 100644 --- a/src/main/java/com/rte_france/antares/datamanager_back/dto/TrajectoryDTO.java +++ b/src/main/java/com/rte_france/antares/datamanager_back/dto/TrajectoryDTO.java @@ -7,7 +7,6 @@ import lombok.NoArgsConstructor; import java.time.LocalDateTime; -import java.util.List; @Data @Builder(toBuilder = true) @@ -33,7 +32,4 @@ public class TrajectoryDTO { @JsonProperty("creation_date") LocalDateTime creationDate; - List tags; - - String projet; } diff --git a/src/main/java/com/rte_france/antares/datamanager_back/repository/TrajectoryRepository.java b/src/main/java/com/rte_france/antares/datamanager_back/repository/TrajectoryRepository.java index f083756..e57ef4f 100644 --- a/src/main/java/com/rte_france/antares/datamanager_back/repository/TrajectoryRepository.java +++ b/src/main/java/com/rte_france/antares/datamanager_back/repository/TrajectoryRepository.java @@ -22,5 +22,7 @@ public interface TrajectoryRepository extends JpaRepository findTrajectoriesFileNameByTypeAAndHorizonAndFileNameStartsWith(@Param("type") String type,@Param("horizon") String horizon, @Param("fileNameStartsWith") String fileNameStartsWith); + List findByTypeAndIdIn(String trajectoryType, List trajectoryIds); + } diff --git a/src/main/java/com/rte_france/antares/datamanager_back/service/TrajectoryService.java b/src/main/java/com/rte_france/antares/datamanager_back/service/TrajectoryService.java index 7f3f1f0..9df758c 100644 --- a/src/main/java/com/rte_france/antares/datamanager_back/service/TrajectoryService.java +++ b/src/main/java/com/rte_france/antares/datamanager_back/service/TrajectoryService.java @@ -1,5 +1,6 @@ package com.rte_france.antares.datamanager_back.service; +import com.rte_france.antares.datamanager_back.dto.TrajectoryDTO; import com.rte_france.antares.datamanager_back.dto.TrajectoryType; import com.rte_france.antares.datamanager_back.repository.model.TrajectoryEntity; @@ -14,5 +15,6 @@ public interface TrajectoryService { List findTrajectoriesByTypeAndFileNameStartWithFromFS(TrajectoryType trajectoryType); + List findTrajectoriesByTypeAndIds(String trajectoryType, List trajectoryIds); } diff --git a/src/main/java/com/rte_france/antares/datamanager_back/service/impl/TrajectoryServiceImpl.java b/src/main/java/com/rte_france/antares/datamanager_back/service/impl/TrajectoryServiceImpl.java index 0633917..a869e48 100644 --- a/src/main/java/com/rte_france/antares/datamanager_back/service/impl/TrajectoryServiceImpl.java +++ b/src/main/java/com/rte_france/antares/datamanager_back/service/impl/TrajectoryServiceImpl.java @@ -1,7 +1,9 @@ package com.rte_france.antares.datamanager_back.service.impl; import com.rte_france.antares.datamanager_back.configuration.AntaressDataManagerProperties; +import com.rte_france.antares.datamanager_back.dto.TrajectoryDTO; import com.rte_france.antares.datamanager_back.dto.TrajectoryType; +import com.rte_france.antares.datamanager_back.mapper.TrajectoryMapper; import com.rte_france.antares.datamanager_back.repository.TrajectoryRepository; import com.rte_france.antares.datamanager_back.repository.model.TrajectoryEntity; import com.rte_france.antares.datamanager_back.service.AreaFileProcessorService; @@ -19,6 +21,8 @@ import java.util.List; import java.util.Objects; +import static com.rte_france.antares.datamanager_back.mapper.TrajectoryMapper.toTrajectoryDTO; + @Slf4j @Service @@ -83,5 +87,11 @@ public List findTrajectoriesByTypeAndFileNameStartWithFromFS(TrajectoryT return Collections.emptyList(); } + @Override + public List findTrajectoriesByTypeAndIds(String trajectoryType, List trajectoryIds) { + return trajectoryRepository.findByTypeAndIdIn(trajectoryType, trajectoryIds).stream() + .map(TrajectoryMapper::toTrajectoryDTO) + .toList(); + } } diff --git a/src/test/java/com/rte_france/antares/datamanager_back/controller/TrajectoryControllerTest.java b/src/test/java/com/rte_france/antares/datamanager_back/controller/TrajectoryControllerTest.java index 7275f1c..2da9d68 100644 --- a/src/test/java/com/rte_france/antares/datamanager_back/controller/TrajectoryControllerTest.java +++ b/src/test/java/com/rte_france/antares/datamanager_back/controller/TrajectoryControllerTest.java @@ -1,8 +1,9 @@ package com.rte_france.antares.datamanager_back.controller; -import com.rte_france.antares.datamanager_back.service.impl.SftpDownloadService; +import com.rte_france.antares.datamanager_back.dto.TrajectoryDTO; import com.rte_france.antares.datamanager_back.repository.model.TrajectoryEntity; +import com.rte_france.antares.datamanager_back.service.impl.SftpDownloadService; import com.rte_france.antares.datamanager_back.service.impl.TrajectoryServiceImpl; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -23,11 +24,12 @@ import static org.mockito.Mockito.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) - class TrajectoryControllerTest { +class TrajectoryControllerTest { @Autowired protected WebApplicationContext wac; @@ -49,7 +51,7 @@ public void setup() { @Test void uploadTrajectory_returnsCreatedTrajectory() throws Exception { - when(trajectoryServiceImpl.processTrajectory(any(),any(), any())).thenReturn(TrajectoryEntity.builder().build()); + when(trajectoryServiceImpl.processTrajectory(any(), any(), any())).thenReturn(TrajectoryEntity.builder().build()); this.mockMvc.perform(post("/v1/trajectory") .contentType(MediaType.APPLICATION_JSON_VALUE) @@ -62,12 +64,12 @@ void uploadTrajectory_returnsCreatedTrajectory() throws Exception { .andExpect(status().isCreated()) .andDo(MockMvcResultHandlers.print()) .andReturn(); - verify(trajectoryServiceImpl, times(1)).processTrajectory(any(), any(),any()); + verify(trajectoryServiceImpl, times(1)).processTrajectory(any(), any(), any()); } @Test void findTrajectoriesByTypeFromDb_returnsTrajectories() throws Exception { - when(trajectoryServiceImpl.findTrajectoriesByTypeAndFileNameStartWithFromDB(any(),any(),any())).thenReturn(List.of(TrajectoryEntity.builder().build())); + when(trajectoryServiceImpl.findTrajectoriesByTypeAndFileNameStartWithFromDB(any(), any(), any())).thenReturn(List.of(TrajectoryEntity.builder().build())); this.mockMvc.perform(get("/v1/trajectory/db") .contentType(MediaType.APPLICATION_JSON_VALUE) @@ -80,7 +82,7 @@ void findTrajectoriesByTypeFromDb_returnsTrajectories() throws Exception { .andExpect(status().isOk()) .andDo(MockMvcResultHandlers.print()) .andReturn(); - verify(trajectoryServiceImpl, times(1)).findTrajectoriesByTypeAndFileNameStartWithFromDB(any(), any(),any()); + verify(trajectoryServiceImpl, times(1)).findTrajectoriesByTypeAndFileNameStartWithFromDB(any(), any(), any()); } @Test @@ -99,4 +101,52 @@ void findTrajectoriesByTypeFromFileSystem_returnsFileNames() throws Exception { verify(sftpDownloadService, times(1)).listFsTrajectoryByType(any(), any()); } + @Test + void getTrajectoriesByStudyIdAndType_returnsEmptyListForNonExistentType() throws Exception { + when(trajectoryServiceImpl.findTrajectoriesByTypeAndIds("nonExistentType", List.of(1, 2, 3))).thenReturn(List.of()); + this.mockMvc.perform(get("/v1/trajectory") + .param("trajectoryType", "nonExistentType") + .param("studyIds", "1,2,3") + .accept(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$").isEmpty()); + } + + @Test + void getTrajectoriesByStudyIdAndType_returnsEmptyListForNonExistentIds() throws Exception { + when(trajectoryServiceImpl.findTrajectoriesByTypeAndIds("AREA", List.of(999, 1000))).thenReturn(List.of()); + this.mockMvc.perform(get("/v1/trajectory") + .param("trajectoryType", "AREA") + .param("studyIds", "999,1000") + .accept(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$").isEmpty()); + } + + @Test + void getTrajectoriesByStudyIdAndType_returnsNonEmptyListForExistentTypeAndIds() throws Exception { + TrajectoryDTO dto = new TrajectoryDTO(); + dto.setType("AREA"); + dto.setId(1); + when(trajectoryServiceImpl.findTrajectoriesByTypeAndIds("AREA", List.of(1, 2))).thenReturn(List.of(dto)); + this.mockMvc.perform(get("/v1/trajectory") + .param("trajectoryType", "AREA") + .param("studyIds", "1,2") + .accept(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$").isNotEmpty()) + .andExpect(jsonPath("$[0].type").value("AREA")) + .andExpect(jsonPath("$[0].id").value(1)); + } + + @Test + void getTrajectoriesByStudyIdAndType_returnsEmptyListForEmptyIds() throws Exception { + when(trajectoryServiceImpl.findTrajectoriesByTypeAndIds("AREA", List.of())).thenReturn(List.of()); + this.mockMvc.perform(get("/v1/trajectory") + .param("trajectoryType", "AREA") + .param("studyIds", "") + .accept(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$").isEmpty()); + } } diff --git a/src/test/java/com/rte_france/antares/datamanager_back/repository/TrajectoryRepositoryTest.java b/src/test/java/com/rte_france/antares/datamanager_back/repository/TrajectoryRepositoryTest.java index 6ad452b..11aa939 100644 --- a/src/test/java/com/rte_france/antares/datamanager_back/repository/TrajectoryRepositoryTest.java +++ b/src/test/java/com/rte_france/antares/datamanager_back/repository/TrajectoryRepositoryTest.java @@ -44,26 +44,58 @@ void findFirstByFileNameOrderByVersionDesc_returnsEmptyOptionalForNonExistentFil @Test void findTrajectoriesByTypeAndFileNameStartsWith_returnsEmptyListForNonExistentType() { - List trajectoryEntities = trajectoryRepository.findTrajectoriesFileNameByTypeAAndHorizonAndFileNameStartsWith("nonExistentType", "2023-2024","test"); + List trajectoryEntities = trajectoryRepository.findTrajectoriesFileNameByTypeAAndHorizonAndFileNameStartsWith("nonExistentType", "2023-2024", "test"); assertThat(trajectoryEntities).isEmpty(); } @Test void findTrajectoriesByTypeAndFileNameStartsWith_returnsEmptyListForNonExistentFileNameStartsWith() { - List trajectoryEntities = trajectoryRepository.findTrajectoriesFileNameByTypeAAndHorizonAndFileNameStartsWith("AREA", "2023-2024","nonExistentStart"); + List trajectoryEntities = trajectoryRepository.findTrajectoriesFileNameByTypeAAndHorizonAndFileNameStartsWith("AREA", "2023-2024", "nonExistentStart"); assertThat(trajectoryEntities).isEmpty(); } @Test void findTrajectoriesByTypeAndFileNameStartsWith_returnsNonEmptyListForExistentTypeAndFileNameStartsWith() { - List trajectoryEntities = trajectoryRepository.findTrajectoriesFileNameByTypeAAndHorizonAndFileNameStartsWith("AREA","2023-2024", "test"); + List trajectoryEntities = trajectoryRepository.findTrajectoriesFileNameByTypeAAndHorizonAndFileNameStartsWith("AREA", "2023-2024", "test"); assertThat(trajectoryEntities).isNotEmpty(); assertThat(trajectoryEntities.get(0).getFileName()).startsWith("test"); } @Test void findTrajectoriesByTypeAndFileNameStartsWith_returnsEmptyListForNullType() { - List trajectoryEntities = trajectoryRepository.findTrajectoriesFileNameByTypeAAndHorizonAndFileNameStartsWith(null, "2023-2024","test"); + List trajectoryEntities = trajectoryRepository.findTrajectoriesFileNameByTypeAAndHorizonAndFileNameStartsWith(null, "2023-2024", "test"); + assertThat(trajectoryEntities).isEmpty(); + } + + @Test + void findByTypeAndIdIn_returnsEmptyListForNonExistentType() { + List trajectoryEntities = trajectoryRepository.findByTypeAndIdIn("nonExistentType", List.of(1, 2, 3)); + assertThat(trajectoryEntities).isEmpty(); + } + + @Test + void findByTypeAndIdIn_returnsEmptyListForNonExistentIds() { + List trajectoryEntities = trajectoryRepository.findByTypeAndIdIn("AREA", List.of(999, 1000)); + assertThat(trajectoryEntities).isEmpty(); + } + + @Test + void findByTypeAndIdIn_returnsNonEmptyListForExistentTypeAndIds() { + List trajectoryEntities = trajectoryRepository.findByTypeAndIdIn("AREA", List.of(1, 2)); + assertThat(trajectoryEntities).isNotEmpty(); + assertThat(trajectoryEntities.get(0).getType()).isEqualTo("AREA"); + assertThat(trajectoryEntities.get(0).getId()).isIn(1, 2); + } + + @Test + void findByTypeAndIdIn_returnsEmptyListForNullType() { + List trajectoryEntities = trajectoryRepository.findByTypeAndIdIn(null, List.of(1, 2, 3)); + assertThat(trajectoryEntities).isEmpty(); + } + + @Test + void findByTypeAndIdIn_returnsEmptyListForEmptyIds() { + List trajectoryEntities = trajectoryRepository.findByTypeAndIdIn("AREA", List.of()); assertThat(trajectoryEntities).isEmpty(); } diff --git a/src/test/java/com/rte_france/antares/datamanager_back/service/TrajectoryServiceImplTest.java b/src/test/java/com/rte_france/antares/datamanager_back/service/TrajectoryServiceImplTest.java index 56e813e..7e12ed6 100644 --- a/src/test/java/com/rte_france/antares/datamanager_back/service/TrajectoryServiceImplTest.java +++ b/src/test/java/com/rte_france/antares/datamanager_back/service/TrajectoryServiceImplTest.java @@ -1,10 +1,11 @@ package com.rte_france.antares.datamanager_back.service; import com.rte_france.antares.datamanager_back.configuration.AntaressDataManagerProperties; -import com.rte_france.antares.datamanager_back.service.impl.SftpDownloadService; +import com.rte_france.antares.datamanager_back.dto.TrajectoryDTO; import com.rte_france.antares.datamanager_back.dto.TrajectoryType; import com.rte_france.antares.datamanager_back.repository.TrajectoryRepository; import com.rte_france.antares.datamanager_back.repository.model.TrajectoryEntity; +import com.rte_france.antares.datamanager_back.service.impl.SftpDownloadService; import com.rte_france.antares.datamanager_back.service.impl.TrajectoryServiceImpl; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,12 +17,12 @@ import java.io.File; import java.io.IOException; import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; -import static org.mockito.Mockito.times; class TrajectoryServiceImplTest { @@ -55,9 +56,9 @@ void processTrajectory_returnsEntityWhenTrajectoryTYpeIsAREA() throws IOExceptio Mockito.when(file.getPath()).thenReturn("src/test/resources/area/testFile.xlsx"); when(antaressDataManagerProperties.getTrajectoryFilePath()).thenReturn("src/test/resources/"); - trajectoryService.processTrajectory(TrajectoryType.AREA, "testFile","2023-2024"); + trajectoryService.processTrajectory(TrajectoryType.AREA, "testFile", "2023-2024"); - verify(areaFileProcessorService, times(1)).processAreaFile(any(),any()); + verify(areaFileProcessorService, times(1)).processAreaFile(any(), any()); } @Test @@ -66,9 +67,9 @@ void processTrajectory_returnsEntityWhenTrajectoryTypeIsLINK() throws IOExceptio Mockito.when(file.getPath()).thenReturn("src/test/resources/link/links_BP23_A_ref.xlsx"); when(antaressDataManagerProperties.getTrajectoryFilePath()).thenReturn("src/test/resources/"); - trajectoryService.processTrajectory(TrajectoryType.LINK, "links_BP23_A_ref","2023-2024"); + trajectoryService.processTrajectory(TrajectoryType.LINK, "links_BP23_A_ref", "2023-2024"); - verify(linkFileProcessorService, times(1)).processLinkFile(any(),any()); + verify(linkFileProcessorService, times(1)).processLinkFile(any(), any()); } @Test @@ -77,17 +78,17 @@ void processTrajectory_returnsEntityWhenTrajectoryTypeIsThermalCapacity() throws Mockito.when(file.getPath()).thenReturn("src/test/resources/thermal_capacity/thermal_BE_PEMMDB23_26avril.xlsx"); when(antaressDataManagerProperties.getTrajectoryFilePath()).thenReturn("src/test/resources/"); - trajectoryService.processTrajectory(TrajectoryType.THERMAL_CAPACITY, "thermal_BE_PEMMDB23_26avril","2023-2024"); + trajectoryService.processTrajectory(TrajectoryType.THERMAL_CAPACITY, "thermal_BE_PEMMDB23_26avril", "2023-2024"); - verify(thermalFileProcessorService, times(1)).processThermalCapacityFile(any(),any()); + verify(thermalFileProcessorService, times(1)).processThermalCapacityFile(any(), any()); } @Test void findTrajectoriesByTypeAndFileNameStartWithFromDB_returnsEntitiesWhenExist() { List expectedEntities = List.of(new TrajectoryEntity()); - when(trajectoryRepository.findTrajectoriesFileNameByTypeAAndHorizonAndFileNameStartsWith(TrajectoryType.AREA.name(), "2023-2024","fileNameStartsWith")).thenReturn(expectedEntities); + when(trajectoryRepository.findTrajectoriesFileNameByTypeAAndHorizonAndFileNameStartsWith(TrajectoryType.AREA.name(), "2023-2024", "fileNameStartsWith")).thenReturn(expectedEntities); - List result = trajectoryService.findTrajectoriesByTypeAndFileNameStartWithFromDB(TrajectoryType.AREA, "2023-2024","fileNameStartsWith"); + List result = trajectoryService.findTrajectoriesByTypeAndFileNameStartWithFromDB(TrajectoryType.AREA, "2023-2024", "fileNameStartsWith"); assertEquals(expectedEntities, result); } @@ -96,25 +97,63 @@ void findTrajectoriesByTypeAndFileNameStartWithFromDB_returnsEntitiesWhenExist() void findTrajectoriesByTypeAndFileNameStartWithFromDB_returnsEmptyWhenDoNotExist() { when(trajectoryRepository.findTrajectoriesFileNameByTypeAAndHorizonAndFileNameStartsWith(TrajectoryType.AREA.name(), "2023-2024", "nonExistentFileNameStartsWith")).thenReturn(List.of()); - List result = trajectoryService.findTrajectoriesByTypeAndFileNameStartWithFromDB(TrajectoryType.AREA,"2023-2024", "nonExistentFileNameStartsWith"); + List result = trajectoryService.findTrajectoriesByTypeAndFileNameStartWithFromDB(TrajectoryType.AREA, "2023-2024", "nonExistentFileNameStartsWith"); assertEquals(List.of(), result); } - @Test - void findTrajectoriesByTypeAndFileNameStartWithFromFS_returnsFileNamesWhenDirectoryExists() { - when(antaressDataManagerProperties.getTrajectoryFilePath()).thenReturn("src/test/resources/"); + @Test + void findTrajectoriesByTypeAndFileNameStartWithFromFS_returnsFileNamesWhenDirectoryExists() { + when(antaressDataManagerProperties.getTrajectoryFilePath()).thenReturn("src/test/resources/"); + + List result = trajectoryService.findTrajectoriesByTypeAndFileNameStartWithFromFS(TrajectoryType.AREA); + + assertEquals(List.of("testFile.xlsx"), result); + } + + @Test + void findTrajectoriesByTypeAndFileNameStartWithFromFS_throwsExceptionWhenDirectoryDoesNotExist() { + when(antaressDataManagerProperties.getTrajectoryFilePath()).thenReturn("src/test/"); + assertThrows(IllegalArgumentException.class, () -> trajectoryService.findTrajectoriesByTypeAndFileNameStartWithFromFS(TrajectoryType.AREA)); + } - List result = trajectoryService.findTrajectoriesByTypeAndFileNameStartWithFromFS(TrajectoryType.AREA); + @Test + void findTrajectoriesByTypeAndIds_returnsEmptyListForNonExistentType() { + when(trajectoryRepository.findByTypeAndIdIn("nonExistentType", List.of(1, 2, 3))).thenReturn(List.of()); + List result = trajectoryService.findTrajectoriesByTypeAndIds("nonExistentType", List.of(1, 2, 3)); + assertThat(result).isEmpty(); + } - assertEquals(List.of("testFile.xlsx"), result); - } + @Test + void findTrajectoriesByTypeAndIds_returnsEmptyListForNonExistentIds() { + when(trajectoryRepository.findByTypeAndIdIn("AREA", List.of(999, 1000))).thenReturn(List.of()); + List result = trajectoryService.findTrajectoriesByTypeAndIds("AREA", List.of(999, 1000)); + assertThat(result).isEmpty(); + } - @Test - void findTrajectoriesByTypeAndFileNameStartWithFromFS_throwsExceptionWhenDirectoryDoesNotExist() { - when(antaressDataManagerProperties.getTrajectoryFilePath()).thenReturn("src/test/"); + @Test + void findTrajectoriesByTypeAndIds_returnsNonEmptyListForExistentTypeAndIds() { + TrajectoryEntity entity = new TrajectoryEntity(); + entity.setType("AREA"); + entity.setId(1); + when(trajectoryRepository.findByTypeAndIdIn("AREA", List.of(1, 2))).thenReturn(List.of(entity)); + List result = trajectoryService.findTrajectoriesByTypeAndIds("AREA", List.of(1, 2)); + assertThat(result).isNotEmpty(); + assertThat(result.get(0).getType()).isEqualTo("AREA"); + assertThat(result.get(0).getId()).isEqualTo(1); + } + @Test + void findTrajectoriesByTypeAndIds_returnsEmptyListForNullType() { + when(trajectoryRepository.findByTypeAndIdIn(null, List.of(1, 2, 3))).thenReturn(List.of()); + List result = trajectoryService.findTrajectoriesByTypeAndIds(null, List.of(1, 2, 3)); + assertThat(result).isEmpty(); + } - assertThrows(IllegalArgumentException.class, () -> trajectoryService.findTrajectoriesByTypeAndFileNameStartWithFromFS(TrajectoryType.AREA)); - } + @Test + void findTrajectoriesByTypeAndIds_returnsEmptyListForEmptyIds() { + when(trajectoryRepository.findByTypeAndIdIn("AREA", List.of())).thenReturn(List.of()); + List result = trajectoryService.findTrajectoriesByTypeAndIds("AREA", List.of()); + assertThat(result).isEmpty(); + } } \ No newline at end of file