<commit_before>// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package javatests;

import java.util.*;
import org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.junit.Assert.assertTrue;
import data.Account;
import data.Vendor;

@RunWith(JUnit4.class)
public final class AccountTest {
    @Test
    public void testAccountConstructorWithValidInput() {
        // Create Account feilds.
        String accountID = "acc_12";
        String vendorID = "vend-21";
        String entity = "shopper";
        String currency = "USD";
        String direction = "disbursement";
        String legacyAccountID = "legAcc_53";
        int nextGenAccountID = 17;
        String matchingMode = "straight";
        String aggregationMode = "totalAgg"; 

        Account account = new Account(accountID, vendorID, entity, currency, 
            direction, legacyAccountID, nextGenAccountID, matchingMode, aggregationMode);

        // Test that the constructor set the Vendor fields with the correct data.
        assertTrue("Account Constructor incorrectly set accountID field.", 
            account.getAccountID().equals(accountID));
        assertTrue("Account Constructor incorrectly set vendorID field.", 
            account.getVendorID().equals(vendorID));
        assertTrue("Account Constructor incorrectly set entity field.", 
            account.getEntity().equals(entity));
        assertTrue("Account Constructor incorrectly set currency field.", 
            account.getCurrency().equals(currency));   
        assertTrue("Account Constructor incorrectly set direction field.", 
            account.getDirection().equals(direction));       
        assertTrue("Account Constructor incorrectly set legacyAccountID field.", 
            account.getLegacyAccountID().equals(legacyAccountID));  
        assertTrue("Account Constructor incorrectly set nextGenAccountID field.", 
            account.getNextGenAccountID() == nextGenAccountID);  
        assertTrue("Account Constructor incorrectly set matchingMode field.", 
            account.getMatchingMode().equals(matchingMode));  
        assertTrue("Account Constructor incorrectly set aggregationMode field.", 
            account.getAggregationMode().equals(aggregationMode));        
    }
}<commit_msg>test Account's toString() method<commit_after>// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package javatests;

import java.util.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.json.JSONObject;
import static org.junit.Assert.assertTrue;
import data.Account;
import data.Vendor;

@RunWith(JUnit4.class)
public final class AccountTest {
  private Account account;
  private final String ACCOUNT_ID = "acc_12";
  private final String VENDOR_ID = "vend-21";
  private final String ENTITY = "shopper";
  private final String CURRENCY = "USD";
  private final String DIRECTION = "disbursement";
  private final String LEGACY_ACCOUNT_ID = "legAcc_53";
  private final int NEXT_GEN_ACCOUNT_ID = 17;
  private final String MATCHING_MODE = "straight";
  private final String AGGREGATION_MODE = "totalAgg"; 

  /** Create an Account object. */
  @Before
  public void setUp() {
    account = new Account(ACCOUNT_ID, VENDOR_ID, ENTITY, CURRENCY, DIRECTION, 
      LEGACY_ACCOUNT_ID, NEXT_GEN_ACCOUNT_ID, MATCHING_MODE, AGGREGATION_MODE);
  }

  /** Test that the constructor set the Vendor fields with the correct data. */
  @Test
  public void testAccountConstructorWithValidInput() {
    assertTrue("Account Constructor incorrectly set accountID field.", 
      account.getAccountID().equals(ACCOUNT_ID));
    assertTrue("Account Constructor incorrectly set vendorID field.", 
      account.getVendorID().equals(VENDOR_ID));
    assertTrue("Account Constructor incorrectly set entity field.", 
      account.getEntity().equals(ENTITY));
    assertTrue("Account Constructor incorrectly set currency field.", 
      account.getCurrency().equals(CURRENCY));   
    assertTrue("Account Constructor incorrectly set direction field.", 
      account.getDirection().equals(DIRECTION));       
    assertTrue("Account Constructor incorrectly set legacyAccountID field.", 
      account.getLegacyAccountID().equals(LEGACY_ACCOUNT_ID));  
    assertTrue("Account Constructor incorrectly set nextGenAccountID field.", 
      account.getNextGenAccountID() == NEXT_GEN_ACCOUNT_ID);  
    assertTrue("Account Constructor incorrectly set matchingMode field.", 
      account.getMatchingMode().equals(MATCHING_MODE));  
    assertTrue("Account Constructor incorrectly set aggregationMode field.", 
      account.getAggregationMode().equals(AGGREGATION_MODE));        
  }

  /** Test that toJson returns a String representation of an Account object. */
  @Test
  public void testToStringMethod() {
    String expectedResponse = "{Legacy_Account_ID:legAcc_53," + 
      "Next_Gen_Customer_ID:17,Settlement_Attributes:{Currency_Code:USD," +
      "Direction:disbursement,Entity:shopper},Settlement_Config:{" + 
      "Matching_Mode:straight},Account_ID:acc_12,Aggregation_Mode:totalAgg}}";
    String actualResponse = account.toString();

    assertTrue("Account's toString() method returned an incorrect String.", 
      expectedResponse.equals(actualResponse));
  }
}
{'fraction_non_alphanumeric': 0.09459251270990603, 'fraction_numerical': 0.006470497612078263, 'mean_word_length': 3.7770419426048565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '5437933', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1672, 'n_words': 524}