<commit_before>/**
 * Copyright 2017 Yahoo Inc. Licensed under the Apache License, Version 2.0
 * See accompanying LICENSE file.
 */
package kafka.manager.model

import org.scalatest.FunSuite

/**
  * @author fuji-151a
  */
class KafkaVersionTest extends FunSuite {

  test("apply method: supported version.") {
    val expected: Map[String, KafkaVersion] = Map(
      "0.8.1.1" -> Kafka_0_8_1_1,
      "0.8.2-beta" -> Kafka_0_8_2_0,
      "0.8.2.0" -> Kafka_0_8_2_0,
      "0.8.2.1" -> Kafka_0_8_2_1,
      "0.8.2.2" -> Kafka_0_8_2_2,
      "0.9.0.0" -> Kafka_0_9_0_0,
      "0.9.0.1" -> Kafka_0_9_0_1,
      "0.10.0.0" -> Kafka_0_10_0_0,
      "0.10.0.1" -> Kafka_0_10_0_1,
      "0.10.1.0" -> Kafka_0_10_1_0,
      "0.10.1.1" -> Kafka_0_10_1_1,
      "0.10.2.0" -> Kafka_0_10_2_0,
      "0.10.2.1" -> Kafka_0_10_2_1
    )
    expected.foreach(v => assertResult(v._2)(KafkaVersion(v._1)))
  }

  test("apply method: Not supported version.") {
    val expected: String = "0.7.0.0"
    intercept[IllegalArgumentException] {
      KafkaVersion(expected)
    }
  }

  test("check supportedVersions") {
    val expected: Map[String, KafkaVersion] = Map(
      "0.8.1.1" -> Kafka_0_8_1_1,
      "0.8.2-beta" -> Kafka_0_8_2_0,
      "0.8.2.0" -> Kafka_0_8_2_0,
      "0.8.2.1" -> Kafka_0_8_2_1,
      "0.8.2.2" -> Kafka_0_8_2_2,
      "0.9.0.0" -> Kafka_0_9_0_0,
      "0.9.0.1" -> Kafka_0_9_0_1,
      "0.10.0.0" -> Kafka_0_10_0_0,
      "0.10.0.1" -> Kafka_0_10_0_1,
      "0.10.1.0" -> Kafka_0_10_1_0,
      "0.10.1.1" -> Kafka_0_10_1_1,
      "0.10.2.0" -> Kafka_0_10_2_0,
      "0.10.2.1" -> Kafka_0_10_2_1
    )
    assertResult(expected)(KafkaVersion.supportedVersions)
  }

  test("Sort formSelectList") {
    val expected: IndexedSeq[(String,String)] = Vector(
      ("0.8.1.1","0.8.1.1"),
      ("0.8.2.0","0.8.2.0"),
      ("0.8.2.1","0.8.2.1"),
      ("0.8.2.2","0.8.2.2"),
      ("0.9.0.0","0.9.0.0"),
      ("0.9.0.1","0.9.0.1"),
      ("0.10.0.0","0.10.0.0"),
      ("0.10.0.1","0.10.0.1"),
      ("0.10.1.0","0.10.1.0"),
      ("0.10.1.1","0.10.1.1"),
      ("0.10.2.0","0.10.2.0"),
      ("0.10.2.1","0.10.2.1")
    )
    assertResult(expected)(KafkaVersion.formSelectList)
  }

  test("unapply") {
    val expected: Map[String, KafkaVersion] = Map(
      "0.8.1.1" -> Kafka_0_8_1_1,
      "0.8.2-beta" -> Kafka_0_8_2_0,
      "0.8.2.0" -> Kafka_0_8_2_0,
      "0.8.2.1" -> Kafka_0_8_2_1,
      "0.8.2.2" -> Kafka_0_8_2_2,
      "0.9.0.0" -> Kafka_0_9_0_0,
      "0.9.0.1" -> Kafka_0_9_0_1,
      "0.10.0.0" -> Kafka_0_10_0_0,
      "0.10.0.1" -> Kafka_0_10_0_1,
      "0.10.1.0" -> Kafka_0_10_1_0,
      "0.10.1.1" -> Kafka_0_10_1_1,
      "0.10.2.0" -> Kafka_0_10_2_0,
      "0.10.2.1" -> Kafka_0_10_2_1
    )
    expected.filterNot(_._1.contains("beta")).foreach(v => assertResult(Some(v._1))(KafkaVersion.unapply(v._2)))
  }
}<commit_msg>added private val for refactoring.<commit_after>/**
 * Copyright 2017 Yahoo Inc. Licensed under the Apache License, Version 2.0
 * See accompanying LICENSE file.
 */
package kafka.manager.model

import org.scalatest.FunSuite

/**
  * @author fuji-151a
  */
class KafkaVersionTest extends FunSuite {

  private val kafkaVersionMap: Map[String, KafkaVersion] = Map(
    "0.8.1.1" -> Kafka_0_8_1_1,
    "0.8.2-beta" -> Kafka_0_8_2_0,
    "0.8.2.0" -> Kafka_0_8_2_0,
    "0.8.2.1" -> Kafka_0_8_2_1,
    "0.8.2.2" -> Kafka_0_8_2_2,
    "0.9.0.0" -> Kafka_0_9_0_0,
    "0.9.0.1" -> Kafka_0_9_0_1,
    "0.10.0.0" -> Kafka_0_10_0_0,
    "0.10.0.1" -> Kafka_0_10_0_1,
    "0.10.1.0" -> Kafka_0_10_1_0,
    "0.10.1.1" -> Kafka_0_10_1_1,
    "0.10.2.0" -> Kafka_0_10_2_0,
    "0.10.2.1" -> Kafka_0_10_2_1
  )

  test("apply method: supported version.") {
    kafkaVersionMap.foreach(v => assertResult(v._2)(KafkaVersion(v._1)))
  }

  test("apply method: Not supported version.") {
    val expected: String = "0.7.0.0"
    intercept[IllegalArgumentException] {
      KafkaVersion(expected)
    }
  }

  test("check supportedVersions") {
    assertResult(kafkaVersionMap)(KafkaVersion.supportedVersions)
  }

  test("Sort formSelectList") {
    val expected: IndexedSeq[(String,String)] = Vector(
      ("0.8.1.1","0.8.1.1"),
      ("0.8.2.0","0.8.2.0"),
      ("0.8.2.1","0.8.2.1"),
      ("0.8.2.2","0.8.2.2"),
      ("0.9.0.0","0.9.0.0"),
      ("0.9.0.1","0.9.0.1"),
      ("0.10.0.0","0.10.0.0"),
      ("0.10.0.1","0.10.0.1"),
      ("0.10.1.0","0.10.1.0"),
      ("0.10.1.1","0.10.1.1"),
      ("0.10.2.0","0.10.2.0"),
      ("0.10.2.1","0.10.2.1")
    )
    assertResult(expected)(KafkaVersion.formSelectList)
  }

  test("unapply") {
    kafkaVersionMap.filterNot(_._1.contains("beta")).foreach(v => assertResult(Some(v._1))(KafkaVersion.unapply(v._2)))
  }
}
{'fraction_non_alphanumeric': 0.22059447983014863, 'fraction_numerical': 0.15116772823779193, 'mean_word_length': 2.3746418338108883, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 98, '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': '5993380', 'n_tokens_mistral': 2439, 'n_tokens_neox': 2336, 'n_words': 265}