<commit_before>package uk.gov.ons.ctp.response.action.export.message;

import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.verify;

import java.io.File;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;

import javax.inject.Inject;

import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import uk.gov.ons.ctp.response.action.export.service.impl.ActionExportServiceImpl;
import uk.gov.ons.ctp.response.action.message.instruction.ActionInstruction;

/**
 * Test Spring Integration flow of Case Notification life cycle messages
 *
 */
@ContextConfiguration(locations = {"/PrintServiceTest-context.xml"})
@RunWith(SpringJUnit4ClassRunner.class)
public class ActionExportReceiverTest {

  private static final int RECEIVE_TIMEOUT = 20000;
  private static final String INVALID_ACTION_INSTRUCTION_LOG_DIRECTORY = "/tmp/ctp/logs/actionexporter/instruction";
  private static final String VALIDXML_PART1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
      + "<p:actionInstruction xmlns:p=\"http://ons.gov.uk/ctp/response/action/message/instruction\" "
      + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
      + "xsi:schemaLocation=\"http://ons.gov.uk/ctp/response/action/message/instruction actionInstruction.xsd \">"
      + "<actionRequests>"
      + "<actionRequest>"
      + "<responseRequired>false</responseRequired>"
      + "<actionId>1</actionId>"
      + "<actionPlan>actionPlan</actionPlan>"
      + "<actionType>actionType</actionType>"
      + "<questionSet>questionSet</questionSet>"
      + "<address>"
      + "<uprn>1</uprn>"
      + "<type>type</type>"
      + "<estabType>estabType</estabType>"
      + "<locality>locality</locality>"
      + "<organisationName>organisationName</organisationName>"
      + "<category>category</category>"
      + "<line1>line1</line1>"
      + "<line2>line2</line2>"
      + "<townName>townName</townName>"
      + "<postcode>postcode</postcode>"
      + "<latitude>0.0</latitude>"
      + "<longitude>0.0</longitude>"
      + "</address>"
      + "<contactName>contactName</contactName>"
      + "<caseId>1</caseId>";

  private static final String VALIDXML_PART2 = "<caseRef>1</caseRef>"
      + "<iac>12345678930666392556</iac>"
      + "<events>"
      + "<event>event</event>"
      + "</events>"
      + "</actionRequest>"
      + "<actionRequest>"
      + "<responseRequired>false</responseRequired>"
      + "<actionId>2</actionId>"
      + "<actionPlan>actionPlan</actionPlan>"
      + "<actionType>actionType</actionType>"
      + "<questionSet>questionSet</questionSet>"
      + "<address>"
      + "<uprn>1</uprn>"
      + "<type>type</type>"
      + "<estabType>estabType</estabType>"
      + "<locality>locality</locality>"
      + "<organisationName>organisationName</organisationName>"
      + "<category>category</category>"
      + "<line1>line1</line1>"
      + "<line2>line2</line2>"
      + "<townName>townName</townName>"
      + "<postcode>postcode</postcode>"
      + "<latitude>0.0</latitude>"
      + "<longitude>0.0</longitude>"
      + "</address>"
      + "<contactName>contactName</contactName>"
      + "<caseId>2</caseId>"
      + "<priority>highest</priority>"
      + "<caseRef>2</caseRef>"
      + "<iac>12345678930666392557</iac>"
      + "<events>"
      + "<event>event</event>"
      + "</events>"
      + "</actionRequest>"
      + "</actionRequests>"
      + "</p:actionInstruction>";

  @Inject
  private MessageChannel testOutbound;

  @Inject
  private ActionExportServiceImpl actionExportService;<commit_msg>CTPA-860 ActionExporter. Fix build for Contact added to instruction.<commit_after>package uk.gov.ons.ctp.response.action.export.message;

import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.verify;

import java.io.File;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;

import javax.inject.Inject;

import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import uk.gov.ons.ctp.response.action.export.service.impl.ActionExportServiceImpl;
import uk.gov.ons.ctp.response.action.message.instruction.ActionInstruction;

/**
 * Test Spring Integration flow of Case Notification life cycle messages
 *
 */
@ContextConfiguration(locations = {"/PrintServiceTest-context.xml"})
@RunWith(SpringJUnit4ClassRunner.class)
public class ActionExportReceiverTest {

  private static final int RECEIVE_TIMEOUT = 20000;
  private static final String INVALID_ACTION_INSTRUCTION_LOG_DIRECTORY = "/tmp/ctp/logs/actionexporter/instruction";
  private static final String VALIDXML_PART1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
      + "<p:actionInstruction xmlns:p=\"http://ons.gov.uk/ctp/response/action/message/instruction\" "
      + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
      + "xsi:schemaLocation=\"http://ons.gov.uk/ctp/response/action/message/instruction actionInstruction.xsd \">"
      + "<actionRequests>"
      + "<actionRequest>"
      + "<responseRequired>false</responseRequired>"
      + "<actionId>1</actionId>"
      + "<actionPlan>actionPlan</actionPlan>"
      + "<actionType>actionType</actionType>"
      + "<questionSet>questionSet</questionSet>"
      + "<contact>"
      + "<title>title</title>"
      + "<forename>forename</forename>"
      + "<surname>surname</surname>"
      + "<phoneNumber>phoneNumber</phoneNumber>"
      + "<emailAddress>emailAddress</emailAddress>"
      + "</contact>"
      + "<address>"
      + "<uprn>1</uprn>"
      + "<type>type</type>"
      + "<estabType>estabType</estabType>"
      + "<locality>locality</locality>"
      + "<organisationName>organisationName</organisationName>"
      + "<category>category</category>"
      + "<line1>line1</line1>"
      + "<line2>line2</line2>"
      + "<townName>townName</townName>"
      + "<postcode>postcode</postcode>"
      + "<latitude>0.0</latitude>"
      + "<longitude>0.0</longitude>"
      + "</address>"
      + "<caseId>1</caseId>";

  private static final String VALIDXML_PART2 = "<caseRef>1</caseRef>"
      + "<iac>12345678930666392556</iac>"
      + "<events>"
      + "<event>event</event>"
      + "</events>"
      + "</actionRequest>"
      + "<actionRequest>"
      + "<responseRequired>false</responseRequired>"
      + "<actionId>2</actionId>"
      + "<actionPlan>actionPlan</actionPlan>"
      + "<actionType>actionType</actionType>"
      + "<questionSet>questionSet</questionSet>"
      + "<contact>"
      + "<title>title</title>"
      + "<forename>forename</forename>"
      + "<surname>surname</surname>"
      + "<phoneNumber>phoneNumber</phoneNumber>"
      + "<emailAddress>emailAddress</emailAddress>"
      + "</contact>"
      + "<address>"
      + "<uprn>1</uprn>"
      + "<type>type</type>"
      + "<estabType>estabType</estabType>"
      + "<locality>locality</locality>"
      + "<organisationName>organisationName</organisationName>"
      + "<category>category</category>"
      + "<line1>line1</line1>"
      + "<line2>line2</line2>"
      + "<townName>townName</townName>"
      + "<postcode>postcode</postcode>"
      + "<latitude>0.0</latitude>"
      + "<longitude>0.0</longitude>"
      + "</address>"
      + "<caseId>2</caseId>"
      + "<priority>highest</priority>"
      + "<caseRef>2</caseRef>"
      + "<iac>12345678930666392557</iac>"
      + "<events>"
      + "<event>event</event>"
      + "</events>"
      + "</actionRequest>"
      + "</actionRequests>"
      + "</p:actionInstruction>";

  @Inject
  private MessageChannel testOutbound;

  @Inject
  private ActionExportServiceImpl actionExportService;
{'fraction_non_alphanumeric': 0.16193840379732863, 'fraction_numerical': 0.019317805497295507, 'mean_word_length': 4.005524861878453, 'pattern_counts': {'":': 0, '<': 237, '<?xml version=': 2, '>': 237, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 8}, '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': '1799282', 'n_tokens_mistral': 2867, 'n_tokens_neox': 2767, 'n_words': 361}