<commit_before>package gocardless.connect;

import static gocardless.http.HttpClient.basicAuth;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.MockitoAnnotations.initMocks;
import gocardless.AccountDetails;
import gocardless.exception.SignatureException;
import gocardless.http.HttpClient;
import gocardless.utils.Utils;

import java.math.BigDecimal;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

@RunWith(PowerMockRunner.class)
@PrepareForTest({Utils.class})
@PowerMockIgnore({"javax.crypto.*"}) // See http://code.google.com/p/powermock/issues/detail?id=274
public class ConnectTest {

  private AccountDetails accountDetails = new AccountDetails.Builder()
    .appId("id01").appSecret("sec01").accessToken("tok01").merchantId("mer01").build();

  private Connect connect = new Connect(accountDetails);

  @Mock private HttpClient mockHttpClient;

  @Before
  public void setup() throws Exception {
    initMocks(this);
    PowerMockito.spy(Utils.class);
    PowerMockito.when(Utils.class, "nonce").thenReturn("Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT+HO3ReWMxavlco0Fw8rva+ZcI");
    PowerMockito.when(Utils.class, "utc").thenReturn("2012-03-21T08:55:56Z");
    connect.setHttpClient(mockHttpClient);
  }

  @Test
  public void testNewBillUrl() {
    Bill bill = new Bill(accountDetails.getMerchantId(), new BigDecimal("1000.0"));
    assertEquals(connect.newBillUrl(bill, null, null, null), Fixtures.NEW_BILL_URL);
  }

  @Test
  public void testNewSubscriptionUrl() {
    Subscription subscription = new Subscription(accountDetails.getMerchantId(), new BigDecimal("15.0"), 1, "month");
    assertEquals(connect.newSubscriptionUrl(subscription, null, null, null), Fixtures.NEW_SUBSCRIPTION_URL);
  }

  @Test
  public void testNewSubscriptionUrlWithSetupFee() {
    Subscription subscription = new Subscription(accountDetails.getMerchantId(), new BigDecimal("15.0"), 1, "month");
    subscription.setSetupFee(new BigDecimal(20));
    assertEquals(connect.newSubscriptionUrl(subscription, null, null, null), Fixtures.NEW_SUB_URL_WITH_SETUP_FEE);
  }

  @Test
  public void testNewPreAuthorizationUrl() {
    PreAuthorization preAuthorization = new PreAuthorization(accountDetails.getMerchantId(), new BigDecimal("15.0"), 1, "month");
    assertEquals(connect.newPreAuthorizationUrl(preAuthorization, null, null, null), Fixtures.NEW_PRE_AUTHORIZATION_URL);
  }

  @Test
  public void testConfirmResource() throws SignatureException {
    Map<String, String> headers = basicAuth(accountDetails.getAppId(), accountDetails.getAppSecret());
    connect.confirm(Fixtures.RESOURCE);
    String expectedPath = "https://gocardless.com/api/v1/confirm";
    verify(mockHttpClient, times(1)).post(expectedPath, headers, Fixtures.CONFIRM_POST);
  }

}<commit_msg>Fix up method ambiguity in test calls<commit_after>package gocardless.connect;

import static gocardless.http.HttpClient.basicAuth;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.MockitoAnnotations.initMocks;
import gocardless.AccountDetails;
import gocardless.exception.SignatureException;
import gocardless.http.HttpClient;
import gocardless.utils.Utils;

import java.math.BigDecimal;
import java.net.URI;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

@RunWith(PowerMockRunner.class)
@PrepareForTest({Utils.class})
@PowerMockIgnore({"javax.crypto.*"}) // See http://code.google.com/p/powermock/issues/detail?id=274
public class ConnectTest {

  private AccountDetails accountDetails = new AccountDetails.Builder()
    .appId("id01").appSecret("sec01").accessToken("tok01").merchantId("mer01").build();

  private Connect connect = new Connect(accountDetails);

  @Mock private HttpClient mockHttpClient;

  @Before
  public void setup() throws Exception {
    initMocks(this);
    PowerMockito.spy(Utils.class);
    PowerMockito.when(Utils.class, "nonce").thenReturn("Q9gMPVBZixfRiQ9VnRdDyrrMiskqT0ox8IT+HO3ReWMxavlco0Fw8rva+ZcI");
    PowerMockito.when(Utils.class, "utc").thenReturn("2012-03-21T08:55:56Z");
    connect.setHttpClient(mockHttpClient);
  }

  @Test
  public void testNewBillUrl() {
    Bill bill = new Bill(accountDetails.getMerchantId(), new BigDecimal("1000.0"));
    assertEquals(connect.newBillUrl(bill, (URI) null, (URI) null, null), Fixtures.NEW_BILL_URL);
  }

  @Test
  public void testNewSubscriptionUrl() {
    Subscription subscription = new Subscription(accountDetails.getMerchantId(), new BigDecimal("15.0"), 1, "month");
    assertEquals(connect.newSubscriptionUrl(subscription, (URI) null, (URI) null, null), Fixtures.NEW_SUBSCRIPTION_URL);
  }

  @Test
  public void testNewSubscriptionUrlWithSetupFee() {
    Subscription subscription = new Subscription(accountDetails.getMerchantId(), new BigDecimal("15.0"), 1, "month");
    subscription.setSetupFee(new BigDecimal(20));
    assertEquals(connect.newSubscriptionUrl(subscription, (URI) null, (URI) null, null), Fixtures.NEW_SUB_URL_WITH_SETUP_FEE);
  }

  @Test
  public void testNewPreAuthorizationUrl() {
    PreAuthorization preAuthorization = new PreAuthorization(accountDetails.getMerchantId(), new BigDecimal("15.0"), 1, "month");
    assertEquals(connect.newPreAuthorizationUrl(preAuthorization, (URI) null, (URI) null, null), Fixtures.NEW_PRE_AUTHORIZATION_URL);
  }

  @Test
  public void testConfirmResource() throws SignatureException {
    Map<String, String> headers = basicAuth(accountDetails.getAppId(), accountDetails.getAppSecret());
    connect.confirm(Fixtures.RESOURCE);
    String expectedPath = "https://gocardless.com/api/v1/confirm";
    verify(mockHttpClient, times(1)).post(expectedPath, headers, Fixtures.CONFIRM_POST);
  }

}
{'fraction_non_alphanumeric': 0.11981351981351981, 'fraction_numerical': 0.016783216783216783, 'mean_word_length': 6.22334455667789, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '5929920', 'n_tokens_mistral': 2064, 'n_tokens_neox': 2013, 'n_words': 352}