<commit_before>/*
 * Copyright (c) 2021 toastkidjp.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompany this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html.
 */

package jp.toastkid.yobidashi.browser.translate

import android.net.Uri
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.InjectMockKs
import io.mockk.impl.annotations.MockK
import io.mockk.mockk
import io.mockk.mockkStatic
import io.mockk.unmockkAll
import io.mockk.verify
import jp.toastkid.lib.BrowserViewModel
import org.junit.After
import org.junit.Before
import org.junit.Test

/**
 * @author toastkidjp
 */
class TranslatedPageOpenerUseCaseTest {

    @InjectMockKs
    private lateinit var translatedPageOpenerUseCase: TranslatedPageOpenerUseCase

    @MockK
    private lateinit var browserViewModel: BrowserViewModel

    @Before
    fun setUp() {
        MockKAnnotations.init(this)
        every { browserViewModel.open(any()) }.returns(Unit)

        mockkStatic(Uri::class)
        every { Uri.encode(any()) }.returns("https://www.yahoo.co.jp")
        every { Uri.parse(any()) }.returns(mockk())
    }

    @After
    fun tearDown() {
        unmockkAll()
    }

    @Test
    fun invoke() {
        translatedPageOpenerUseCase.invoke("https://www.yahoo.co.jp")

        verify(exactly = 1) { browserViewModel.open(any()) }
        verify(exactly = 1) { Uri.encode(any()) }
        verify(exactly = 1) { Uri.parse(any()) }
    }

}<commit_msg>refactor #559 Rename test function.<commit_after>/*
 * Copyright (c) 2021 toastkidjp.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompany this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html.
 */

package jp.toastkid.yobidashi.browser.translate

import android.net.Uri
import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.InjectMockKs
import io.mockk.impl.annotations.MockK
import io.mockk.mockk
import io.mockk.mockkStatic
import io.mockk.unmockkAll
import io.mockk.verify
import jp.toastkid.lib.BrowserViewModel
import org.junit.After
import org.junit.Before
import org.junit.Test

/**
 * @author toastkidjp
 */
class TranslatedPageOpenerUseCaseTest {

    @InjectMockKs
    private lateinit var translatedPageOpenerUseCase: TranslatedPageOpenerUseCase

    @MockK
    private lateinit var browserViewModel: BrowserViewModel

    @Before
    fun setUp() {
        MockKAnnotations.init(this)
        every { browserViewModel.open(any()) }.returns(Unit)

        mockkStatic(Uri::class)
        every { Uri.encode(any()) }.returns("https://www.yahoo.co.jp")
        every { Uri.parse(any()) }.returns(mockk())
    }

    @After
    fun tearDown() {
        unmockkAll()
    }

    @Test
    fun testInvoke() {
        translatedPageOpenerUseCase.invoke("https://www.yahoo.co.jp")

        verify(exactly = 1) { browserViewModel.open(any()) }
        verify(exactly = 1) { Uri.encode(any()) }
        verify(exactly = 1) { Uri.parse(any()) }
    }

}
{'fraction_non_alphanumeric': 0.11138310893512852, 'fraction_numerical': 0.007649938800489596, 'mean_word_length': 3.441576086956522, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 6, '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': '835225', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1005, 'n_words': 230}