<commit_before>/*
 * Copyright (c) 2019 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.main.launch

import android.net.Uri
import jp.toastkid.lib.ContentViewModel
import jp.toastkid.yobidashi.R
import jp.toastkid.yobidashi.libs.Toaster
import jp.toastkid.yobidashi.wikipedia.random.RandomWikipedia

/**
 * @author toastkidjp
 */
class RandomWikipediaUseCase(
        private val contentViewModel: ContentViewModel?,
        private val openNewWebTab: (Uri) -> Unit,
        private val stringFinder: (Int, String) -> String
) {

    operator fun invoke() {
        RandomWikipedia().fetchWithAction { title, uri ->
            openNewWebTab(uri)
            contentViewModel?.snackShort(stringFinder(R.string.message_open_random_wikipedia, title))
        }
    }
}<commit_msg>refactor #605 Modify constractor for writeable test case.<commit_after>/*
 * Copyright (c) 2019 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.main.launch

import android.net.Uri
import jp.toastkid.lib.ContentViewModel
import jp.toastkid.yobidashi.R
import jp.toastkid.yobidashi.wikipedia.random.RandomWikipedia

/**
 * @author toastkidjp
 */
class RandomWikipediaUseCase(
        private val contentViewModel: ContentViewModel?,
        private val openNewWebTab: (Uri) -> Unit,
        private val stringFinder: (Int, String) -> String,
        private val randomWikipedia: RandomWikipedia = RandomWikipedia()
) {

    operator fun invoke() {
        randomWikipedia.fetchWithAction { title, uri ->
            openNewWebTab(uri)
            contentViewModel?.snackShort(stringFinder(R.string.message_open_random_wikipedia, title))
        }
    }
}
{'fraction_non_alphanumeric': 0.09111933395004625, 'fraction_numerical': 0.008788159111933395, 'mean_word_length': 3.6516129032258067, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4558081', 'n_tokens_mistral': 674, 'n_tokens_neox': 620, 'n_words': 166}