package pirateboat.info;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import pirateboat.torrent.Torrent;
import pirateboat.utilities.PropertiesHelper;

import java.util.List;
import java.util.Map;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;

class CloudServiceTest {

    private CloudService cloudService;

    @BeforeEach
    public void beforeMethod() {
        cloudService = new CloudService();
    }

    @EnabledIfEnvironmentVariable(named = "DISABLE_UPDATE_PROMPT",matches = "true")
    @Test
    void searchForFilesWithYear() {
        // Given
        // When
        List<String> files = cloudService.findExistingFiles("Test 1997");
        // Then
        assertTrue(files.size() > 0);
    }

    @EnabledIfEnvironmentVariable(named = "DISABLE_UPDATE_PROMPT",matches = "true")
    @Test
    void searchForFiles() {
        // Given
        // When
        List<String> files = cloudService.findExistingFiles("Test1");
        // Then
        assertTrue(files.size() > 0);
    }

    @Test
    void buildDestinationPathForSingleFileTorrentNoMatch() {
        // Given
        Torrent torrentToBeDownloaded = new Torrent("test");
        // When
        String destinationPath = cloudService.buildDestinationPath("Movie");
        // Then
        assertEquals(PropertiesHelper.getProperty("rclonedir") + "/transfer/M/", destinationPath);
    }

    @Test
    void buildDestinationPathForSingleFileTorrent() {
        // Given
        Torrent torrentToBeDownloaded = new Torrent("test");
        // When
        String destinationPath = cloudService.buildDestinationPath("Movie Title Xvid");
        // Then
        assertEquals(PropertiesHelper.getProperty("rclonedir") + "/Movies/M/", destinationPath);
    }

    @Test
    void buildDestinationPathForSingleFileTorrentExtended() {
        // Given
        Torrent torrentToBeDownloaded = new Torrent("test");
        // When
        String destinationPath = cloudService.buildDestinationPath("Movie Title 2008 2160p US BluRay REMUX HEVC DTS HD MA TrueHD 7 1 Atmos FGT");
        // Then
        assertEquals(PropertiesHelper.getProperty("rclonedir") + "/Movies/M/", destinationPath);
    }

    @Test
    void buildDestinationPathForSingleFileTorrentWithArticles() {
        // Given
        // When
        String destinationPath = cloudService.buildDestinationPath("A Movie Title 2008 2160p US BluRay REMUX HEVC DTS HD MA TrueHD 7 1 Atmos FGT");
        // Then
        assertEquals(PropertiesHelper.getProperty("rclonedir") + "/Movies/M/", destinationPath);
    }

    @Test
    void buildDestinationPathForMultiFileTorrentTest() {
        // Given
        // When
        String destinationPath = cloudService.buildDestinationPath("Test and Test [UNCENSORED] Season 1-3 [1080p] [5.1 MP3] [x265][FINAL]");
        // Then
        assertEquals(PropertiesHelper.getProperty("rclonedir") + "/Series-Shows/T/", destinationPath);
    }

    @Test
    void buildDestinationPathForSeriesTorrentTest() {
        // Given
        // When
        String destinationPath = cloudService.buildDestinationPath("Series.S01E02.480p.x264-mSD[tag].mkv");
        // Then
        assertEquals(PropertiesHelper.getProperty("rclonedir") + "/Series-Shows/S/", destinationPath);
    }

    @Test
    void buildDestinationPathForSeriesLowerCaseTorrentTest() {
        // Given
        // When
        String destinationPath = cloudService.buildDestinationPath("series.S01E02.480p.x264-mSD[tag].mkv");
        // Then
        assertEquals(PropertiesHelper.getProperty("rclonedir") + "/Series-Shows/S/", destinationPath);
    }

    @Test
    void buildDestinationPathWithQuoteTest() {
        // Given
        // When
        String destinationPath = cloudService.buildDestinationPath("\"series.S01E02.480p.x264-mSD[tag].mkv");
        // Then
        assertEquals(PropertiesHelper.getProperty("rclonedir") + "/Series-Shows/S/", destinationPath);
    }

    @Test
    void buildDestinationPathWithPDFTest() {
        // Given
        // When
        String destinationPath = cloudService.buildDestinationPath("series.S01E02.480p.x264-mSD[tag].pdf");
        // Then
        assertEquals(PropertiesHelper.getProperty("rclonedir") + "/transfer/S/", destinationPath);
    }

}
@@ -93,104 +93,12 @@
 api.
-Disabled;%0Aimport org.junit.jupiter.api.Test;%0Aimport org.junit.jupiter.api.condition.DisabledOnOs
+Test
 ;%0Aim
@@ -273,73 +273,8 @@
 st;%0A
-import java.util.Map;%0A%0Aimport static org.junit.Assert.assertTrue;
 %0Aimp
@@ -330,16 +330,75 @@
 tEquals;
+%0Aimport static org.junit.jupiter.api.Assertions.assertTrue;
 %0A%0Aclass 

fix test asserts