Search in sources :

Example 6 with EnrichedSessionState

use of io.github.vocabhunter.analysis.session.EnrichedSessionState in project VocabHunter by VocabHunter.

the class GuiTest method validateSavedSession.

@Override
public void validateSavedSession(final Path file, final String name) {
    EnrichedSessionState state = SessionSerialiser.read(file);
    assertEquals("Session state name", name, state.getState().getName());
}
Also used : EnrichedSessionState(io.github.vocabhunter.analysis.session.EnrichedSessionState)

Example 7 with EnrichedSessionState

use of io.github.vocabhunter.analysis.session.EnrichedSessionState in project VocabHunter by VocabHunter.

the class GuiFileHandler method processOpenSession.

private void processOpenSession() {
    Path file = checkUnsavedChangesAndChooseFile(FileDialogueType.OPEN_SESSION);
    if (file == null) {
        statusManager.completeAction();
    } else {
        statusManager.performAction(file);
        LOG.info("Opening session file '{}'", file);
        GuiTask<EnrichedSessionState> task = new GuiTask<>(guiTaskHandler, statusManager, () -> sessionFileService.read(file), this::finishOpen, e -> FileErrorTool.open(file, e));
        guiTaskHandler.executeInBackground(task);
    }
}
Also used : Path(java.nio.file.Path) GuiTask(io.github.vocabhunter.gui.status.GuiTask) EnrichedSessionState(io.github.vocabhunter.analysis.session.EnrichedSessionState)

Example 8 with EnrichedSessionState

use of io.github.vocabhunter.analysis.session.EnrichedSessionState in project VocabHunter by VocabHunter.

the class FileStreamerTest method testEqualSession.

@Test
public void testEqualSession() {
    EnrichedSessionState state1 = createNewSession(FILE_TEXT);
    EnrichedSessionState state2 = createNewSession(FILE_TEXT);
    assertEquals("Equal session", state1, state2);
}
Also used : EnrichedSessionState(io.github.vocabhunter.analysis.session.EnrichedSessionState) Test(org.junit.Test)

Example 9 with EnrichedSessionState

use of io.github.vocabhunter.analysis.session.EnrichedSessionState in project VocabHunter by VocabHunter.

the class FileStreamerTest method validateSession.

private void validateSession(final String fileName, final String sessionName, final Function<String, EnrichedSessionState> targetMethod) {
    EnrichedSessionState session = targetMethod.apply(fileName);
    assertEquals("Session name", sessionName, session.getState().getName());
}
Also used : EnrichedSessionState(io.github.vocabhunter.analysis.session.EnrichedSessionState)

Example 10 with EnrichedSessionState

use of io.github.vocabhunter.analysis.session.EnrichedSessionState in project VocabHunter by VocabHunter.

the class GuiFileHandler method finishOpen.

private void finishOpen(final EnrichedSessionState enrichedState) {
    SessionState state = enrichedState.getState();
    SessionModel sessionModel = sessionStateHandler.addSession(state);
    model.replaceSessionModel(state, sessionModel, enrichedState.getFile().orElse(null));
    statusManager.replaceSession(sessionModel.getPosition(), sessionModel.getProgress());
}
Also used : SessionState(io.github.vocabhunter.analysis.session.SessionState) EnrichedSessionState(io.github.vocabhunter.analysis.session.EnrichedSessionState) SessionModel(io.github.vocabhunter.gui.model.SessionModel)

Aggregations

EnrichedSessionState (io.github.vocabhunter.analysis.session.EnrichedSessionState)10 Test (org.junit.Test)4 Path (java.nio.file.Path)3 SessionState (io.github.vocabhunter.analysis.session.SessionState)2 GuiTask (io.github.vocabhunter.gui.status.GuiTask)2 Analyser (io.github.vocabhunter.analysis.model.Analyser)1 SimpleAnalyser (io.github.vocabhunter.analysis.simple.SimpleAnalyser)1 SessionModel (io.github.vocabhunter.gui.model.SessionModel)1 URL (java.net.URL)1 BeforeClass (org.junit.BeforeClass)1