Search in sources :

Example 16 with ProjectModel

use of ch.acanda.eclipse.pmd.domain.ProjectModel in project eclipse-pmd by acanda.

the class RuleSetsCacheTest method secondGetLoadsWhenProjectWasREmovedAndAddedAfterFirstGet.

/**
 * Verifies that the second cache access loads the rule sets if the project model has been removed and added after
 * the first access.
 */
@Test
public void secondGetLoadsWhenProjectWasREmovedAndAddedAfterFirstGet() throws Exception {
    final WorkspaceModel workspaceModel = getWorkspaceModel();
    final RuleSetsCache cache = new RuleSetsCache(getCacheLoaderMock(), workspaceModel);
    cache.getRuleSets(PROJECT_NAME_1);
    workspaceModel.remove(PROJECT_NAME_1);
    workspaceModel.add(new ProjectModel(PROJECT_NAME_1));
    final RuleSets actualRuleSets = cache.getRuleSets(PROJECT_NAME_1);
    assertSame("Second cache access should reload rule sets", RULE_SETS_FOO_2, actualRuleSets);
}
Also used : WorkspaceModel(ch.acanda.eclipse.pmd.domain.WorkspaceModel) RuleSets(net.sourceforge.pmd.RuleSets) ProjectModel(ch.acanda.eclipse.pmd.domain.ProjectModel) Test(org.junit.Test)

Example 17 with ProjectModel

use of ch.acanda.eclipse.pmd.domain.ProjectModel in project eclipse-pmd by acanda.

the class RuleSetsCacheTest method getWorkspaceModel.

private WorkspaceModel getWorkspaceModel() {
    final WorkspaceModel workspaceModel = new WorkspaceModel();
    workspaceModel.add(new ProjectModel(PROJECT_NAME_1));
    return workspaceModel;
}
Also used : WorkspaceModel(ch.acanda.eclipse.pmd.domain.WorkspaceModel) ProjectModel(ch.acanda.eclipse.pmd.domain.ProjectModel)

Aggregations

ProjectModel (ch.acanda.eclipse.pmd.domain.ProjectModel)17 Test (org.junit.Test)10 ByteArrayInputStream (java.io.ByteArrayInputStream)6 WorkspaceModel (ch.acanda.eclipse.pmd.domain.WorkspaceModel)5 RuleSetModel (ch.acanda.eclipse.pmd.domain.RuleSetModel)4 RuleSets (net.sourceforge.pmd.RuleSets)3 Location (ch.acanda.eclipse.pmd.domain.Location)2 IProject (org.eclipse.core.resources.IProject)2 ProjectModelRepository (ch.acanda.eclipse.pmd.repository.ProjectModelRepository)1 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 RuleSetFactory (net.sourceforge.pmd.RuleSetFactory)1 RuleSetNotFoundException (net.sourceforge.pmd.RuleSetNotFoundException)1 RuleSetReferenceId (net.sourceforge.pmd.RuleSetReferenceId)1 IFile (org.eclipse.core.resources.IFile)1 IResourceChangeListener (org.eclipse.core.resources.IResourceChangeListener)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 CoreException (org.eclipse.core.runtime.CoreException)1