<commit_before>
package jp.mironal.java.aws.app.glacier.cmd;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import jp.mironal.java.aws.app.glacier.AwsTools.Region;
import jp.mironal.java.aws.app.glacier.cmd.ArchiveControllerCmd.ArchiveCmdKind;

import org.junit.Test;

public class ArchiveControllerCmdTest {

    @Test
    public void test_Upload() {
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--vault", "hogehoge", "--file", "filename"
        });
        assertEquals(cmd.cmdKind, ArchiveCmdKind.Upload);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.filename, "filename");
        assertTrue(cmd.validateParam());
    }

    @Test
    public void test_Upload_InvalidParam() {
        // vault無し.
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--file", "filename"
        });
        assertEquals(cmd.cmdKind, ArchiveCmdKind.Upload);
        assertEquals(cmd.vaultName, null);
        assertEquals(cmd.filename, "filename");
        assertFalse(cmd.validateParam());

        // file無し
        cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--vault", "hogehoge",
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Upload);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.filename, null);
        assertFalse(cmd.validateParam());
    }

    @Test
    public void test_Download() {
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "download", "--vault", "hugahuga", "--archive", "archiveId", "--file", "savefile"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Download);
        assertEquals(cmd.vaultName, "hugahuga");
        assertEquals(cmd.archiveId, "archiveId");
        assertEquals(cmd.filename, "savefile");
        assertTrue(cmd.validateParam());
    }

    @Test
    public void test_Download_InvalidParam() {

        // vault無し
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "download", "--archive", "archiveId", "--file", "savefile"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Download);
        assertEquals(cmd.vaultName, null);
        assertEquals(cmd.archiveId, "archiveId");
        assertEquals(cmd.filename, "savefile");
        assertFalse(cmd.validateParam());

        // archive無し
        cmd = new ArchiveControllerCmd(new String[] {
                "download", "--vault", "hugahuga", "--file", "savefile"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Download);
        assertEquals(cmd.vaultName, "hugahuga");
        assertEquals(cmd.archiveId, null);
        assertEquals(cmd.filename, "savefile");
        assertFalse(cmd.validateParam());

        // file無し
        cmd = new ArchiveControllerCmd(new String[] {
                "download", "--vault", "hugahuga", "--archive", "archiveId"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Download);
        assertEquals(cmd.vaultName, "hugahuga");
        assertEquals(cmd.archiveId, "archiveId");
        assertEquals(cmd.filename, null);
        assertFalse(cmd.validateParam());
    }

    @Test
    public void test_Delete() {
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "delete", "--vault", "hogehoge", "--archive", "archiveId"
        });
        assertEquals(cmd.cmdKind, ArchiveCmdKind.Delete);
        assertEquals(cmd.archiveId, "archiveId");
        assertEquals(cmd.vaultName, "hogehoge");

        assertTrue(cmd.validateParam());
    }

    @Test
    public void test_Delete_InvalidParam() {
        // vault無し
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "delete", "--archive", "archiveId"
        });
        assertEquals(cmd.cmdKind, ArchiveCmdKind.Delete);
        assertEquals(cmd.vaultName, null);
        assertEquals(cmd.archiveId, "archiveId");
        assertFalse(cmd.validateParam());

        // archive無し
        cmd = new ArchiveControllerCmd(new String[] {
                "delete", "--vault", "hogehoge",
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Delete);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.archiveId, null);
        assertFalse(cmd.validateParam());

    }

    @Test
    public void test_Region() {
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--vault", "hogehoge", "--file", "filename", "--endpoint", "us-east-1"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Upload);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.filename, "filename");
        assertEquals(cmd.region, Region.US_EAST_1);

        cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--vault", "hogehoge", "--file", "filename", "--endpoint", "us-west-1"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Upload);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.filename, "filename");
        assertEquals(cmd.region, Region.US_WEST_1);

        cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--vault", "hogehoge", "--file", "filename", "--endpoint", "us-west-2"
        });

        try {
            assertEquals(cmd.region, Region.US_WEST_2);
        } catch (InvalidRegionException e) {
            fail();
            e.printStackTrace();
        }

        cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--vault", "hogehoge", "--file", "filename", "--endpoint", "eu-west-1"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Upload);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.filename, "filename");
        assertEquals(cmd.region, Region.EU_WEST_1);

        cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--vault", "hogehoge", "--file", "filename", "--endpoint",
                "ap-northeast-1"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Upload);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.filename, "filename");
        assertEquals(cmd.region, Region.AP_NORTHEAST_1);
        assertTrue(cmd.validateParam());
    }

    @Test()
    public void test_Region_Invalid() throws InvalidRegionException {
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "create", "--vault", "hogehoge", "--file", "filename", "--endpoint", "aa",
                "--debug"
        });
        assertNull(cmd.region);
        assertEquals(cmd.cmdKind, ArchiveCmdKind.Bad);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.filename, "filename");
        assertFalse(cmd.validateParam());
    }

    @Test
    public void test_Help() {
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
            "help"
        });
        assertEquals(cmd.cmdKind, ArchiveCmdKind.Help);
        assertNull(cmd.filename);
        assertNull(cmd.vaultName);<commit_msg>テスト修正<commit_after>
package jp.mironal.java.aws.app.glacier.cmd;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import jp.mironal.java.aws.app.glacier.AwsTools.Region;
import jp.mironal.java.aws.app.glacier.cmd.ArchiveControllerCmd.ArchiveCmdKind;

import org.junit.Test;

public class ArchiveControllerCmdTest {

    @Test
    public void test_Upload() {
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--vault", "hogehoge", "--file", "filename"
        });
        assertEquals(cmd.cmdKind, ArchiveCmdKind.Upload);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.filename, "filename");
        assertTrue(cmd.validateParam());
    }

    @Test
    public void test_Upload_InvalidParam() {
        // vault無し.
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--file", "filename"
        });
        assertEquals(cmd.cmdKind, ArchiveCmdKind.Upload);
        assertEquals(cmd.vaultName, null);
        assertEquals(cmd.filename, "filename");
        assertFalse(cmd.validateParam());

        // file無し
        cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--vault", "hogehoge",
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Upload);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.filename, null);
        assertFalse(cmd.validateParam());
    }

    @Test
    public void test_Download() {
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "download", "--vault", "hugahuga", "--archive", "archiveId", "--file", "savefile"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Download);
        assertEquals(cmd.vaultName, "hugahuga");
        assertEquals(cmd.archiveId, "archiveId");
        assertEquals(cmd.filename, "savefile");
        assertTrue(cmd.validateParam());
    }

    @Test
    public void test_Download_InvalidParam() {

        // vault無し
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "download", "--archive", "archiveId", "--file", "savefile"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Download);
        assertEquals(cmd.vaultName, null);
        assertEquals(cmd.archiveId, "archiveId");
        assertEquals(cmd.filename, "savefile");
        assertFalse(cmd.validateParam());

        // archive無し
        cmd = new ArchiveControllerCmd(new String[] {
                "download", "--vault", "hugahuga", "--file", "savefile"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Download);
        assertEquals(cmd.vaultName, "hugahuga");
        assertEquals(cmd.archiveId, null);
        assertEquals(cmd.filename, "savefile");
        assertFalse(cmd.validateParam());

        // file無し
        cmd = new ArchiveControllerCmd(new String[] {
                "download", "--vault", "hugahuga", "--archive", "archiveId"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Download);
        assertEquals(cmd.vaultName, "hugahuga");
        assertEquals(cmd.archiveId, "archiveId");
        assertEquals(cmd.filename, null);
        assertFalse(cmd.validateParam());
    }

    @Test
    public void test_Delete() {
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "delete", "--vault", "hogehoge", "--archive", "archiveId"
        });
        assertEquals(cmd.cmdKind, ArchiveCmdKind.Delete);
        assertEquals(cmd.archiveId, "archiveId");
        assertEquals(cmd.vaultName, "hogehoge");

        assertTrue(cmd.validateParam());
    }

    @Test
    public void test_Delete_InvalidParam() {
        // vault無し
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "delete", "--archive", "archiveId"
        });
        assertEquals(cmd.cmdKind, ArchiveCmdKind.Delete);
        assertEquals(cmd.vaultName, null);
        assertEquals(cmd.archiveId, "archiveId");
        assertFalse(cmd.validateParam());

        // archive無し
        cmd = new ArchiveControllerCmd(new String[] {
                "delete", "--vault", "hogehoge",
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Delete);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.archiveId, null);
        assertFalse(cmd.validateParam());

    }

    @Test
    public void test_Region() {
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--vault", "hogehoge", "--file", "filename", "--region", "us-east-1"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Upload);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.filename, "filename");
        assertEquals(cmd.region, Region.US_EAST_1);

        cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--vault", "hogehoge", "--file", "filename", "--region", "us-west-1"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Upload);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.filename, "filename");
        assertEquals(cmd.region, Region.US_WEST_1);

        cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--vault", "hogehoge", "--file", "filename", "--region", "us-west-2"
        });

        assertEquals(cmd.region, Region.US_WEST_2);

        cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--vault", "hogehoge", "--file", "filename", "--region", "eu-west-1"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Upload);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.filename, "filename");
        assertEquals(cmd.region, Region.EU_WEST_1);

        cmd = new ArchiveControllerCmd(new String[] {
                "upload", "--vault", "hogehoge", "--file", "filename", "--region", "ap-northeast-1"
        });

        assertEquals(cmd.cmdKind, ArchiveCmdKind.Upload);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.filename, "filename");
        assertEquals(cmd.region, Region.AP_NORTHEAST_1);
        assertTrue(cmd.validateParam());
    }

    @Test()
    public void test_Region_Invalid() throws InvalidRegionException {
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
                "create", "--vault", "hogehoge", "--file", "filename", "--region", "aa", "--debug"
        });
        assertNull(cmd.region);
        assertEquals(cmd.cmdKind, ArchiveCmdKind.Bad);
        assertEquals(cmd.vaultName, "hogehoge");
        assertEquals(cmd.filename, "filename");
        assertFalse(cmd.validateParam());
    }

    @Test
    public void test_Help() {
        ArchiveControllerCmd cmd = new ArchiveControllerCmd(new String[] {
            "help"
        });
        assertEquals(cmd.cmdKind, ArchiveCmdKind.Help);
        assertNull(cmd.filename);
        assertNull(cmd.vaultName);
{'fraction_non_alphanumeric': 0.1411919794629848, 'fraction_numerical': 0.0013876361617983764, 'mean_word_length': 2.5999000999001, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6001370', 'n_tokens_mistral': 4130, 'n_tokens_neox': 3913, 'n_words': 726}