Search in sources :

Example 6 with StaticAnalysisWarningEvent

use of nl.tudelft.watchdog.core.logic.event.eventtypes.staticanalysis.StaticAnalysisWarningEvent in project watchdog by TestRoots.

the class MarkupModelListenerTest method computes_warning_time_difference_for_removed_warning.

@Test
public void computes_warning_time_difference_for_removed_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);
            this.saveWorkspaceAndWaitForBuild();
            marker.delete();
        } catch (Exception e) {
            e.printStackTrace();
        }
    });
    assertEquals(generatedEvents.size(), 2);
    // We simply want any time difference here. If there is any, it is not -1, but 0, 1 or anything above
    // We do not want to rely on timing differences to assert on specific values, so asserting we have
    // anything is sufficient
    assertNotEquals(generatedEvents.get(1).warning.secondsBetween, -1);
}
Also used : StaticAnalysisWarningEvent(nl.tudelft.watchdog.core.logic.event.eventtypes.staticanalysis.StaticAnalysisWarningEvent) IMarker(org.eclipse.core.resources.IMarker) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) Test(org.junit.Test)

Example 7 with StaticAnalysisWarningEvent

use of nl.tudelft.watchdog.core.logic.event.eventtypes.staticanalysis.StaticAnalysisWarningEvent in project watchdog by TestRoots.

the class MarkupModelListenerTest method correctly_generates_document_information.

@Test
public void correctly_generates_document_information() throws Exception {
    List<StaticAnalysisWarningEvent> generatedWarnings = this.deleteMarkerAndReturnGeneratedWarningList(this.preExistingMarker);
    assertEquals(generatedWarnings.size(), 1);
    Document document = generatedWarnings.get(0).document;
    assertEquals(document.getFileName(), "Existing.java");
    assertEquals(document.getContent().split("\\d+").length, 25);
}
Also used : StaticAnalysisWarningEvent(nl.tudelft.watchdog.core.logic.event.eventtypes.staticanalysis.StaticAnalysisWarningEvent) Document(nl.tudelft.watchdog.core.logic.document.Document) Test(org.junit.Test)

Aggregations

StaticAnalysisWarningEvent (nl.tudelft.watchdog.core.logic.event.eventtypes.staticanalysis.StaticAnalysisWarningEvent)7 Test (org.junit.Test)6 IMarker (org.eclipse.core.resources.IMarker)5 CoreException (org.eclipse.core.runtime.CoreException)5 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 Stream (java.util.stream.Stream)1 Document (nl.tudelft.watchdog.core.logic.document.Document)1 TrackingEventManager (nl.tudelft.watchdog.core.logic.event.TrackingEventManager)1 WatchDogEventEditorSpecificImplementation (nl.tudelft.watchdog.core.logic.ui.events.WatchDogEventType.WatchDogEventEditorSpecificImplementation)1 IntervalManager (nl.tudelft.watchdog.eclipse.logic.interval.IntervalManager)1 TransferManager (nl.tudelft.watchdog.eclipse.logic.network.TransferManager)1 WorkbenchListener (nl.tudelft.watchdog.eclipse.logic.ui.listeners.WorkbenchListener)1 PartInitException (org.eclipse.ui.PartInitException)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1