package io;

import com.google.common.collect.ImmutableList;
import configuration.Configuration;
import database.repository.ChangeRepository;
import io.filesystem.FileSystemInterface;
import io.filesystem.FileSystemWrapperTest;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.graphdb.Node;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Collectors;

import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;

/**
 * Created by david on 2016-05-20.
 */
public class DeleteTest {
    private static Logger logger = LoggerFactory.getLogger(DeleteTest.class.getSimpleName());
    private FileSystemInterface fs;
    private Delete delete;
    private ChangeRepository changeRepository;
    private Node fileNode;
    private String path;

    @Before
    public void setUp() throws Exception {
        Configuration configuration = new Configuration();
        fs = new FileSystemWrapperTest(configuration);

        changeRepository = mock(ChangeRepository.class);
        fileNode = mock(Node.class);

        delete = new Delete(fs);
        delete.setFileId("fileId");

        path = "test";

        init();
    }

    private void init() throws IOException {
        Path folder = fs.getRootPath().resolve(path);
        Files.createDirectories(fs.getRootPath());
        Files.createDirectory(folder);
        Files.write(fs.getRootPath().resolve("file1.txt"),
                ImmutableList.of("Hello world"), StandardCharsets.UTF_8);
    }

    @Test
    public void testWrite() throws Exception{
        assertEquals(2, getList().size());
        assertTrue(delete.write(path));
        assertEquals(1, getList().size());
    }

    @Test
    public void testWrite2() throws Exception{
        assertFalse(delete.write("path", "path"));
    }


    private List<Path> getList() throws IOException {
        return Files.list(delete.getFileSystem().getRootPath()).collect(Collectors.toList());
    }
}
@@ -94,53 +94,8 @@
 on;%0A
-import database.repository.ChangeRepository;%0A
 impo
@@ -803,55 +803,8 @@
 te;%0A
-    private ChangeRepository changeRepository;%0A
     
@@ -1021,25 +1021,24 @@
 ation);%0A
-%0A
         
 changeRe
@@ -1033,94 +1033,8 @@
     
-changeRepository = mock(ChangeRepository.class);%0A        fileNode = mock(Node.class);%0A
 %0A   

Remove ChangeRepository reference