@@ -0,0 +1,3573 @@
+package jfdi.test.storage;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0Aimport java.util.ArrayList;%0A%0Aimport jfdi.storage.Constants;%0Aimport jfdi.storage.FileStorage;%0Aimport jfdi.storage.records.Alias;%0A%0Aimport org.junit.After;%0Aimport org.junit.BeforeClass;%0Aimport org.junit.Test;%0A%0Apublic class AliasTest %7B%0A%0A    private static Path testDirectory = null;%0A    private static String testDirectoryString = null;%0A%0A    @BeforeClass%0A    public static void setUpBeforeClass() throws Exception %7B%0A        testDirectory = Files.createTempDirectory(Constants.TEST_DIRECTORY_NAME);%0A        testDirectoryString = testDirectory.toString();%0A        FileStorage fileStorageInstance = FileStorage.getInstance();%0A        fileStorageInstance.load(testDirectory.toString());%0A    %7D%0A%0A    @After%0A    public void tearDown() throws Exception %7B%0A        clearAliasList();%0A    %7D%0A%0A    @Test%0A    public void testAliasConstructorAndGetters() %7B%0A        Alias alias = new Alias(Constants.TEST_ALIAS, Constants.TEST_COMMAND);%0A        assertEquals(alias.getAlias(), Constants.TEST_ALIAS);%0A        assertEquals(alias.getCommand(), Constants.TEST_COMMAND);%0A    %7D%0A%0A    @Test%0A    public void testGetAllAliases() %7B%0A        Alias alias = new Alias(Constants.TEST_ALIAS, Constants.TEST_COMMAND);%0A        alias.createAndPersist();%0A%0A        Alias alias2 = new Alias(Constants.TEST_ALIAS_2, Constants.TEST_COMMAND_2);%0A        alias2.createAndPersist();%0A%0A        ArrayList%3CAlias%3E expectedAliasList = new ArrayList%3CAlias%3E();%0A        expectedAliasList.add(alias);%0A        expectedAliasList.add(alias2);%0A%0A        ArrayList%3CAlias%3E obtainedAliasList = new ArrayList%3CAlias%3E(Alias.getAllAliases());%0A        assertEquals(expectedAliasList, obtainedAliasList);%0A    %7D%0A%0A    @Test%0A    public void testSetAndGetFilePath() %7B%0A        Path subdirectory = Paths.get(testDirectory.toString(), Constants.TEST_SUBDIRECTORY_NAME);%0A        Path expectedAliasPath = Paths.get(subdirectory.toString(), Constants.FILENAME_ALIAS);%0A%0A        Alias.setFilePath(subdirectory.toString());%0A%0A        assertEquals(expectedAliasPath, Alias.getFilePath());%0A%0A        // Reset back to the original filepath%0A        Alias.setFilePath(testDirectoryString);;%0A    %7D%0A%0A    @Test%0A    public void testDestroyAndUndestroy() %7B%0A        Alias alias = new Alias(Constants.TEST_ALIAS, Constants.TEST_COMMAND);%0A        alias.createAndPersist();%0A%0A        assertEquals(Alias.getCommandFromAlias(alias.getAlias()), alias.getCommand());%0A%0A        Alias.destroy(alias.getAlias());%0A%0A        assertEquals(Alias.getCommandFromAlias(alias.getAlias()), null);%0A%0A        Alias.undestroy(alias.getAlias());%0A%0A        assertEquals(Alias.getCommandFromAlias(alias.getAlias()), alias.getCommand());%0A    %7D%0A%0A    @Test%0A    public void testCreateAndPersistAndLoad() %7B%0A        Alias alias = new Alias(Constants.TEST_ALIAS, Constants.TEST_COMMAND);%0A        alias.createAndPersist();%0A%0A        assertEquals(Alias.getCommandFromAlias(alias.getAlias()), alias.getCommand());%0A%0A        Alias.destroy(alias.getAlias());%0A        assertEquals(Alias.getCommandFromAlias(alias.getAlias()), null);%0A%0A        Alias.load();%0A        assertEquals(Alias.getCommandFromAlias(alias.getAlias()), alias.getCommand());%0A    %7D%0A%0A    /**%0A     * This method deletes all existing aliases from the program storage.%0A     */%0A    private void clearAliasList() %7B%0A        ArrayList%3CAlias%3E aliasList = new ArrayList%3CAlias%3E(Alias.getAllAliases());%0A        for (Alias alias : aliasList) %7B%0A            Alias.destroy(alias.getAlias());%0A        %7D%0A    %7D%0A%0A%7D%0A

Implement AliasTest