Search in sources :

Example 1 with N4JSProjectExplorerProblemsDecorator

use of org.eclipse.n4js.ui.navigator.N4JSProjectExplorerProblemsDecorator in project n4js by eclipse.

the class GHOLD_101_WorkingSetsTest_PluginUITest method testMarkerSupportForWorkingSets.

/**
 */
@Test
public void testMarkerSupportForWorkingSets() throws CoreException, IOException {
    final IProject project = createN4JSProject("P1", LIBRARY);
    createTestFile(project.getFolder("src"), "A", "class a { }");
    final IFile moduleFile = project.getFolder("src").getFile("A.n4js");
    assertTrue("File is not accessible under src/A.n4js", moduleFile.isAccessible());
    // line 1: Class names should start with upper case letter.
    assertMarkers("Expected exactly one validation issue.", project, 1);
    activateWorkingSetManager(ManualAssociationAwareWorkingSetManager.class);
    final TreeItem[] treeItems = commonViewer.getTree().getItems();
    assertTrue("Expected exactly one item in the Project Explorer. Input was: " + Arrays.toString(treeItems), treeItems.length == 1);
    final Object data = treeItems[0].getData();
    assertTrue("Expected " + WorkingSet.class + " input in navigator. Was " + data, data instanceof WorkingSet);
    final WorkingSet workingSet = (WorkingSet) treeItems[0].getData();
    assertTrue("Expected working set with ID: " + OTHERS_WORKING_SET_ID + ". Was " + workingSet.getId(), OTHERS_WORKING_SET_ID.equals(workingSet.getId()));
    final N4JSProjectExplorerProblemsDecorator decorator = new N4JSProjectExplorerProblemsDecorator();
    int adornmentFlag = decorator.computeAdornmentFlags(workingSet);
    assertEquals("Adornment mismatch.", WARNING, adornmentFlag);
    try (final InputStream is = new StringInputStream("someBrokenContent")) {
        moduleFile.setContents(is, IResource.FORCE, null);
    }
    waitForAutoBuild();
    // line 1: Couldn't resolve reference to IdentifiableElement 'someBrokenContent'
    assertMarkers("Expected exactly one validation issue.", project, 1);
    adornmentFlag = decorator.computeAdornmentFlags(workingSet);
    assertEquals("Adornment mismatch.", ERROR, adornmentFlag);
    try (final InputStream is = new StringInputStream("class A { }")) {
        moduleFile.setContents(is, IResource.FORCE, null);
    }
    waitForAutoBuild();
    assertMarkers("Expected exactly zero validation issues.", project, 0);
    adornmentFlag = decorator.computeAdornmentFlags(workingSet);
    assertEquals("Adornment mismatch.", NO_ADORNMENT, adornmentFlag);
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) IFile(org.eclipse.core.resources.IFile) TreeItem(org.eclipse.swt.widgets.TreeItem) StringInputStream(org.eclipse.xtext.util.StringInputStream) InputStream(java.io.InputStream) ManualAssociationWorkingSet(org.eclipse.n4js.ui.workingsets.ManualAssociationAwareWorkingSetManager.ManualAssociationWorkingSet) ProjectNameFilterWorkingSet(org.eclipse.n4js.ui.workingsets.ProjectNameFilterAwareWorkingSetManager.ProjectNameFilterWorkingSet) ProjectTypeWorkingSet(org.eclipse.n4js.ui.workingsets.ProjectTypeAwareWorkingSetManager.ProjectTypeWorkingSet) WorkingSet(org.eclipse.n4js.ui.workingsets.WorkingSet) IProject(org.eclipse.core.resources.IProject) N4JSProjectExplorerProblemsDecorator(org.eclipse.n4js.ui.navigator.N4JSProjectExplorerProblemsDecorator) Test(org.junit.Test)

Aggregations

InputStream (java.io.InputStream)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 N4JSProjectExplorerProblemsDecorator (org.eclipse.n4js.ui.navigator.N4JSProjectExplorerProblemsDecorator)1 ManualAssociationWorkingSet (org.eclipse.n4js.ui.workingsets.ManualAssociationAwareWorkingSetManager.ManualAssociationWorkingSet)1 ProjectNameFilterWorkingSet (org.eclipse.n4js.ui.workingsets.ProjectNameFilterAwareWorkingSetManager.ProjectNameFilterWorkingSet)1 ProjectTypeWorkingSet (org.eclipse.n4js.ui.workingsets.ProjectTypeAwareWorkingSetManager.ProjectTypeWorkingSet)1 WorkingSet (org.eclipse.n4js.ui.workingsets.WorkingSet)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 StringInputStream (org.eclipse.xtext.util.StringInputStream)1 Test (org.junit.Test)1