<commit_before>package com.ubirch.avatar.util.model

import com.typesafe.scalalogging.slf4j.StrictLogging
import com.ubirch.avatar.model.DummyDevices
import com.ubirch.services.util.DeviceCoreUtil
import com.ubirch.util.json.MyJsonProtocol
import org.json4s.JValue
import org.json4s.native.Serialization.{read, write}
import org.scalatest.{FeatureSpec, Matchers}

import scala.concurrent.Await
import scala.concurrent.duration._

/**
  * Created by derMicha on 18/01/17.
  */
class DeviceUtilTest extends FeatureSpec
  with Matchers
  with StrictLogging
  with MyJsonProtocol {

  val device = DummyDevices.device1

  feature("DeviceUtil") {

    scenario("sign message") {

      val payload = read[JValue](
        """{"a":"b"}""".stripMargin
      )

      val (k, s) = DeviceUtil.sign(payload, device)

      val checkedD = DeviceCoreUtil.validateSignedMessage(device.hwDeviceId, k, s, payload)
      checkedD shouldBe true
    }

    scenario("sign empty message") {

      val payload = read[JValue]("")

      val (k, s) = DeviceUtil.sign(payload, device)

      val checkedD = DeviceCoreUtil.validateSignedMessage(device.hwDeviceId, k, s, payload)
      checkedD shouldBe true

    }

  }

}
<commit_msg>UBD-251: optimized imports<commit_after>package com.ubirch.avatar.util.model

import com.typesafe.scalalogging.slf4j.StrictLogging

import com.ubirch.avatar.model.DummyDevices
import com.ubirch.avatar.model.device.Device
import com.ubirch.services.util.DeviceCoreUtil
import com.ubirch.util.json.MyJsonProtocol

import org.json4s.JValue
import org.json4s.native.Serialization.read
import org.scalatest.{FeatureSpec, Matchers}

/**
  * Created by derMicha on 18/01/17.
  */
class DeviceUtilTest extends FeatureSpec
  with Matchers
  with StrictLogging
  with MyJsonProtocol {

  val device: Device = DummyDevices.device1

  feature("DeviceUtil") {

    scenario("sign message") {

      val payload = read[JValue](
        """{"a":"b"}""".stripMargin
      )

      val (k, s) = DeviceUtil.sign(payload, device)

      val checkedD = DeviceCoreUtil.validateSignedMessage(device.hwDeviceId, k, s, payload)
      checkedD shouldBe true
    }

    scenario("sign empty message") {

      val payload = read[JValue]("")

      val (k, s) = DeviceUtil.sign(payload, device)

      val checkedD = DeviceCoreUtil.validateSignedMessage(device.hwDeviceId, k, s, payload)
      checkedD shouldBe true

    }

  }

}

{'fraction_non_alphanumeric': 0.10839884153909805, 'fraction_numerical': 0.009515928837401738, 'mean_word_length': 3.695145631067961, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '2497934', 'n_tokens_mistral': 823, 'n_tokens_neox': 791, 'n_words': 162}