66 */
77package com .powsybl .caseserver .service ;
88
9- import com .fasterxml .jackson .core .type .TypeReference ;
109import com .fasterxml .jackson .databind .ObjectMapper ;
1110import com .google .common .io .ByteStreams ;
1211import com .powsybl .caseserver .ContextConfigurationWithTestChannel ;
5756@ SpringBootTest (webEnvironment = SpringBootTest .WebEnvironment .MOCK )
5857@ ContextConfigurationWithTestChannel
5958abstract class AbstractCaseControllerTest {
60- private static final String TEST_CASE = "testCase.xiidm" ;
59+ public static final String TEST_CASE = "testCase.xiidm" ;
6160 private static final String TEST_TAR_CASE = "tarCase.tar" ;
6261 private static final String TEST_CASE_FORMAT = "XIIDM" ;
6362 private static final String NOT_A_NETWORK = "notANetwork.txt" ;
@@ -80,11 +79,11 @@ abstract class AbstractCaseControllerTest {
8079 OutputDestination outputDestination ;
8180
8281 @ Autowired
83- private ObjectMapper mapper ;
82+ public ObjectMapper mapper ;
8483
8584 FileSystem fileSystem ;
8685
87- private final String caseImportDestination = "case.import.destination" ;
86+ public final String caseImportDestination = "case.import.destination" ;
8887
8988 @ AfterEach
9089 public void tearDown () throws Exception {
@@ -93,7 +92,7 @@ public void tearDown() throws Exception {
9392 TestUtils .assertQueuesEmptyThenClear (destinations , outputDestination );
9493 }
9594
96- private void createStorageDir () throws IOException {
95+ void createStorageDir () throws IOException {
9796 Path path = fileSystem .getPath (caseService .getRootDirectory ());
9897 if (!Files .exists (path )) {
9998 Files .createDirectories (path );
@@ -467,7 +466,7 @@ void testDuplicateNonIndexedCase() throws Exception {
467466 assertFalse (caseMetadataRepository .findById (duplicateCaseUuid ).get ().isIndexed ());
468467 }
469468
470- private UUID importCase (String testCase , Boolean withExpiration ) throws Exception {
469+ UUID importCase (String testCase , Boolean withExpiration ) throws Exception {
471470 String importedCase ;
472471 if (withExpiration ) {
473472 importedCase = mvc .perform (multipart ("/v1/cases" )
@@ -721,35 +720,6 @@ private static String getDateSearchTerm(String entsoeFormatDate) {
721720 return "date:\" " + utcFormattedDate + "\" " ;
722721 }
723722
724- @ Test
725- void invalidFileInCaseDirectoryShouldBeIgnored () throws Exception {
726- createStorageDir ();
727-
728- // add a random file in the storage, not stored in a UUID named directory
729- Path filePath = fileSystem .getPath (caseService .getRootDirectory ()).resolve ("randomFile.txt" );
730- Files .createFile (filePath );
731-
732- // add a case file in a UUID named directory but no metadata in the database
733- Path casePath = fileSystem .getPath (caseService .getRootDirectory ()).resolve (UUID .randomUUID ().toString ());
734- Files .createDirectory (casePath );
735- Files .createFile (casePath .resolve (TEST_CASE ));
736-
737- importCase (TEST_CASE , false );
738-
739- MvcResult mvcResult = mvc .perform (get ("/v1/cases" ))
740- .andExpect (status ().isOk ())
741- .andReturn ();
742- String resultAsString = mvcResult .getResponse ().getContentAsString ();
743- List <CaseInfos > caseInfos = mapper .readValue (resultAsString , new TypeReference <>() { });
744- assertEquals (1 , caseInfos .size ());
745- assertEquals (TEST_CASE , caseInfos .get (0 ).getName ());
746-
747- Files .delete (filePath );
748- mvc .perform (delete ("/v1/cases" ))
749- .andExpect (status ().isOk ());
750- assertNotNull (outputDestination .receive (1000 , caseImportDestination ));
751- }
752-
753723 @ Test
754724 void testGetCaseBaseName () throws Exception {
755725 MvcResult mvcResult = mvc .perform (get ("/v1/cases/caseBaseName?caseName=case.xml" ))
0 commit comments