<commit_before>package com.jvm_bloggers.facebook.client.kafka

import com.fasterxml.jackson.databind.ObjectMapper
import com.github.charithe.kafka.EphemeralKafkaBroker
import com.github.charithe.kafka.KafkaJunitRule
import com.jvm_bloggers.facebook.client.NewIssuePublishedData
import com.jvm_bloggers.facebook.client.fb.FacebookPublisher
import groovy.util.logging.Slf4j
import org.junit.Rule
import spock.lang.Specification
import spock.util.concurrent.BlockingVariable

@Slf4j
class KafkaSpec extends Specification {

    @Rule
    public KafkaJunitRule kafkaRule = new KafkaJunitRule(EphemeralKafkaBroker.create(9092, 2181));

    FacebookPublisher facebookPublisher = Mock(FacebookPublisher)

    def "should do kafka"() {
        given:
            NewIssuePublishedData data = new NewIssuePublishedData(55, "http://jvm-bloggers.com/")
            String issueData = new ObjectMapper().writeValueAsString(data)
        and:
            def awaitForPublisher = new BlockingVariable<Boolean>(1)
            facebookPublisher.publishPost(_) >> { arguments ->
                log.info("Issue data captured: " + arguments[0])
                awaitForPublisher.set(true)
            }
        and:
            new KafkaConsumer(facebookPublisher).run()
        when:
            kafkaRule.helper().produceStrings("com.jvm_bloggers.issue.published", issueData)
        then:
            awaitForPublisher.get()
    }

}
<commit_msg>More readable name of a test case<commit_after>package com.jvm_bloggers.facebook.client.kafka

import com.fasterxml.jackson.databind.ObjectMapper
import com.github.charithe.kafka.EphemeralKafkaBroker
import com.github.charithe.kafka.KafkaJunitRule
import com.jvm_bloggers.facebook.client.NewIssuePublishedData
import com.jvm_bloggers.facebook.client.fb.FacebookPublisher
import groovy.util.logging.Slf4j
import org.junit.Rule
import spock.lang.Specification
import spock.util.concurrent.BlockingVariable

@Slf4j
class KafkaSpec extends Specification {

    @Rule
    public KafkaJunitRule kafkaRule = new KafkaJunitRule(EphemeralKafkaBroker.create(9092, 2181));

    FacebookPublisher facebookPublisher = Mock(FacebookPublisher)

    def "Should consume a message from Kafka and publish it with Facebook publisher"() {
        given:
            NewIssuePublishedData data = new NewIssuePublishedData(55, "http://jvm-bloggers.com/")
            String issueData = new ObjectMapper().writeValueAsString(data)
        and:
            def awaitForPublisher = new BlockingVariable<Boolean>(1)
            facebookPublisher.publishPost(_) >> { arguments ->
                log.info("Issue data captured: " + arguments[0])
                awaitForPublisher.set(true)
            }
        and:
            new KafkaConsumer(facebookPublisher).run()
        when:
            kafkaRule.helper().produceStrings("com.jvm_bloggers.issue.published", issueData)
        then:
            awaitForPublisher.get()
    }

}

{'fraction_non_alphanumeric': 0.0870452227133628, 'fraction_numerical': 0.009520571234274057, 'mean_word_length': 3.3392330383480826, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3634980', 'n_tokens_mistral': 929, 'n_tokens_neox': 831, 'n_words': 153}