<commit_before>package steps

import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import com.qingstor.sdk.config.QSConfig
import cucumber.api.java8.En
import com.qingstor.sdk.service.QingStor
import com.qingstor.sdk.service.QingStor._
import TestUtil.TestConfig
import cucumber.runtime.java.picocontainer.PicoFactory

import scala.concurrent.{Await, ExecutionContextExecutor}
import scala.concurrent.duration.Duration

class QingStorTest(dep: QingStorDependency) extends En {
  implicit val system = ActorSystem()
  implicit val mat = ActorMaterializer()
  implicit val ec: ExecutionContextExecutor = system.dispatcher
  private val qingStorDependency = dep

//  private var config: QSConfig = _
//  private var testConfig: TestConfig = _
//  private var qingStor: QingStor = _
//  private var listBucketsOutput: ListBucketsOutput = _

  Given("^need to use QingStor service$", () => {
    qingStorDependency.config = TestUtil.getQSConfig
    qingStorDependency.testConfig = TestUtil.getTestConfig
    assert(qingStorDependency.config != null)
    assert(qingStorDependency.testConfig != null)
  })

  When("^initialize QingStor service$", () => {
    qingStorDependency.qingStor = QingStor(qingStorDependency.config)
  })

  Then("^the QingStor service is initialized$", () => {
    assert(qingStorDependency.qingStor != null)
  })

  When("^list buckets$", () => {
    val input = ListBucketsInput(Option(qingStorDependency.testConfig.zone))
    qingStorDependency.listBucketsOutput = Await.result(qingStorDependency.qingStor.listBuckets(input), Duration.Inf)
    assert(qingStorDependency.listBucketsOutput != null)
  })

  Then("^list buckets status code is (\\d+)$", (status: Int) => {
    assert(qingStorDependency.listBucketsOutput.statusCode.getOrElse(0) == status)
  })

}<commit_msg>test for service.feature done<commit_after>package steps

import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import com.qingstor.sdk.config.QSConfig
import cucumber.api.java8.En
import com.qingstor.sdk.service.QingStor
import com.qingstor.sdk.service.QingStor._
import TestUtil.TestConfig

import scala.concurrent.{Await, ExecutionContextExecutor}
import scala.concurrent.duration.Duration

class QingStorSteps extends En {
  implicit val system = ActorSystem()
  implicit val mat = ActorMaterializer()
  implicit val ec: ExecutionContextExecutor = system.dispatcher

  private var config: QSConfig = _
  private var testConfig: TestConfig = _
  private var qingStor: QingStor = _
  private var listBucketsOutput: ListBucketsOutput = _

  When("^initialize QingStor service$", () => {
    config = TestUtil.getQSConfig
    testConfig = TestUtil.getTestConfig
    qingStor = QingStor(config)
  })

  Then("^the QingStor service is initialized$", () => {
    if (qingStor == null)
      throw new NullPointerException("QingStor service is not initialized")
  })

  When("^list buckets$", () => {
    config = TestUtil.getQSConfig
    testConfig = TestUtil.getTestConfig
    qingStor = QingStor(config)
    val input = ListBucketsInput(Option(testConfig.zone))
    listBucketsOutput = Await.result(qingStor.listBuckets(input), Duration.Inf)
  })

  Then("^list buckets status code is (\\d+)$", (status: Integer) => {
    assert(int2Integer(listBucketsOutput.statusCode.getOrElse(0)) == status)
  })

}
{'fraction_non_alphanumeric': 0.10626128838049367, 'fraction_numerical': 0.0015051173991571343, 'mean_word_length': 4.902309058614565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '5605243', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1051, 'n_words': 211}