Search in sources :

Example 1 with TypingInterval

use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.TypingInterval in project watchdog by TestRoots.

the class IntervalJsonConverterTest method testJsonTypingIntervalDiffsModification.

@Test
public void testJsonTypingIntervalDiffsModification() {
    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-documens"));
    interval.close();
    sleepABit();
    ArrayList<WatchDogItem> intervals = new ArrayList<>();
    intervals.add(interval);
    assertEquals("[{\"endingDocument\":{\"pn\":\"f6f4da8d93e88a08220e03b7810451d3ba540a34\",\"fn\":\"e4afa075bb910c8ecb427e9950426a4599b21d7e\",\"sloc\":1,\"dt\":\"un\"},\"diff\":1,\"modCountDiff\":0,\"charLengthDiff\":0,\"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 2 with TypingInterval

use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.TypingInterval in project watchdog by TestRoots.

the class IDEIntervalManagerBase method closeInterval.

private void closeInterval(IntervalBase interval) {
    if (interval == null) {
        return;
    }
    if (interval instanceof TypingInterval) {
        TypingInterval typingInterval = (TypingInterval) interval;
        setEndingDocumentOf(typingInterval);
    }
    interval.close();
    if (interval instanceof EditorIntervalBase) {
        editorInterval = null;
    } else {
        intervals.remove(interval);
    }
    intervalsToTransferPersister.save(interval);
    intervalsStatisticsPersister.save(interval);
    WatchDogLogger.getInstance().logInfo("closed interval " + interval + " " + interval.getType());
}
Also used : EditorIntervalBase(nl.tudelft.watchdog.core.logic.interval.intervaltypes.EditorIntervalBase) TypingInterval(nl.tudelft.watchdog.core.logic.interval.intervaltypes.TypingInterval)

Example 3 with TypingInterval

use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.TypingInterval in project watchdog by TestRoots.

the class IntervalJsonConverterTest method testJsonTypingIntervalTwoSameIntervalsRepresentation.

/**
 * Tests the format of the returned Json representation.
 */
@Test
public void testJsonTypingIntervalTwoSameIntervalsRepresentation() {
    ITextEditor editor = Mockito.mock(ITextEditor.class);
    TypingInterval interval = new TypingInterval(new EditorWrapper(editor), new Date());
    interval.setDocument(new Document("Project", "filepath", "Production.java", "blah-document"));
    interval.setEndingDocument(new Document("Project", "Production.java", "filepath", "blah-document"));
    ArrayList<WatchDogItem> intervals = createSampleIntervals(interval);
    assertEquals("[{\"endingDocument\":{\"pn\":\"f6f4da8d93e88a08220e03b7810451d3ba540a34\",\"fn\":\"90a8834de76326869f3e703cd61513081ad73d3c\",\"sloc\":1,\"dt\":\"pr\"},\"diff\":0,\"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) 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 4 with TypingInterval

use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.TypingInterval in project watchdog by TestRoots.

the class IntervalJsonConverterTest method testJsonTypingIntervalDiffsNoChanges.

@Test
public void testJsonTypingIntervalDiffsNoChanges() {
    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"));
    interval.close();
    sleepABit();
    ArrayList<WatchDogItem> intervals = new ArrayList<>();
    intervals.add(interval);
    assertEquals("[{\"endingDocument\":{\"pn\":\"f6f4da8d93e88a08220e03b7810451d3ba540a34\",\"fn\":\"e4afa075bb910c8ecb427e9950426a4599b21d7e\",\"sloc\":1,\"dt\":\"un\"},\"diff\":0,\"modCountDiff\":0,\"charLengthDiff\":0,\"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 5 with TypingInterval

use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.TypingInterval 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)

Aggregations

TypingInterval (nl.tudelft.watchdog.core.logic.interval.intervaltypes.TypingInterval)7 Date (java.util.Date)6 WatchDogItem (nl.tudelft.watchdog.core.logic.storage.WatchDogItem)6 EditorWrapper (nl.tudelft.watchdog.eclipse.logic.document.EditorWrapper)6 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)6 Test (org.junit.Test)6 Document (nl.tudelft.watchdog.core.logic.document.Document)5 ArrayList (java.util.ArrayList)4 EditorIntervalBase (nl.tudelft.watchdog.core.logic.interval.intervaltypes.EditorIntervalBase)1