<commit_before>package io.github.crabzilla.pgclient.projection

import io.github.crabzilla.core.EventTopics
import io.github.crabzilla.core.json.JsonSerDer
import io.github.crabzilla.example1.example1Json
import io.github.crabzilla.json.KotlinJsonSerDer
import io.github.crabzilla.pgclient.TestRepository
import io.github.crabzilla.pgclient.command.cleanDatabase
import io.github.crabzilla.pgclient.command.config
import io.github.crabzilla.pgclient.command.pgPool
import io.vertx.core.Vertx
import io.vertx.core.json.JsonObject
import io.vertx.junit5.VertxExtension
import io.vertx.junit5.VertxTestContext
import io.vertx.pgclient.PgPool
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith

@ExtendWith(VertxExtension::class)
@DisplayName("Forcing projector to be greedy")
class GreedyProjectionIT {

  lateinit var jsonSerDer: JsonSerDer
  lateinit var pgPool: PgPool
  private lateinit var testRepo: TestRepository

  @BeforeEach
  fun setup(vertx: Vertx, tc: VertxTestContext) {
    jsonSerDer = KotlinJsonSerDer(example1Json)
    pgPool = pgPool(vertx)
    testRepo = TestRepository(pgPool)
    cleanDatabase(pgPool)
      .compose {
        vertx.deployProjector(
          config, "service:crabzilla.example1.customer.CustomersSlowEventsProjector"
        )
      }
      .onFailure { tc.failNow(it) }
      .onSuccess { tc.completeNow() }
  }

  @Test
  @DisplayName("forcing it starting greedy then sending a command the events will be projected")
  fun a0(tc: VertxTestContext, vertx: Vertx) {
    val target = "crabzilla.example1.customer.CustomersSlowEventsProjector"
    pgPool
      .preparedQuery("NOTIFY " + EventTopics.STATE_TOPIC.name.lowercase() + ", 'Customer'")
      .execute()
      .compose {
        vertx.eventBus().request<JsonObject>("crabzilla.projectors.$target.status", null)
      }.onSuccess {
        println(it.body().encodePrettily())
        if (it.body().getBoolean("greedy")) {
          tc.completeNow()
        } else {
          tc.failNow("Status should be greedy")
        }
      }
  }
}<commit_msg>test fix<commit_after>package io.github.crabzilla.pgclient.projection

import io.github.crabzilla.core.EventTopics
import io.github.crabzilla.core.json.JsonSerDer
import io.github.crabzilla.example1.example1Json
import io.github.crabzilla.json.KotlinJsonSerDer
import io.github.crabzilla.pgclient.TestRepository
import io.github.crabzilla.pgclient.command.cleanDatabase
import io.github.crabzilla.pgclient.command.config
import io.github.crabzilla.pgclient.command.pgPool
import io.vertx.core.Vertx
import io.vertx.core.json.JsonObject
import io.vertx.junit5.VertxExtension
import io.vertx.junit5.VertxTestContext
import io.vertx.pgclient.PgPool
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith

@ExtendWith(VertxExtension::class)
@DisplayName("Forcing projector to be greedy")
class GreedyProjectionIT {

  lateinit var jsonSerDer: JsonSerDer
  lateinit var pgPool: PgPool
  private lateinit var testRepo: TestRepository

  @BeforeEach
  fun setup(vertx: Vertx, tc: VertxTestContext) {
    jsonSerDer = KotlinJsonSerDer(example1Json)
    pgPool = pgPool(vertx)
    testRepo = TestRepository(pgPool)
    cleanDatabase(pgPool)
      .compose {
        vertx.deployProjector(
          config, "service:crabzilla.example1.customer.CustomersSlowEventsProjector"
        )
      }
      .onFailure { tc.failNow(it) }
      .onSuccess { tc.completeNow() }
  }

  @Test
  @DisplayName("forcing it starting greedy then sending a command the events will be projected")
  fun a0(tc: VertxTestContext, vertx: Vertx) {
    val target = "crabzilla.example1.customer.CustomersSlowEventsProjector"
    pgPool
      .preparedQuery("NOTIFY " + EventTopics.STATE_TOPIC.name.lowercase() + ", 'Customer'")
      .execute()
      .compose {
        Thread.sleep(500)
        vertx.eventBus().request<JsonObject>("crabzilla.projectors.$target.status", null)
      }.onSuccess {
        println(it.body().encodePrettily())
        if (it.body().getBoolean("greedy")) {
          tc.completeNow()
        } else {
          tc.failNow("Status should be greedy")
        }
      }
  }
}
{'fraction_non_alphanumeric': 0.10449826989619378, 'fraction_numerical': 0.004382929642445213, 'mean_word_length': 3.893905191873589, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7397081', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1396, 'n_words': 238}