use of nl.tudelft.watchdog.core.logic.event.eventtypes.staticanalysis.StaticAnalysisWarningEvent in project watchdog by TestRoots.
the class MarkupModelListenerTest method sets_line_number_for_generated_warning.
@Test
public void sets_line_number_for_generated_warning() throws Exception {
List<StaticAnalysisWarningEvent> generatedEvents = processMarkerAndReturnGeneratedWarningList(() -> {
try {
IMarker marker = this.testFile.createMarker(IMarker.PROBLEM);
marker.setAttribute(IMarker.MESSAGE, "This warning does not exist");
marker.setAttribute(IMarker.LINE_NUMBER, 15);
} catch (CoreException e) {
e.printStackTrace();
}
});
assertEquals(generatedEvents.size(), 1);
assertEquals(generatedEvents.get(0).warning.lineNumber, 15);
}
use of nl.tudelft.watchdog.core.logic.event.eventtypes.staticanalysis.StaticAnalysisWarningEvent in project watchdog by TestRoots.
the class MarkupModelListenerTest method correctly_classifies_checkstyle_warning_type.
@Test
public void correctly_classifies_checkstyle_warning_type() throws Exception {
List<StaticAnalysisWarningEvent> generatedEvents = processMarkerAndReturnGeneratedWarningList(() -> {
try {
IMarker marker = this.testFile.createMarker(EclipseMarkupModelListener.CHECKSTYLE_MARKER_ID);
marker.setAttribute(IMarker.MESSAGE, "Using the '.*' form of import should be avoided - java.util.*.");
} catch (CoreException e) {
e.printStackTrace();
}
});
assertEquals(generatedEvents.size(), 1);
assertEquals(generatedEvents.get(0).warning.type, "checkstyle.imports.import.avoidStar");
}
use of nl.tudelft.watchdog.core.logic.event.eventtypes.staticanalysis.StaticAnalysisWarningEvent in project watchdog by TestRoots.
the class MarkupModelListenerTest method correctly_classifies_warning_type_for_creating_a_new_marker.
@Test
public void correctly_classifies_warning_type_for_creating_a_new_marker() throws Exception {
List<StaticAnalysisWarningEvent> generatedEvents = processMarkerAndReturnGeneratedWarningList(() -> {
try {
IMarker marker = this.testFile.createMarker(IMarker.PROBLEM);
marker.setAttribute(IMarker.MESSAGE, "Duplicate tag for parameter");
} catch (CoreException e) {
e.printStackTrace();
}
});
assertEquals(generatedEvents.size(), 1);
// See explanation in the previous test why this is 474
assertEquals(generatedEvents.get(0).warning.type, "474");
}
use of nl.tudelft.watchdog.core.logic.event.eventtypes.staticanalysis.StaticAnalysisWarningEvent in project watchdog by TestRoots.
the class MarkupModelListenerTest method non_existing_warning_should_not_match_any_type.
@Test
public void non_existing_warning_should_not_match_any_type() throws Exception {
List<StaticAnalysisWarningEvent> generatedEvents = processMarkerAndReturnGeneratedWarningList(() -> {
try {
IMarker marker = this.testFile.createMarker(IMarker.PROBLEM);
marker.setAttribute(IMarker.MESSAGE, "This warning does not exist");
} catch (CoreException e) {
e.printStackTrace();
}
});
assertEquals(generatedEvents.size(), 1);
assertEquals(generatedEvents.get(0).warning.type, "unknown");
}
use of nl.tudelft.watchdog.core.logic.event.eventtypes.staticanalysis.StaticAnalysisWarningEvent in project watchdog by TestRoots.
the class MarkupModelListenerTest method setup.
@Before
public void setup() throws Exception {
WatchDogEventType.intervalManager = Mockito.mock(IntervalManager.class);
WatchDogEventType.editorSpecificImplementation = Mockito.mock(WatchDogEventEditorSpecificImplementation.class);
this.transferManager = Mockito.mock(TransferManager.class);
this.trackingEventManager = Mockito.mock(TrackingEventManager.class);
this.generatedEvents = new ArrayList<>();
Mockito.doAnswer(new Answer<Object>() {
@SuppressWarnings("unchecked")
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Stream<StaticAnalysisWarningEvent> stream = (Stream<StaticAnalysisWarningEvent>) invocation.getArguments()[0];
stream.map(StaticAnalysisWarningEvent::getType).forEach(generatedEvents::add);
return null;
}
}).when(this.trackingEventManager).addEvents(Mockito.any());
this.setUpTestingProject();
this.workbenchListener = new WorkbenchListener(trackingEventManager, transferManager);
this.workbenchListener.attachListeners();
}
Aggregations