<commit_before>package org.motechproject.commcare.service.impl;

import org.motechproject.commcare.domain.CommcareAccountSettings;
import org.motechproject.commcare.exception.CommcareAuthenticationException;
import org.motechproject.commcare.exception.CommcareConnectionFailureException;
import org.motechproject.commcare.service.CommcareAccountService;
import org.springframework.stereotype.Service;

@Service
public class StubCommcareAccountServiceImpl implements CommcareAccountService {

    @Override
    public boolean verifySettings(CommcareAccountSettings commcareAccountSettings) throws CommcareConnectionFailureException, CommcareAuthenticationException {
        if (!commcareAccountSettings.canMakeConnection()) {
            throw new IllegalArgumentException("Account settings are not valid.");
        }
        if (!commcareAccountSettings.getCommcareBaseUrl().contains("commcarehq.org")) {
            throw new CommcareConnectionFailureException("Motech was unable to connect to CommCareHQ. Please verify the URL is correct.");
        }
        if (!commcareAccountSettings.getUsername().equals("foo") || !commcareAccountSettings.getPassword().equals("<PASSWORD>")) {
            throw new CommcareAuthenticationException("Motech was unable to authenticate to CommCareHQ. Please verify the username and password.");
        }
        return true;
    }
}<commit_msg>ashish,akula| #855| commcare stub connection service passes by default<commit_after>package org.motechproject.commcare.service.impl;

import org.motechproject.commcare.domain.CommcareAccountSettings;
import org.motechproject.commcare.exception.CommcareAuthenticationException;
import org.motechproject.commcare.exception.CommcareConnectionFailureException;
import org.motechproject.commcare.service.CommcareAccountService;
import org.springframework.stereotype.Service;

@Service
public class StubCommcareAccountServiceImpl implements CommcareAccountService {

    @Override
    public boolean verifySettings(CommcareAccountSettings commcareAccountSettings) throws CommcareConnectionFailureException, CommcareAuthenticationException {
        if (!commcareAccountSettings.canMakeConnection()) {
            throw new IllegalArgumentException("Account settings are not valid.");
        }
        if (commcareAccountSettings.getCommcareBaseUrl().equals("fail")) {
            throw new CommcareConnectionFailureException("Motech was unable to connect to CommCareHQ. Please verify the URL is correct.");
        }
        if (commcareAccountSettings.getUsername().equals("fail") && commcareAccountSettings.getPassword().equals("<PASSWORD>")) {
            throw new CommcareAuthenticationException("Motech was unable to authenticate to CommCareHQ. Please verify the username and password.");
        }
        return true;
    }
}
{'fraction_non_alphanumeric': 0.0782083185211518, 'fraction_numerical': 0.001066477070742979, 'mean_word_length': 5.14410480349345, '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': '6351937', 'n_tokens_mistral': 679, 'n_tokens_neox': 649, 'n_words': 152}