Search in sources :

Example 6 with WorkbenchResolutionAdapter

use of com.avaloq.tools.ddk.xtext.ui.quickfix.WorkbenchMarkerResolutionGenerator.WorkbenchResolutionAdapter in project dsl-devkit by dsldevkit.

the class WorkbenchResolutionAdaptorTest method findOtherMarkers.

@Test
public void findOtherMarkers() {
    IssueResolution mockIssueResolution = mock(IssueResolution.class);
    IMarker mockResolutionMarker = mock(IMarker.class);
    when(mockResolutionMarker.getAttribute(Issue.CODE_KEY, null)).thenReturn(CODE1);
    IMarker mockMarker1 = mock(IMarker.class);
    when(mockMarker1.getAttribute(Issue.CODE_KEY, null)).thenReturn(CODE1);
    IMarker mockMarker2 = mock(IMarker.class);
    when(mockMarker2.getAttribute(Issue.CODE_KEY, null)).thenReturn(CODE2);
    IMarker mockMarker3 = mock(IMarker.class);
    when(mockMarker3.getAttribute(Issue.CODE_KEY, null)).thenReturn(CODE1);
    IMarker[] allMarkers = new IMarker[] { mockMarker1, mockMarker2, mockMarker3 };
    IMarker[] matchingMarkers = new IMarker[] { mockMarker1, mockMarker3 };
    WorkbenchResolutionAdapter adapter = mockWmrg.new WorkbenchResolutionAdapter(mockIssueResolution, mockResolutionMarker);
    // $NON-NLS-1$
    assertArrayEquals("Adapter findOtherMarkers matching on CODE1.", matchingMarkers, adapter.findOtherMarkers(allMarkers));
    when(mockResolutionMarker.getAttribute(Issue.CODE_KEY, null)).thenReturn(CODE2);
    matchingMarkers = new IMarker[] { mockMarker2 };
    adapter = mockWmrg.new WorkbenchResolutionAdapter(mockIssueResolution, mockResolutionMarker);
    // $NON-NLS-1$
    assertArrayEquals("Adapter findOtherMarkers matching on CODE2.", matchingMarkers, adapter.findOtherMarkers(allMarkers));
}
Also used : WorkbenchResolutionAdapter(com.avaloq.tools.ddk.xtext.ui.quickfix.WorkbenchMarkerResolutionGenerator.WorkbenchResolutionAdapter) IssueResolution(org.eclipse.xtext.ui.editor.quickfix.IssueResolution) IMarker(org.eclipse.core.resources.IMarker) Test(org.junit.Test)

Example 7 with WorkbenchResolutionAdapter

use of com.avaloq.tools.ddk.xtext.ui.quickfix.WorkbenchMarkerResolutionGenerator.WorkbenchResolutionAdapter in project dsl-devkit by dsldevkit.

the class WorkbenchResolutionAdaptorTest method testGetLabel.

@Test
public void testGetLabel() {
    IssueResolution mockIssueResolution = mock(IssueResolution.class);
    IMarker mockMarker = mock(IMarker.class);
    when(mockIssueResolution.getLabel()).thenReturn(TEST_LABEL);
    WorkbenchResolutionAdapter adapter = mockWmrg.new WorkbenchResolutionAdapter(mockIssueResolution, mockMarker);
    // $NON-NLS-1$
    assertEquals("Adapter delegates get label to resolution.", TEST_LABEL, adapter.getLabel());
}
Also used : WorkbenchResolutionAdapter(com.avaloq.tools.ddk.xtext.ui.quickfix.WorkbenchMarkerResolutionGenerator.WorkbenchResolutionAdapter) IssueResolution(org.eclipse.xtext.ui.editor.quickfix.IssueResolution) IMarker(org.eclipse.core.resources.IMarker) Test(org.junit.Test)

Aggregations

WorkbenchResolutionAdapter (com.avaloq.tools.ddk.xtext.ui.quickfix.WorkbenchMarkerResolutionGenerator.WorkbenchResolutionAdapter)7 Test (org.junit.Test)6 IMarker (org.eclipse.core.resources.IMarker)5 IssueResolution (org.eclipse.xtext.ui.editor.quickfix.IssueResolution)5 IFile (org.eclipse.core.resources.IFile)1 IMarkerResolution (org.eclipse.ui.IMarkerResolution)1 IssueUtil (org.eclipse.xtext.ui.util.IssueUtil)1 Issue (org.eclipse.xtext.validation.Issue)1 Before (org.junit.Before)1