use of ch.acanda.eclipse.pmd.domain.ProjectModel in project eclipse-pmd by acanda.
the class PMDPropertyPageController method init.
public void init(final IProject project) {
this.project = project;
final WorkspaceModel workspaceModel = PMDPlugin.getDefault().getWorkspaceModel();
projectModel = workspaceModel.getOrCreateProject(project.getName());
model.setInitialState(projectModel.isPMDEnabled(), projectModel.getRuleSets(), project);
final ImmutableSortedSet.Builder<RuleSetModel> ruleSetBuilder = ImmutableSortedSet.orderedBy(ProjectModel.RULE_SET_COMPARATOR);
for (final ProjectModel projectModel : workspaceModel.getProjects()) {
ruleSetBuilder.addAll(projectModel.getRuleSets());
}
model.setRuleSets(ImmutableList.copyOf(toViewModels(ruleSetBuilder.build(), project)));
reset();
}
use of ch.acanda.eclipse.pmd.domain.ProjectModel in project eclipse-pmd by acanda.
the class ProjectModelSerializerTest method deserializeWorkspaceRuleSetModel.
/**
* Verifies that {@link ProjectModelSerializer#deserialize(java.io.InputStream, String)} deserializes the attributes
* of a workspace {@link RuleSetModel} correctly.
*/
@Test
public void deserializeWorkspaceRuleSetModel() throws IOException {
final ByteArrayInputStream stream = new ByteArrayInputStream(createXmlConfiguration().getBytes(Charsets.UTF_8));
final ProjectModel projectModel = new ProjectModelSerializer().deserialize(stream, "TestProjectName");
assertRuleSetModel(projectModel, LocationContext.WORKSPACE, "Workspace Rule Set", "Projext X/pmd.xml");
}
use of ch.acanda.eclipse.pmd.domain.ProjectModel in project eclipse-pmd by acanda.
the class ProjectModelSerializerTest method deserializeProjectRuleSetModel.
/**
* Verifies that {@link ProjectModelSerializer#deserialize(java.io.InputStream, String)} deserializes the attributes
* of a project {@link RuleSetModel} correctly.
*/
@Test
public void deserializeProjectRuleSetModel() throws IOException {
final ByteArrayInputStream stream = new ByteArrayInputStream(createXmlConfiguration().getBytes(Charsets.UTF_8));
final ProjectModel projectModel = new ProjectModelSerializer().deserialize(stream, "TestProjectName");
assertRuleSetModel(projectModel, LocationContext.PROJECT, "Project Rule Set", "pmd.xml");
}
use of ch.acanda.eclipse.pmd.domain.ProjectModel in project eclipse-pmd by acanda.
the class ProjectModelSerializerTest method deserializeProjectModel.
/**
* Verifies that {@link ProjectModelSerializer#deserialize(java.io.InputStream, String)} deserializes the attributes
* of {@link ProjectModel} correctly.
*/
@Test
public void deserializeProjectModel() throws IOException {
final ByteArrayInputStream stream = new ByteArrayInputStream(createXmlConfiguration().getBytes(Charsets.UTF_8));
final ProjectModel projectModel = new ProjectModelSerializer().deserialize(stream, "TestProjectName");
assertEquals("Project name", "TestProjectName", projectModel.getProjectName());
assertTrue("PMD should be enabled", projectModel.isPMDEnabled());
assertEquals("Number of rule sets", 4, projectModel.getRuleSets().size());
}
use of ch.acanda.eclipse.pmd.domain.ProjectModel in project eclipse-pmd by acanda.
the class ProjectModelSerializerTest method serializeWithoutRuleSets.
/**
* Verifies that {@link ProjectModelSerializer#serialize(ProjectModel)} serializes a {@link ProjectModel} without
* rule sets correctly, i.e. without a {@code <rulesets>} tag.
*/
@Test
public void serializeWithoutRuleSets() throws SAXException, IOException {
final ProjectModel projectModel = new ProjectModel("TestProjectName");
projectModel.setPMDEnabled(false);
final String actual = new ProjectModelSerializer().serialize(projectModel);
final String expected = createXmlConfigurationWithoutRuleSets();
assertEquals("Serialized project model", expected, actual);
assertValid(actual);
}
Aggregations