Search in sources :

Example 1 with TestFile

use of org.pentaho.di.plugins.fileopensave.providers.model.TestFile in project pentaho-kettle by pentaho.

the class FileControllerTest method testRename.

@Test
public void testRename() throws FileException {
    TestDirectory testDirectory = new TestDirectory();
    testDirectory.setParent("/");
    testDirectory.setPath("/directory1");
    testDirectory.setName("directory1");
    fileController.getFiles(testDirectory, "", true);
    TestFile testFile = new TestFile();
    testFile.setParent("/directory1");
    testFile.setName("file1");
    testFile.setPath("/directory1/file1");
    TestFile newFile = (TestFile) fileController.rename(testFile, "/directory1/file1new", true).getData();
    Assert.assertEquals("file1new", newFile.getName());
    Assert.assertEquals("/directory1/file1new", newFile.getPath());
    Assert.assertTrue(fileController.fileCache.fileExists(testDirectory, "/directory1/file1new"));
    Assert.assertFalse(fileController.fileCache.fileExists(testDirectory, "/directory1/file1"));
}
Also used : TestDirectory(org.pentaho.di.plugins.fileopensave.providers.model.TestDirectory) TestFile(org.pentaho.di.plugins.fileopensave.providers.model.TestFile) Test(org.junit.Test)

Example 2 with TestFile

use of org.pentaho.di.plugins.fileopensave.providers.model.TestFile in project pentaho-kettle by pentaho.

the class TestFileProvider method rename.

@Override
public TestFile rename(TestFile file, String newPath, boolean overwrite) throws FileException {
    TestFile findFile = findFile(file);
    if (findFile != null) {
        findFile.setPath(newPath);
        findFile.setName(newPath.substring(newPath.lastIndexOf("/") + 1));
        findFile.setParent(newPath.substring(0, newPath.lastIndexOf("/")));
    }
    return findFile;
}
Also used : TestFile(org.pentaho.di.plugins.fileopensave.providers.model.TestFile)

Example 3 with TestFile

use of org.pentaho.di.plugins.fileopensave.providers.model.TestFile in project pentaho-kettle by pentaho.

the class FileControllerTest method testCopy.

@Test
public void testCopy() throws FileException {
    TestDirectory testDirectory = new TestDirectory();
    testDirectory.setParent("/");
    testDirectory.setPath("/directory1");
    testDirectory.setName("directory1");
    fileController.getFiles(testDirectory, "", true);
    TestDirectory testDirectory4 = new TestDirectory();
    testDirectory4.setParent("/");
    testDirectory4.setPath("/directory4");
    testDirectory4.setName("directory4");
    fileController.getFiles(testDirectory4, "", true);
    TestFile testFile = new TestFile();
    testFile.setParent("/directory1");
    testFile.setName("file1");
    testFile.setPath("/directory1/file1");
    TestFile newFile = (TestFile) fileController.copyFile(testFile, testDirectory4, "/directory4/file1", true).getData();
    Assert.assertEquals("file1", newFile.getName());
    Assert.assertEquals("/directory4/file1", newFile.getPath());
    Assert.assertTrue(fileController.fileCache.fileExists(testDirectory, "/directory1/file1"));
    Assert.assertTrue(fileController.fileCache.fileExists(testDirectory4, "/directory4/file1"));
}
Also used : TestDirectory(org.pentaho.di.plugins.fileopensave.providers.model.TestDirectory) TestFile(org.pentaho.di.plugins.fileopensave.providers.model.TestFile) Test(org.junit.Test)

Example 4 with TestFile

use of org.pentaho.di.plugins.fileopensave.providers.model.TestFile in project pentaho-kettle by pentaho.

the class FileControllerTest method testMove.

@Test
public void testMove() throws FileException {
    TestDirectory testDirectory = new TestDirectory();
    testDirectory.setParent("/");
    testDirectory.setPath("/directory1");
    testDirectory.setName("directory1");
    fileController.getFiles(testDirectory, "", true);
    TestDirectory testDirectory4 = new TestDirectory();
    testDirectory4.setParent("/");
    testDirectory4.setPath("/directory4");
    testDirectory4.setName("directory4");
    fileController.getFiles(testDirectory4, "", true);
    TestFile testFile = new TestFile();
    testFile.setParent("/directory1");
    testFile.setName("file1");
    testFile.setPath("/directory1/file1");
    TestFile newFile = (TestFile) fileController.moveFile(testFile, testDirectory4, "/directory4/file1", true).getData();
    Assert.assertEquals("file1", newFile.getName());
    Assert.assertEquals("/directory4/file1", newFile.getPath());
    Assert.assertFalse(fileController.fileCache.fileExists(testDirectory, "/directory1/file1"));
    Assert.assertTrue(fileController.fileCache.fileExists(testDirectory4, "/directory4/file1"));
}
Also used : TestDirectory(org.pentaho.di.plugins.fileopensave.providers.model.TestDirectory) TestFile(org.pentaho.di.plugins.fileopensave.providers.model.TestFile) Test(org.junit.Test)

Example 5 with TestFile

use of org.pentaho.di.plugins.fileopensave.providers.model.TestFile in project pentaho-kettle by pentaho.

the class TestFileProvider method copy.

@Override
public TestFile copy(TestFile file, String toPath, boolean overwrite) throws FileException {
    TestFile findFile = findFile(file);
    if (findFile != null) {
        String parent = toPath.substring(0, toPath.lastIndexOf("/"));
        if (findFile instanceof TestDirectory) {
            TestDirectory newDirectory = TestDirectory.create(findFile.getName(), toPath, parent);
            testFileSystem.get(newDirectory.getParent()).add(newDirectory);
            return newDirectory;
        } else {
            TestFile newFile = TestFile.create(findFile.getName(), toPath, parent);
            testFileSystem.get(newFile.getParent()).add(newFile);
            return newFile;
        }
    }
    return null;
}
Also used : TestDirectory(org.pentaho.di.plugins.fileopensave.providers.model.TestDirectory) TestFile(org.pentaho.di.plugins.fileopensave.providers.model.TestFile)

Aggregations

TestFile (org.pentaho.di.plugins.fileopensave.providers.model.TestFile)5 TestDirectory (org.pentaho.di.plugins.fileopensave.providers.model.TestDirectory)4 Test (org.junit.Test)3