<commit_before>package com.elpassion.mainframerplugin.task

import com.elpassion.mainframerplugin.util.toJson
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase
import com.nhaarman.mockito_kotlin.*
import org.jdom.Element
import org.junit.Assert

class MFBeforeRunTaskTest : LightPlatformCodeInsightFixtureTestCase() {
    val element = mock<Element>()

    fun testShouldReadDefaultValuesFromProviderWhenWasntSaveBefore() {
        val task = MFBeforeRunTask(data = MFTaskData())
        task.readExternal(element)

        Assert.assertEquals(MFBeforeTaskDefaultSettingsProvider.getInstance(project).taskData, task.data)
    }

    fun testShouldReadMFTaskDataFromJson() {
        val task = MFBeforeRunTask(data = MFTaskData())
        whenever(element.getAttributeValue(any())).thenReturn(MFTaskData(buildCommand = "b", mainframerPath = "p").toJson())
        task.readExternal(element)<commit_msg>[#119] Add setup method with stubbing MFBeforeTaskDefaultSettingsProvider to return empty MFTaskData<commit_after>package com.elpassion.mainframerplugin.task

import com.elpassion.mainframerplugin.util.toJson
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase
import com.nhaarman.mockito_kotlin.*
import org.jdom.Element
import org.junit.Assert

class MFBeforeRunTaskTest : LightPlatformCodeInsightFixtureTestCase() {
    val element = mock<Element>()

    override fun setUp() {
        super.setUp()
        MFBeforeTaskDefaultSettingsProvider.getInstance(project).taskData = MFTaskData()
    }

    fun testShouldReadDefaultValuesFromProviderWhenWasntSaveBefore() {
        val task = MFBeforeRunTask(data = MFTaskData())
        task.readExternal(element)

        Assert.assertEquals(MFBeforeTaskDefaultSettingsProvider.getInstance(project).taskData, task.data)
    }

    fun testShouldReadMFTaskDataFromJson() {
        val task = MFBeforeRunTask(data = MFTaskData())
        whenever(element.getAttributeValue(any())).thenReturn(MFTaskData(buildCommand = "b", mainframerPath = "p").toJson())
        task.readExternal(element)
{'fraction_non_alphanumeric': 0.09095238095238095, 'fraction_numerical': 0.0014285714285714286, 'mean_word_length': 5.215976331360947, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6021977', 'n_tokens_mistral': 609, 'n_tokens_neox': 593, 'n_words': 91}