<commit_before>package de.holisticon.util.tracee.jms.out;

import de.holisticon.util.tracee.SimpleTraceeBackend;
import de.holisticon.util.tracee.TraceeBackend;
import de.holisticon.util.tracee.TraceeConstants;
import org.junit.Test;
import org.mockito.Mockito;

import javax.jms.Message;
import javax.jms.MessageProducer;

import java.util.HashMap;
import java.util.Map;

import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;

/**
 * @author <NAME> (Holisticon AG)
 */
public class TraceeMessageProducerTest {

	private final TraceeBackend backend = SimpleTraceeBackend.createNonLoggingAllPermittingBackend();
	private final MessageProducer messageProducer = Mockito.mock(MessageProducer.class);
	private final TraceeMessageProducer unit = new TraceeMessageProducer(messageProducer, backend);
	private final Message message = Mockito.mock(Message.class);


	@Test
	public void testWriteTraceeContextToMessage() throws Exception {
		backend.put("random", "entry");
		unit.writeTraceeContextToMessage(message);

		final Map<String,String> expectedObjectProperty = new HashMap<String, String>();
		expectedObjectProperty.put("random","entry");
		verify(message).setObjectProperty(eq(TraceeConstants.JMS_HEADER_NAME), eq(expectedObjectProperty));
	}

	@Test
	public void testDontWriteEmptyTraceeContextToMessage() throws Exception {
		backend.clear();<commit_msg>#16: minor refactoring [skip ci]<commit_after>package de.holisticon.util.tracee.jms.out;

import de.holisticon.util.tracee.SimpleTraceeBackend;
import de.holisticon.util.tracee.TraceeBackend;
import de.holisticon.util.tracee.TraceeConstants;
import org.junit.Test;
import org.mockito.Mockito;

import javax.jms.Message;
import javax.jms.MessageProducer;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;

/**
 * @author <NAME> (Holisticon AG)
 */
public class TraceeMessageProducerTest {

	private final TraceeBackend backend = SimpleTraceeBackend.createNonLoggingAllPermittingBackend();
	private final MessageProducer messageProducer = Mockito.mock(MessageProducer.class);
	private final TraceeMessageProducer unit = new TraceeMessageProducer(messageProducer, backend);
	private final Message message = Mockito.mock(Message.class);


	@Test
	public void testWriteTraceeContextToMessage() throws Exception {
		backend.put("random", "entry");
		unit.writeTraceeContextToMessage(message);
		verify(message).setObjectProperty(eq(TraceeConstants.JMS_HEADER_NAME), eq(Collections.singletonMap("random","entry")));
	}

	@Test
	public void testDontWriteEmptyTraceeContextToMessage() throws Exception {
		backend.clear();
{'fraction_non_alphanumeric': 0.10102437301306959, 'fraction_numerical': 0.0007064641469445425, 'mean_word_length': 7.045454545454546, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4233834', 'n_tokens_mistral': 864, 'n_tokens_neox': 856, 'n_words': 164}