// Path: src/main/java/no/pritest/vcs/VCSStatus.java
// public interface VCSStatus {
//     public Set<String> getUntracked();
//     public Set<String> getModified();
// }
// 
// Path: src/main/java/no/pritest/vcs/VCSStatusProvider.java
// public class VCSStatusProvider {
// 
//     private File basedir;
//     private final String sourceDirectory;
//     private final String testSourceDirectory;
//     VCSStatus status;
// 
//     public VCSStatusProvider(File basedir, String sourceDirectory, String testSourceDirectory, VCSStatus status) throws IOException {
//         this.basedir = basedir;
//         this.sourceDirectory = sourceDirectory.replace(basedir.getPath() + File.separator, "");
//         this.testSourceDirectory = testSourceDirectory.replace(basedir.getPath() + File.separator, "");
//         this.status = status;
//     }
// 
//     public List<String> getGitStatusPriorityList() throws NoWorkTreeException, IOException {
//         List<String> gitStatusList = new ArrayList<String>();
// 
//         addTestCasesToList(status.getUntracked(), gitStatusList);
//         addTestCasesToList(status.getModified(), gitStatusList);
// 
//         return gitStatusList;
//     }
// 
//     private void addTestCasesToList(Set<String> changedFiles, List<String> statusList) {
// 
//         TestCaseMapper mapper =
//                 new TestCaseMapper(new String[]{sourceDirectory, testSourceDirectory,
//                         basedir.getName() + File.separator + sourceDirectory,
//                         basedir.getName() + File.separator + testSourceDirectory});
// 
//         for (String changedFile : changedFiles) {
//             String testCaseName = mapper.prepareTestCaseName(changedFile);
// 
//             if (testCaseName != null && !statusList.contains(testCaseName)) {
//                 statusList.add(testCaseName);
//             }
//         }
//     }
// }


import static org.mockito.Mockito.when;
import no.pritest.vcs.VCSStatus;
import no.pritest.vcs.VCSStatusProvider;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat;
/**
    This file is part of Pritest.

    Pritest is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Pritest is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
*/

package no.pritest.vcs;




public class VCSStatusProviderTest {

    private VCSStatusProvider provider;

    @Mock
    private VCSStatus status;
    @Mock
    private File basedir;

    @Before
    public void setup() {
        MockitoAnnotations.initMocks(this);
        
        when(basedir.getPath()).thenReturn("basedir/a");
        when(basedir.getName()).thenReturn("a");
    }

    @Test
    public void should_return_list_of_tests_to_run_given_status() throws IOException {
        HashSet<String> modified = new HashSet<String>();
        modified.add("src/test/java/no/ATest.java");
        modified.add("src/test/java/no/b/B.java");

        when(status.getModified()).thenReturn(modified);
        when(status.getUntracked()).thenReturn(new HashSet<String>());

        String testSrcDir = "basedir/a/src/test/java";
        String srcDir = "basedir/a/src/main/java";

// Path: src/main/java/no/pritest/vcs/VCSStatus.java
// public interface VCSStatus {
//     public Set<String> getUntracked();
//     public Set<String> getModified();
// }
// 
// Path: src/main/java/no/pritest/vcs/VCSStatusProvider.java
// public class VCSStatusProvider {
// 
//     private File basedir;
//     private final String sourceDirectory;
//     private final String testSourceDirectory;
//     VCSStatus status;
// 
//     public VCSStatusProvider(File basedir, String sourceDirectory, String testSourceDirectory, VCSStatus status) throws IOException {
//         this.basedir = basedir;
//         this.sourceDirectory = sourceDirectory.replace(basedir.getPath() + File.separator, "");
//         this.testSourceDirectory = testSourceDirectory.replace(basedir.getPath() + File.separator, "");
//         this.status = status;
//     }
// 
//     public List<String> getGitStatusPriorityList() throws NoWorkTreeException, IOException {
//         List<String> gitStatusList = new ArrayList<String>();
// 
//         addTestCasesToList(status.getUntracked(), gitStatusList);
//         addTestCasesToList(status.getModified(), gitStatusList);
// 
//         return gitStatusList;
//     }
// 
//     private void addTestCasesToList(Set<String> changedFiles, List<String> statusList) {
// 
//         TestCaseMapper mapper =
//                 new TestCaseMapper(new String[]{sourceDirectory, testSourceDirectory,
//                         basedir.getName() + File.separator + sourceDirectory,
//                         basedir.getName() + File.separator + testSourceDirectory});
// 
//         for (String changedFile : changedFiles) {
//             String testCaseName = mapper.prepareTestCaseName(changedFile);
// 
//             if (testCaseName != null && !statusList.contains(testCaseName)) {
//                 statusList.add(testCaseName);
//             }
//         }
//     }
// }


// Path: src/test/java/no/pritest/vcs/VCSStatusProviderTest.java
import static org.mockito.Mockito.when;
import no.pritest.vcs.VCSStatus;
import no.pritest.vcs.VCSStatusProvider;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertThat;

/**
    This file is part of Pritest.

    Pritest is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Pritest is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
*/

package no.pritest.vcs;




public class VCSStatusProviderTest {

    private VCSStatusProvider provider;

    @Mock
    private VCSStatus status;
    @Mock
    private File basedir;

    @Before
    public void setup() {
        MockitoAnnotations.initMocks(this);
        
        when(basedir.getPath()).thenReturn("basedir/a");
        when(basedir.getName()).thenReturn("a");
    }

    @Test
    public void should_return_list_of_tests_to_run_given_status() throws IOException {
        HashSet<String> modified = new HashSet<String>();
        modified.add("src/test/java/no/ATest.java");
        modified.add("src/test/java/no/b/B.java");

        when(status.getModified()).thenReturn(modified);
        when(status.getUntracked()).thenReturn(new HashSet<String>());

        String testSrcDir = "basedir/a/src/test/java";
        String srcDir = "basedir/a/src/main/java";

        provider = new VCSStatusProvider(basedir, srcDir, testSrcDir, status);