<commit_before>package gov.nih.nci.integration.catissue;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import gov.nih.nci.integration.exception.IntegrationException;
import gov.nih.nci.integration.invoker.ServiceInvocationResult;

import java.io.IOException;
import java.io.InputStream;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * This is the test class to test the methods of the Wrapper Consent Client.
 * 
 * @author <NAME>
 * 
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:applicationContext-transcend-catissue.xml")
public class CaTissueParticipantTest {

    private CaTissueParticipantClient caTissueParticipantClient;

    @Value("${catissue.custom.lib.location}")
    private String caTissueLibLocation;

    @Value("${catissue.api.login.username}")
    private String catissueApiLoginName;

    @Value("${catissue.api.login.password}")
    private String catissueApiPassword;

    @Value("${catissue.participant.mock.client}")
    private String participantMockClientClass;

    private static final Logger LOG = LoggerFactory.getLogger(CaTissueParticipantTest.class);

    /**
     * To initialize the things
     * 
     * @throws IntegrationException - IntegrationException
     */
    @Test
    @Before
    public void initialize() throws IntegrationException {
        caTissueParticipantClient = new CaTissueParticipantClient(caTissueLibLocation, catissueApiLoginName,
                catissueApiPassword, participantMockClientClass);
    }

    /**
     * TestCase to test the registerParticipant of Wrapper client
     */
    @Test
    public void clientInitException() {
        CaTissueParticipantClient client = null;
        ServiceInvocationResult svc = null;
        try {
            client = new CaTissueParticipantClient("catissue-client-lib-123/", catissueApiLoginName,
                    catissueApiPassword, participantMockClientClass);
            svc = client.registerParticipant(getParticipantXMLStr());

        } catch (IntegrationException e) { 
            svc = null;
        }

        assertNull(svc);
    }

    /**
     * TestCase to test the registerParticipant of Wrapper client
     * 
     */
    @Test
    public void registerParticipantFailure() {
        final ServiceInvocationResult svc = caTissueParticipantClient
                .registerParticipant(getParticipantXMLStrFailure());
        assertNotNull(svc);
    }

    /**
     * TestCase to test the registerParticipant of Wrapper client
     * 
     * @throws IntegrationException - IntegrationException
     */
    @Test
    public void registerParticipant() throws IntegrationException {
        final ServiceInvocationResult svc = caTissueParticipantClient.registerParticipant(getParticipantXMLStr());
        assertNotNull(svc);
    }

    /**
     * TestCase to test the updateRegistrationParticipant of Wrapper client
     * 
     * @throws IntegrationException - IntegrationException
     */
    @Test
    public void updateRegistrationParticipant() throws IntegrationException {
        final ServiceInvocationResult svc = caTissueParticipantClient
                .updateRegistrationParticipant(getParticipantXMLStr());
        assertNotNull(svc);
    }

    /**<commit_msg>Added test for Off_Study flow<commit_after>package gov.nih.nci.integration.catissue;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import gov.nih.nci.integration.exception.IntegrationException;
import gov.nih.nci.integration.invoker.ServiceInvocationResult;

import java.io.IOException;
import java.io.InputStream;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * This is the test class to test the methods of the Wrapper Participant Client.
 * 
 * @author <NAME>
 * 
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:applicationContext-transcend-catissue.xml")
public class CaTissueParticipantTest {

    private CaTissueParticipantClient caTissueParticipantClient;

    @Value("${catissue.custom.lib.location}")
    private String caTissueLibLocation;

    @Value("${catissue.api.login.username}")
    private String catissueApiLoginName;

    @Value("${catissue.api.login.password}")
    private String catissueApiPassword;

    @Value("${catissue.participant.mock.client}")
    private String participantMockClientClass;

    private static final Logger LOG = LoggerFactory.getLogger(CaTissueParticipantTest.class);

    /**
     * To initialize the things
     * 
     * @throws IntegrationException - IntegrationException
     */
    @Test
    @Before
    public void initialize() throws IntegrationException {
        caTissueParticipantClient = new CaTissueParticipantClient(caTissueLibLocation, catissueApiLoginName,
                catissueApiPassword, participantMockClientClass);
    }

    /**
     * TestCase to test the registerParticipant of Wrapper client
     */
    @Test
    public void clientInitException() {
        CaTissueParticipantClient client = null;
        ServiceInvocationResult svc = null;
        try {
            client = new CaTissueParticipantClient("catissue-client-lib-123/", catissueApiLoginName,
                    catissueApiPassword, participantMockClientClass);
            svc = client.registerParticipant(getParticipantXMLStr());

        } catch (IntegrationException e) {
            svc = null;
        }

        assertNull(svc);
    }

    /**
     * TestCase to test the registerParticipant of Wrapper client
     * 
     */
    @Test
    public void registerParticipantFailure() {
        final ServiceInvocationResult svc = caTissueParticipantClient
                .registerParticipant(getParticipantXMLStrFailure());
        assertNotNull(svc);
    }

    /**
     * TestCase to test the registerParticipant of Wrapper client
     * 
     * @throws IntegrationException - IntegrationException
     */
    @Test
    public void registerParticipant() throws IntegrationException {
        final ServiceInvocationResult svc = caTissueParticipantClient.registerParticipant(getParticipantXMLStr());
        assertNotNull(svc);
    }

    /**
     * TestCase to test the updateRegistrationParticipant of Wrapper client
     * 
     * @throws IntegrationException - IntegrationException
     */
    @Test
    public void updateRegistrationParticipant() throws IntegrationException {
        final ServiceInvocationResult svc = caTissueParticipantClient
                .updateRegistrationParticipant(getParticipantXMLStr());
        assertNotNull(svc);
    }

    /**
     * TestCase to test the updateRegistrationParticipant for Off Study flow
     * 
     * @throws IntegrationException - IntegrationException
     */
    @Test
    public void updateRegistrationParticipantOffStudy() throws IntegrationException {
        String message = getParticipantXMLStr();
        message = message.replaceAll("Active", "Closed");
        final ServiceInvocationResult svc = caTissueParticipantClient.updateRegistrationParticipant(message);
        assertNotNull(svc);
    }

    /**
{'fraction_non_alphanumeric': 0.08167252833137945, 'fraction_numerical': 0.0020841474534323305, 'mean_word_length': 3.4926857811585723, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '4050700', 'n_tokens_mistral': 2111, 'n_tokens_neox': 1970, 'n_words': 423}