<commit_before>package justin.db.storage

import java.util.UUID

import justin.db.Data
import justin.db.storage.PluggableStorageProtocol.{Ack, StorageGetData, StoragePutData}
import org.scalatest.{FlatSpec, Matchers}

import scala.concurrent.Await
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
import language.postfixOps

class InMemStorageTest extends FlatSpec with Matchers {

  behavior of "In-memory storage"

  it should "store single data" in {
    // given
    val data = StoragePutData.Single(Data(id = UUID.randomUUID(), "some-data"))
    val inMemStorage = new InMemStorage

    // when
    val result = Await.result(inMemStorage.put(data), atMost = 5 seconds)

    // then
    result shouldBe Ack
  }

  it should "store conflicted data" in {
    // given
    val id = UUID.randomUUID()
    val data = StoragePutData.Conflict(id, Data(id, "some-data-1"), Data(id, "some-data-2"))
    val inMemStorage = new InMemStorage

    // when
    val result = Await.result(inMemStorage.put(data), atMost = 5 seconds)

    // then
    result shouldBe Ack
  }

  it should "get single data for appropriate identificator" in {
    // given
    val data = StoragePutData.Single(Data(id = UUID.randomUUID(), "some-data"))
    val inMemStorage = new InMemStorage
    Await.result(inMemStorage.put(data), atMost = 5 seconds)

    // when
    val result = Await.result(inMemStorage.get(data.data.id), atMost = 5 seconds)

    // then
    result shouldBe StorageGetData.Single(data.data)
  }
}<commit_msg>test In-memory storage scenario: "get none data for not existing id in memory"<commit_after>package justin.db.storage

import java.util.UUID

import justin.db.Data
import justin.db.storage.PluggableStorageProtocol.{Ack, StorageGetData, StoragePutData}
import org.scalatest.{FlatSpec, Matchers}

import scala.concurrent.Await
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
import language.postfixOps

class InMemStorageTest extends FlatSpec with Matchers {

  behavior of "In-memory storage"

  it should "store single data" in {
    // given
    val data = StoragePutData.Single(Data(id = UUID.randomUUID(), "some-data"))
    val inMemStorage = new InMemStorage

    // when
    val result = Await.result(inMemStorage.put(data), atMost = 5 seconds)

    // then
    result shouldBe Ack
  }

  it should "store conflicted data" in {
    // given
    val id = UUID.randomUUID()
    val data = StoragePutData.Conflict(id, Data(id, "some-data-1"), Data(id, "some-data-2"))
    val inMemStorage = new InMemStorage

    // when
    val result = Await.result(inMemStorage.put(data), atMost = 5 seconds)

    // then
    result shouldBe Ack
  }

  it should "get single data for appropriate identificator" in {
    // given
    val data = StoragePutData.Single(Data(id = UUID.randomUUID(), "some-data"))
    val inMemStorage = new InMemStorage
    Await.result(inMemStorage.put(data), atMost = 5 seconds)

    // when
    val result = Await.result(inMemStorage.get(data.data.id), atMost = 5 seconds)

    // then
    result shouldBe StorageGetData.Single(data.data)
  }

  it should "get none data for not existing id in memory" in {
    // given
    val noExistingId = UUID.randomUUID()
    val inMemStorage = new InMemStorage

    // when
    val result = Await.result(inMemStorage.get(noExistingId), atMost = 5 seconds)

    // then
    result shouldBe StorageGetData.None
  }
}
{'fraction_non_alphanumeric': 0.10251227259601502, 'fraction_numerical': 0.003753970545769564, 'mean_word_length': 3.435339308578745, 'pattern_counts': {'":': 0, '<': 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': '3319473', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1085, 'n_words': 291}