<commit_before>/*
 * FXGL - JavaFX Game Library. The MIT License (MIT).
 * Copyright (c) AlmasB (<EMAIL>).
 * See LICENSE for details.
 */

package com.almasb.fxgl.cutscene.dialogue

import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
import org.junit.jupiter.api.Test

/**
 *
 * @author <NAME> (<EMAIL>)
 */
class SerializableDialogueGraphTest {

    @Test
    fun `Serialization to and from`() {
        val start = StartNode("test start")
        val choice = ChoiceNode("test choice")
        val function = FunctionNode("test function")
        val end = EndNode("test end")

        val graph = DialogueGraph()
        graph.addNode(start)
        graph.addNode(choice)
        graph.addNode(function)
        graph.addNode(end)

        val sGraph = DialogueGraphSerializer.toSerializable(graph)

        val copy = DialogueGraphSerializer.fromSerializable(sGraph)

        assertThat(copy.uniqueID, `is`(graph.uniqueID))
        assertThat(copy.nodes.mapValues { it.toString() }, `is`(graph.nodes.mapValues { it.toString() }))
        assertThat(copy.edges.map { it.toString() }, `is`(graph.edges.map { it.toString() }))
    }
}<commit_msg>added test edges<commit_after>/*
 * FXGL - JavaFX Game Library. The MIT License (MIT).
 * Copyright (c) AlmasB (<EMAIL>).
 * See LICENSE for details.
 */

package com.almasb.fxgl.cutscene.dialogue

import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
import org.junit.jupiter.api.Test

/**
 *
 * @author <NAME> (<EMAIL>)
 */
class SerializableDialogueGraphTest {

    @Test
    fun `Serialization to and from`() {
        val start = StartNode("test start")
        val choice = ChoiceNode("test choice")
        val function = FunctionNode("test function")
        val end = EndNode("test end")

        val graph = DialogueGraph()
        graph.addNode(start)
        graph.addNode(choice)
        graph.addNode(function)
        graph.addNode(end)

        graph.addEdge(start, choice)
        graph.addChoiceEdge(choice, 0, function)
        graph.addChoiceEdge(choice, 1, end)
        graph.addEdge(function, end)

        val sGraph = DialogueGraphSerializer.toSerializable(graph)

        val copy = DialogueGraphSerializer.fromSerializable(sGraph)

        assertThat(copy.uniqueID, `is`(graph.uniqueID))
        assertThat(copy.nodes.mapValues { it.toString() }, `is`(graph.nodes.mapValues { it.toString() }))

        val edges1 = graph.edges.map { it.toString() }
        val edges2 = copy.edges.map { it.toString() }

        assertThat(edges1, containsInAnyOrder(*edges2.toTypedArray()))
    }
}
{'fraction_non_alphanumeric': 0.12920696324951644, 'fraction_numerical': 0.0023210831721470018, 'mean_word_length': 3.0093023255813955, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '145474', 'n_tokens_mistral': 800, 'n_tokens_neox': 784, 'n_words': 168}