use of org.infernus.idea.checkstyle.util.ProjectFilePaths in project checkstyle-idea by jshiell.
the class RelativeFileConfigurationLocationTest method setUp.
@Before
public void setUp() {
ProjectPaths projectPaths = mock(ProjectPaths.class);
Function<File, String> absolutePathOf = file -> {
// a nasty hack to pretend we're on a Windows box when required...
if (file.getPath().startsWith("c:")) {
return file.getPath().replace('/', '\\').replaceAll("\\\\\\\\", "\\\\");
}
return FilenameUtils.separatorsToUnix(file.getPath());
};
ProjectFilePaths testProjectFilePaths = new ProjectFilePaths(project, '/', absolutePathOf, projectPaths);
when(project.getService(ProjectFilePaths.class)).thenReturn(testProjectFilePaths);
when(projectBase.getPath()).thenReturn(PROJECT_BASE_PATH);
when(projectPaths.projectPath(project)).thenReturn(projectBase);
underTest = new RelativeFileConfigurationLocation(project);
underTest.setLocation("aLocation");
underTest.setDescription("aDescription");
}
use of org.infernus.idea.checkstyle.util.ProjectFilePaths in project checkstyle-idea by jshiell.
the class ConfigurationLocationTest method testSorting.
@Test
public void testSorting() {
final Project project = mock(Project.class);
when(project.getService(ProjectFilePaths.class)).thenReturn(new ProjectFilePaths(project));
List<ConfigurationLocation> list = new ArrayList<>();
FileConfigurationLocation fcl = new FileConfigurationLocation(project, ConfigurationType.LOCAL_FILE);
fcl.setDescription("descB");
fcl.setLocation("locB");
list.add(fcl);
RelativeFileConfigurationLocation rfcl1 = new RelativeFileConfigurationLocation(project);
rfcl1.setDescription("descA");
rfcl1.setLocation("locA");
list.add(rfcl1);
list.add(new BundledConfigurationLocation(BundledConfig.SUN_CHECKS, project));
RelativeFileConfigurationLocation rfcl2 = new RelativeFileConfigurationLocation(project);
rfcl2.setDescription("descC");
rfcl2.setLocation("locC");
list.add(rfcl2);
list.add(new BundledConfigurationLocation(BundledConfig.GOOGLE_CHECKS, project));
Collections.sort(list);
assertEquals(BundledConfigurationLocation.class, list.get(0).getClass());
assertTrue(list.get(0).getDescription().contains("Sun Checks"));
assertTrue(list.contains(new BundledConfigurationLocation(BundledConfig.SUN_CHECKS, project)));
assertEquals(BundledConfigurationLocation.class, list.get(1).getClass());
assertTrue(list.get(1).getDescription().contains("Google Checks"));
assertTrue(list.contains(new BundledConfigurationLocation(BundledConfig.GOOGLE_CHECKS, project)));
assertEquals(RelativeFileConfigurationLocation.class, list.get(2).getClass());
assertEquals("descA", list.get(2).getDescription());
assertEquals(FileConfigurationLocation.class, list.get(3).getClass());
assertEquals("descB", list.get(3).getDescription());
assertEquals(RelativeFileConfigurationLocation.class, list.get(4).getClass());
assertEquals("descC", list.get(4).getDescription());
}
use of org.infernus.idea.checkstyle.util.ProjectFilePaths in project checkstyle-idea by jshiell.
the class FileConfigurationLocationTest method useWindowsFilePaths.
private FileConfigurationLocation useWindowsFilePaths() {
reset(project);
ProjectFilePaths testProjectFilePaths = testProjectFilePaths('\\');
when(project.getService(ProjectFilePaths.class)).thenReturn(testProjectFilePaths);
when(projectPaths.projectPath(project)).thenReturn(projectBase);
when(projectPaths.projectPath(project)).thenReturn(projectBase);
when(projectBase.getPath()).thenReturn("c:/some-where/a-project");
return new FileConfigurationLocation(project);
}
use of org.infernus.idea.checkstyle.util.ProjectFilePaths in project checkstyle-idea by jshiell.
the class FileConfigurationLocationTest method useUnixPaths.
private FileConfigurationLocation useUnixPaths() {
reset(project);
ProjectFilePaths testProjectFilePaths = testProjectFilePaths('/');
when(project.getService(ProjectFilePaths.class)).thenReturn(testProjectFilePaths);
when(projectPaths.projectPath(project)).thenReturn(projectBase);
when(projectBase.getPath()).thenReturn(PROJECT_BASE_PATH);
return new FileConfigurationLocation(project);
}
Aggregations