<commit_before>package stroom.pipeline.server;

import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import stroom.connectors.kafka.*;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;

@RunWith(MockitoJUnitRunner.class)
public class TestStroomKafkaProducer {

    public static final Consumer<Exception> DEFAULT_CALLBACK = ex -> {
        throw new RuntimeException(String.format("Exception during send"), ex);
    };

    @Test
    //@Ignore("You may use this to test the local instance of Kafka.")
    public void testManualSend() {
        // Given
        StroomKafkaProducerFactoryImpl stroomKafkaProducerFactory = new StroomKafkaProducerFactoryImpl();
        StroomKafkaProducer stroomKafkaProducer = stroomKafkaProducerFactory.getProducer("0.10.0.1", "localhost:9092");
        StroomKafkaProducerRecord<String, String> record =
                new StroomKafkaProducerRecord.Builder<String, String>()
                        .topic("statistics")
                        .key("statistics")
                        .value("some record data")
                        .build();

        // When
        stroomKafkaProducer.send(record, FlushMode.FLUSH_ON_SEND, DEFAULT_CALLBACK);

        // Then: manually check your Kafka instances 'statistics' topic for 'some record data'
    }

    @Test
    public void testBadlyConfigured() {
        // Given
        StroomKafkaProducerFactoryImpl stroomKafkaProducerFactory = new StroomKafkaProducerFactoryImpl();
        StroomKafkaProducer stroomKafkaProducer = stroomKafkaProducerFactory.getProducer("0.10.0.1", null);<commit_msg>setting test back to correct values<commit_after>package stroom.pipeline.server;

import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import stroom.connectors.kafka.*;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;

@RunWith(MockitoJUnitRunner.class)
public class TestStroomKafkaProducer {
    private static final String KAFKA_VERSION = "0.10.0.1";

    public static final Consumer<Exception> DEFAULT_CALLBACK = ex -> {
        throw new RuntimeException(String.format("Exception during send"), ex);
    };

    @Test
    @Ignore("You may use this to test the local instance of Kafka.")
    public void testManualSend() {
        // Given
        StroomKafkaProducerFactoryImpl stroomKafkaProducerFactory = new StroomKafkaProducerFactoryImpl();
        StroomKafkaProducer stroomKafkaProducer = stroomKafkaProducerFactory.getProducer(KAFKA_VERSION, "stroom.kafka:9092");
        StroomKafkaProducerRecord<String, String> record =
                new StroomKafkaProducerRecord.Builder<String, String>()
                        .topic("statistics")
                        .key("statistics")
                        .value("some record data")
                        .build();

        // When
        stroomKafkaProducer.send(record, FlushMode.FLUSH_ON_SEND, DEFAULT_CALLBACK);

        // Then: manually check your Kafka instances 'statistics' topic for 'some record data'
    }

    @Test
    public void testBadlyConfigured() {
        // Given
        StroomKafkaProducerFactoryImpl stroomKafkaProducerFactory = new StroomKafkaProducerFactoryImpl();
        StroomKafkaProducer stroomKafkaProducer = stroomKafkaProducerFactory.getProducer(KAFKA_VERSION, null);
{'fraction_non_alphanumeric': 0.08856088560885608, 'fraction_numerical': 0.006528526823729776, 'mean_word_length': 3.250904704463209, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, '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': '262552', 'n_tokens_mistral': 1014, 'n_tokens_neox': 983, 'n_words': 208}