<commit_before>package nl.tudelft.ewi.dea.mail.internals;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;

import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;
import java.util.concurrent.LinkedBlockingQueue;

import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.MimeMessage;

import nl.tudelft.ewi.dea.mail.MailProperties;
import nl.tudelft.ewi.dea.mail.SimpleMessage;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class MailQueueTakerTest {

	@Spy private LinkedBlockingQueue<SimpleMessage> mailQueue;
	@Mock private MailProperties mailProps;
	private Session session = Session.getDefaultInstance(new Properties());
	@Mock private Transport transport;
	private MailQueueTaker mQueueTaker;

	@Before
	public void setup() {
		mQueueTaker = new MailQueueTaker(mailQueue, transport, mailProps, session);
	}
<commit_msg>Last test for the night<commit_after>package nl.tudelft.ewi.dea.mail.internals;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;

import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;
import java.util.concurrent.LinkedBlockingQueue;

import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.MimeMessage;

import nl.tudelft.ewi.dea.mail.MailException;
import nl.tudelft.ewi.dea.mail.MailProperties;
import nl.tudelft.ewi.dea.mail.SimpleMessage;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class MailQueueTakerTest {

	@Spy private LinkedBlockingQueue<SimpleMessage> mailQueue;
	@Mock private MailProperties mailProps;
	private Session session = Session.getDefaultInstance(new Properties());
	@Mock private Transport transport;
	private MailQueueTaker mQueueTaker;

	@Before
	public void setup() {
		mQueueTaker = new MailQueueTaker(mailQueue, transport, mailProps, session);
	}

	@Test
	public void whenConnectionIsTestedTheTakerOpensAndClosesTheTransport() throws MessagingException {
		mQueueTaker.testConnection();
		InOrder order = inOrder(mailQueue, transport, mailProps);
		order.verify(transport).connect(anyString(), anyString(), anyString());
		order.verify(transport).close();
		order.verifyNoMoreInteractions();
	}

	@Test(expected = MailException.class)
	public void whenConnectionTestFailsTheMethodInterrups() throws MessagingException {
		doThrow(new MessagingException()).when(transport).connect(anyString(), anyString(), anyString());
		mQueueTaker.testConnection();
	}

{'fraction_non_alphanumeric': 0.10131108462455304, 'fraction_numerical': 0.0, 'mean_word_length': 6.510067114093959, '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': '381060', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1064, 'n_words': 215}