<commit_before>package justin.db

import java.util.UUID

import justin.consistent_hashing.NodeId
import justin.vector_clocks.{Counter, VectorClock}
import org.scalatest.{FlatSpec, Matchers}

class DataTest extends FlatSpec with Matchers {

  behavior of "Data"

  it should "update its empty inner Vector Clock based on preference list" in {
    // given
    val preferenceList = List(NodeId(1), NodeId(5), NodeId(8))
    val data = Data(id = UUID.randomUUID(), value = "some value")

    // when
    val updatedData = Data.updateVclock(data, preferenceList)

    // then
    val expectedVclock = VectorClock[NodeId](Map(
      NodeId(1) -> Counter(1),
      NodeId(5) -> Counter(1),
      NodeId(8) -> Counter(1))
    )
    updatedData shouldBe Data(data.id, data.value, expectedVclock)
  }
}<commit_msg>add Data test: "increase vector clock's counter of repeated nodeId"<commit_after>package justin.db

import java.util.UUID

import justin.consistent_hashing.NodeId
import justin.vector_clocks.{Counter, VectorClock}
import org.scalatest.{FlatSpec, Matchers}

class DataTest extends FlatSpec with Matchers {

  behavior of "Data"

  it should "update its empty inner Vector Clock based on preference list" in {
    // given
    val preferenceList = List(NodeId(1), NodeId(5), NodeId(8))
    val data = Data(id = UUID.randomUUID(), value = "some value")

    // when
    val updatedData = Data.updateVclock(data, preferenceList)

    // then
    val expectedVclock = VectorClock[NodeId](Map(
      NodeId(1) -> Counter(1),
      NodeId(5) -> Counter(1),
      NodeId(8) -> Counter(1))
    )
    updatedData shouldBe Data(data.id, data.value, expectedVclock)
  }

  it should "increase vector clock's counter of repeated nodeId" in {
    // given
    val preferenceList = List(NodeId(1), NodeId(1), NodeId(1))

    val data = Data(id = UUID.randomUUID(), value = "some value")

    // when
    val updatedData = Data.updateVclock(data, preferenceList)

    // then
    val expectedVclock = VectorClock[NodeId](Map(
      NodeId(1) -> Counter(3)
    ))
    updatedData shouldBe Data(data.id, data.value, expectedVclock)
  }
}
{'fraction_non_alphanumeric': 0.11534839924670433, 'fraction_numerical': 0.010828625235404897, 'mean_word_length': 3.550321199143469, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '4662929', 'n_tokens_mistral': 699, 'n_tokens_neox': 673, 'n_words': 182}