Search in sources :

Example 26 with WatchDogItem

use of nl.tudelft.watchdog.core.logic.storage.WatchDogItem in project watchdog by TestRoots.

the class IntervalJsonConverterTest method testJsonTypingIntervalMissingDocumentRepresentation.

/**
 * Tests the format of the returned Json representation, if one of the
 * typing intervals does not have its ending document properly set.
 */
@Test
public void testJsonTypingIntervalMissingDocumentRepresentation() {
    ITextEditor editor = Mockito.mock(ITextEditor.class);
    TypingInterval interval = new TypingInterval(new EditorWrapper(editor), new Date());
    ArrayList<WatchDogItem> intervals = createSampleIntervals(interval);
    assertEquals("[{\"modCountDiff\":0,\"charLengthDiff\":0,\"doc\":{\"pn\":\"f6f4da8d93e88a08220e03b7810451d3ba540a34\",\"fn\":\"90a8834de76326869f3e703cd61513081ad73d3c\",\"sloc\":1,\"dt\":\"pr\"},\"it\":\"ty\",\"ts\":1,\"te\":2,\"ss\":\"\"," + pasteWDVAndClient() + "}]", transferer.toJson(intervals));
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) TypingInterval(nl.tudelft.watchdog.core.logic.interval.intervaltypes.TypingInterval) EditorWrapper(nl.tudelft.watchdog.eclipse.logic.document.EditorWrapper) Date(java.util.Date) WatchDogItem(nl.tudelft.watchdog.core.logic.storage.WatchDogItem) Test(org.junit.Test)

Example 27 with WatchDogItem

use of nl.tudelft.watchdog.core.logic.storage.WatchDogItem in project watchdog by TestRoots.

the class IntervalJsonConverterTest method testJsonTypingIntervalDiffsRemoval.

@Test
public void testJsonTypingIntervalDiffsRemoval() {
    ITextEditor editor = Mockito.mock(ITextEditor.class);
    TypingInterval interval = new TypingInterval(new EditorWrapper(editor), new Date(1));
    interval.setDocument(new Document("Project", "filepath", "Production.java", "blah-document"));
    interval.setEndingDocument(new Document("Project", "filepath", "Production.java", "blah-doc"));
    interval.close();
    sleepABit();
    ArrayList<WatchDogItem> intervals = new ArrayList<>();
    intervals.add(interval);
    assertEquals("[{\"endingDocument\":{\"pn\":\"f6f4da8d93e88a08220e03b7810451d3ba540a34\",\"fn\":\"e4afa075bb910c8ecb427e9950426a4599b21d7e\",\"sloc\":1,\"dt\":\"un\"},\"diff\":5,\"modCountDiff\":0,\"charLengthDiff\":5,\"doc\":{\"pn\":\"f6f4da8d93e88a08220e03b7810451d3ba540a34\",\"fn\":\"e4afa075bb910c8ecb427e9950426a4599b21d7e\",\"sloc\":1,\"dt\":\"un\"},\"it\":\"ty\",\"ts\":1," + pasteWDVAndClient() + "}]", transferer.toJson(intervals));
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) TypingInterval(nl.tudelft.watchdog.core.logic.interval.intervaltypes.TypingInterval) EditorWrapper(nl.tudelft.watchdog.eclipse.logic.document.EditorWrapper) ArrayList(java.util.ArrayList) Document(nl.tudelft.watchdog.core.logic.document.Document) Date(java.util.Date) WatchDogItem(nl.tudelft.watchdog.core.logic.storage.WatchDogItem) Test(org.junit.Test)

Example 28 with WatchDogItem

use of nl.tudelft.watchdog.core.logic.storage.WatchDogItem in project watchdog by TestRoots.

the class IntervalJsonConverterTest method testJsonTypingIntervalDiffsAddition.

@Test
public void testJsonTypingIntervalDiffsAddition() {
    ITextEditor editor = Mockito.mock(ITextEditor.class);
    TypingInterval interval = new TypingInterval(new EditorWrapper(editor), new Date(1));
    interval.setDocument(new Document("Project", "filepath", "Production.java", "blah-document"));
    interval.setEndingDocument(new Document("Project", "filepath", "Production.java", "blah-document-add"));
    interval.close();
    sleepABit();
    ArrayList<WatchDogItem> intervals = new ArrayList<>();
    intervals.add(interval);
    assertEquals("[{\"endingDocument\":{\"pn\":\"f6f4da8d93e88a08220e03b7810451d3ba540a34\",\"fn\":\"e4afa075bb910c8ecb427e9950426a4599b21d7e\",\"sloc\":1,\"dt\":\"un\"},\"diff\":4,\"modCountDiff\":0,\"charLengthDiff\":4,\"doc\":{\"pn\":\"f6f4da8d93e88a08220e03b7810451d3ba540a34\",\"fn\":\"e4afa075bb910c8ecb427e9950426a4599b21d7e\",\"sloc\":1,\"dt\":\"un\"},\"it\":\"ty\",\"ts\":1," + pasteWDVAndClient() + "}]", transferer.toJson(intervals));
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) TypingInterval(nl.tudelft.watchdog.core.logic.interval.intervaltypes.TypingInterval) EditorWrapper(nl.tudelft.watchdog.eclipse.logic.document.EditorWrapper) ArrayList(java.util.ArrayList) Document(nl.tudelft.watchdog.core.logic.document.Document) Date(java.util.Date) WatchDogItem(nl.tudelft.watchdog.core.logic.storage.WatchDogItem) Test(org.junit.Test)

Example 29 with WatchDogItem

use of nl.tudelft.watchdog.core.logic.storage.WatchDogItem in project watchdog by TestRoots.

the class IntervalJsonConverterTest method createSampleIntervals.

private ArrayList<WatchDogItem> createSampleIntervals(EditorIntervalBase interval) {
    interval.setDocument(new Document("Project", "Production.java", "filepath", "blah-document"));
    ArrayList<WatchDogItem> intervals = createSampleIntervals((IntervalBase) interval);
    return intervals;
}
Also used : Document(nl.tudelft.watchdog.core.logic.document.Document) WatchDogItem(nl.tudelft.watchdog.core.logic.storage.WatchDogItem)

Example 30 with WatchDogItem

use of nl.tudelft.watchdog.core.logic.storage.WatchDogItem in project watchdog by TestRoots.

the class IntervalPersisterTest method testInteraction.

private void testInteraction(int items) {
    List<IntervalBase> generatedIntervals = generateIntervalList(items);
    // Shuffle the generated intervals to test for
    // correct ordering of returned values
    Collections.shuffle(generatedIntervals);
    Collections.sort(generatedIntervals);
    for (IntervalBase intervalBase : generatedIntervals) {
        persister.save(intervalBase);
    }
    List<WatchDogItem> readIntervals = new ArrayList<WatchDogItem>(persister.readItems());
    assertEquals(readIntervals.size(), items);
    // Test order of returned results
    assertEquals(readIntervals, generatedIntervals);
}
Also used : IntervalBase(nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase) ArrayList(java.util.ArrayList) WatchDogItem(nl.tudelft.watchdog.core.logic.storage.WatchDogItem)

Aggregations

WatchDogItem (nl.tudelft.watchdog.core.logic.storage.WatchDogItem)43 Test (org.junit.Test)35 Date (java.util.Date)32 ArrayList (java.util.ArrayList)14 IntervalBase (nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase)10 Document (nl.tudelft.watchdog.core.logic.document.Document)6 BreakpointAddEvent (nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.BreakpointAddEvent)6 DebugEventBase (nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.DebugEventBase)6 TypingInterval (nl.tudelft.watchdog.core.logic.interval.intervaltypes.TypingInterval)6 EditorWrapper (nl.tudelft.watchdog.eclipse.logic.document.EditorWrapper)6 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)6 BreakpointChangeEvent (nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.BreakpointChangeEvent)5 EditorIntervalBase (nl.tudelft.watchdog.core.logic.interval.intervaltypes.EditorIntervalBase)5 BreakpointChangeType (nl.tudelft.watchdog.core.logic.breakpoint.BreakpointChangeType)4 EventBase (nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase)4 IDEOpenInterval (nl.tudelft.watchdog.core.logic.interval.intervaltypes.IDEOpenInterval)3 BreakpointRemoveEvent (nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.BreakpointRemoveEvent)1 DebugInterval (nl.tudelft.watchdog.core.logic.interval.intervaltypes.DebugInterval)1 ReadingInterval (nl.tudelft.watchdog.core.logic.interval.intervaltypes.ReadingInterval)1 JsonTransferer (nl.tudelft.watchdog.core.logic.network.JsonTransferer)1