use of ch.acanda.eclipse.pmd.domain.Location in project eclipse-pmd by acanda.
the class V07ToV08ConverterTest method convertWorkspaceLocationFallback.
@Test
public void convertWorkspaceLocationFallback() {
final RuleSetConfiguration config = new WorkspaceRuleSetConfiguration(1, "Workspace Config", Paths.get("../somewhere/else/pmd.xml"));
final IWorkspaceRoot workspaceRoot = mock(IWorkspaceRoot.class);
when(workspaceRoot.getLocationURI()).thenReturn(URI.create("file:///home/workspace/"));
doReturn(createProjects()).when(workspaceRoot).getProjects();
final Location result = V07ToV08Converter.getLocation(config, workspaceRoot);
assertEquals("Location path", Paths.get("/home", "somewhere", "else", "pmd.xml").toString(), result.getPath());
assertEquals("Location context", LocationContext.FILE_SYSTEM, result.getContext());
}
use of ch.acanda.eclipse.pmd.domain.Location in project eclipse-pmd by acanda.
the class V07ToV08ConverterTest method convertWorkspaceLocationProjectInWorkspace.
@Test
public void convertWorkspaceLocationProjectInWorkspace() {
final RuleSetConfiguration config = new WorkspaceRuleSetConfiguration(1, "Workspace Config", Paths.get("ch.acanda.eclipse.pmd/pmd.xml"));
final IWorkspaceRoot workspaceRoot = mock(IWorkspaceRoot.class);
when(workspaceRoot.getLocationURI()).thenReturn(URI.create("file:///home/src/"));
doReturn(createProjects()).when(workspaceRoot).getProjects();
final Location result = V07ToV08Converter.getLocation(config, workspaceRoot);
assertEquals("Location path", Paths.get("ch.acanda.eclipse.pmd", "pmd.xml").toString(), result.getPath());
assertEquals("Location context", LocationContext.WORKSPACE, result.getContext());
}
use of ch.acanda.eclipse.pmd.domain.Location in project eclipse-pmd by acanda.
the class AddRuleSetConfigurationModel method getAbsoluteLocation.
private Optional<Path> getAbsoluteLocation() {
final LocationContext locationContext;
if (isWorkspaceTypeSelected) {
locationContext = LocationContext.WORKSPACE;
} else if (isProjectTypeSelected) {
locationContext = LocationContext.PROJECT;
} else if (isFileSystemTypeSelected) {
locationContext = LocationContext.FILE_SYSTEM;
} else {
throw new IllegalStateException("Unknown location type");
}
final Optional<String> resolvedLocation = LocationResolver.resolveIfExists(new Location(location, locationContext), project);
if (resolvedLocation.isPresent()) {
return Optional.of(Paths.get(resolvedLocation.get()));
}
return Optional.absent();
}
Aggregations