{"action":"created","comment":{"url":"https://api.github.com/repos/eroispaziali/HEDAP/pulls/comments/70732294","id":70732294,"diff_hunk":"@@ -0,0 +1,1112 @@\n+/*\n+    Copyright (c) 2016, Salesforce.org\n+    All rights reserved.\n+    \n+    Redistribution and use in source and binary forms, with or without\n+    modification, are permitted provided that the following conditions are met:\n+    \n+    * Redistributions of source code must retain the above copyright\n+      notice, this list of conditions and the following disclaimer.\n+    * Redistributions in binary form must reproduce the above copyright\n+      notice, this list of conditions and the following disclaimer in the\n+      documentation and/or other materials provided with the distribution.\n+    * Neither the name of Salesforce.org nor the names of\n+      its contributors may be used to endorse or promote products derived\n+      from this software without specific prior written permission.\n+ \n+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+    \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \n+    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS \n+    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \n+    COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \n+    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \n+    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \n+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER \n+    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \n+    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN \n+    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE \n+    POSSIBILITY OF SUCH DAMAGE.\n+*/\n+/**\n+* @author Salesforce.org\n+* @date 2016\n+* @group Addresses\n+* @group-content ../../ApexDocContent/Addresses.htm\n+* @description Tests specific to Contact Address Management. \n+*/\n+\n+@isTest\n+public with sharing class ADDR_Contact_TEST {\n+    \n+    private static void configSettings() {\n+        Hierarchy_Settings__c hs = new Hierarchy_Settings__c(Contacts_Addresses_Enabled__c = true,\n+                                               Simple_Address_Change_Treated_as_Update__c = true);\n+        UTIL_CustomSettingsFacade.getSettingsForTests(hs);\n+    }\n+    \n+    @isTest\n+    public static void noContactToAccPropagation() {\n+        Hierarchy_Settings__c hs = new Hierarchy_Settings__c(\n+            Account_Processor__c = UTIL_Describe.getAdminAccRecTypeID(),\n+            Accounts_Addresses_Enabled__c = UTIL_Describe.getAdminAccRecTypeID() + ';',\n+            Contacts_Addresses_Enabled__c = true,\n+            Simple_Address_Change_Treated_as_Update__c = true);\n+        UTIL_CustomSettingsFacade.getSettingsForTests(hs);\n+        \n+        Contact contact = new Contact(LastName = 'Testerson', MailingStreet = '123 Main St', \n+        MailingCity = 'Chicago', MailingState = 'IL', MailingPostalcode = '60606', MailingCountry = 'USA');\n+        Test.startTest();\n+        insert contact;\n+        Test.stopTest();\n+        \n+        //Verify parent account was automatically created\n+        contact = [select AccountID from Contact where ID = :contact.ID];\n+        System.assertNotEquals(null, contact.AccountID);\n+        \n+        //Verify child address record was created\n+        List<Address__c> addrs = [select Parent_Account__c from Address__c where Parent_Contact__c = :contact.ID]; \n+        System.assertEquals(1, addrs.size());\n+        System.assertEquals(null, addrs[0].Parent_Account__c);\n+        \n+        //Verify no address record was created as child of the parent account\n+        addrs = [select ID from Address__c where Parent_Account__c = :contact.AccountID];\n+        System.assertEquals(0, addrs.size()); \n+        \n+        //Verify parent account has no address info\n+        Account acc = [select BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry\n+        from Account where ID = :contact.AccountID];\n+        System.assertEquals(null, acc.BillingStreet);\n+        System.assertEquals(null, acc.BillingState);\n+        System.assertEquals(null, acc.BillingPostalCode);\n+        System.assertEquals(null, acc.BillingCountry);\n+    }\n+    \n+    @isTest\n+    public static void noAccToContactPropagation() {\n+        Hierarchy_Settings__c hs = new Hierarchy_Settings__c(\n+            Account_Processor__c = UTIL_Describe.getAdminAccRecTypeID(),\n+            Accounts_Addresses_Enabled__c = UTIL_Describe.getAdminAccRecTypeID() + ';',\n+            Contacts_Addresses_Enabled__c = true,\n+            Simple_Address_Change_Treated_as_Update__c = true);\n+        UTIL_CustomSettingsFacade.getSettingsForTests(hs);\n+        \n+        Contact contact = new Contact(LastName = 'Testerson');\n+        insert contact;\n+        \n+        //Verify parent account was automatically created\n+        contact = [select AccountID from Contact where ID = :contact.ID];\n+        System.assertNotEquals(null, contact.AccountID);\n+        \n+        //Give address info to account\n+        Account acc = [select BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry\n+        from Account where ID = :contact.AccountID];\n+        acc.BillingStreet = '123 main st';\n+        acc.BillingState = 'IL';\n+        acc.BillingPostalCode = '54545';\n+        acc.BillingCountry = 'USA';\n+\n+        Test.startTest();\n+        update acc;\n+        Test.stopTest();\n+        \n+        //Verify child address record was created\n+        List<Address__c> addrs = [select Parent_Contact__c from Address__c where Parent_Account__c = :acc.ID]; \n+        System.assertEquals(1, addrs.size());\n+        System.assertEquals(null, addrs[0].Parent_Contact__c);\n+        \n+         //Verify child contact has no address info\n+        contact = [select MailingStreet, MailingCity, MailingState, MailingPostalCode, MailingCountry\n+        from Contact where ID = :contact.ID];\n+        System.assertEquals(null, contact.MailingStreet);\n+        System.assertEquals(null, contact.MailingState);\n+        System.assertEquals(null, contact.MailingPostalCode);\n+        System.assertEquals(null, contact.MailingCountry);\n+        \n+        //Verify no address record was created as child of the child contact\n+        addrs = [select ID from Address__c where Parent_Contact__c = :contact.ID];\n+        System.assertEquals(0, addrs.size()); \n+    }\n+  \n+    /*********************************************************************************************************\n+    @description Create N new Contacts with Mailing addresses \n+    verify:\n+        N addresses created\n+        Contact address matches address object address\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void newRecordsWithAddrInfo() {            \n+        UTIL_CustomSettingsFacade.getSettingsForTests(new Hierarchy_Settings__c(Contacts_Addresses_Enabled__c = true));\n+ \n+        Integer contactCount = 3;\n+        List<Contact> contacts = UTIL_UnitTestData_TEST.createMultipleTestContacts(contactCount);\n+        for (Contact contact : contacts) {\n+            contact.MailingStreet = '123 45th';\n+            contact.MailingCity = 'Seattle';\n+        }\n+        Test.startTest();\n+        insert contacts;\n+        Test.stopTest();\n+\n+        // verify results\n+        map<Id, Contact> mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c from Contact]);\n+        system.assertEquals(contactCount, mapAccIdAcc.size());\n+        \n+        List<Address__c> ListAddr = [select Id, Default_Address__c, MailingStreet__c, MailingCity__c, Parent_Contact__c, \n+        Latest_Start_Date__c, Latest_End_Date__c from Address__c];\n+        system.assertEquals(contactCount, ListAddr.size());\n+        \n+        for (Address__c addr : ListAddr) {\n+            Contact contact = mapAccIdAcc.get(addr.Parent_Contact__c);\n+            system.assertEquals(contact.MailingStreet, addr.MailingStreet__c);\n+            system.assertEquals(contact.MailingCity, addr.MailingCity__c);\n+            system.assertEquals(true, addr.Default_Address__c);\n+        }\n+    }\n+        \n+    /*********************************************************************************************************\n+    @description Update existing default Addresses.  \n+    verify: Contact Mailing address fields updated\n+    **********************************************************************************************************/            \n+    @isTest \n+    public static void updateDefaultAddr() {\n+        configSettings();\n+\n+        // this creates a default Address for each Contact\n+        UTIL_UnitTestData_TEST.ContactsWithAddrs contactsAddrs = UTIL_UnitTestData_TEST.createTestContactsAddrs(2);\n+\n+        // now let's update the Addresses\n+        for (Integer i = 0; i < contactsAddrs.addrs.size(); i++) {\n+            Address__c addr = contactsAddrs.addrs[i];\n+            addr.MailingStreet__c = 'New Street' + i;\n+            addr.MailingCity__c = 'New City' + i;\n+        }\n+        system.assertEquals(false, ADDR_Addresses_TDTM.hasRunAddrTrigger);\n+        Test.startTest();\n+        update contactsAddrs.addrs;\n+        Test.stopTest();\n+    \n+        map<Id, Contact> mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c\n+        from Contact]);\n+        \n+        for (Contact contact : mapAccIdAcc.values()) {\n+            system.assert(contact.MailingStreet.contains('New Street'));\n+            system.assert(contact.MailingCity.contains('New City'));\n+            system.assertEquals(false, contact.is_Address_Override__c);\n+            system.assertNotEquals(null, contact.Current_Address__c);\n+        }\n+    }\n+    \n+    /*********************************************************************************************************\n+    @description Delete existing default Addresses.  \n+    verify: Contact Mailing address fields cleared.\n+    **********************************************************************************************************/            \n+    @isTest \n+    static void deleteDefaultAddr() {\n+        configSettings();\n+        \n+        // this creates a default Address for each Contact\n+        UTIL_UnitTestData_TEST.ContactsWithAddrs contactsAddrs = UTIL_UnitTestData_TEST.createTestContactsAddrs(2);\n+       \n+        // now let's delete the Addresses\n+        system.assertEquals(false, ADDR_Addresses_TDTM.hasRunAddrTrigger);\n+        Test.startTest();\n+        delete contactsAddrs.addrs;\n+        Test.stopTest();\n+    \n+        // verify that the Contact address fields are cleared\n+        map<Id, Contact> mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c from Contact]);\n+        \n+        for (Contact contact : mapAccIdAcc.values()) {\n+            system.assertEquals(null, contact.MailingStreet);\n+            system.assertEquals(null, contact.MailingCity);\n+        }\n+    }\n+\n+    /*********************************************************************************************************\n+    @description Delete existing non-default override Addresses.  \n+    verify: Contact Mailing address fields not changed.\n+    **********************************************************************************************************/            \n+    @isTest\n+    static void deleteNonDefaultOverrideAddr() {\n+        configSettings();\n+        \n+        UTIL_UnitTestData_TEST.ContactsWithAddrs contactsAddrs = UTIL_UnitTestData_TEST.createTestContactsAddrs(2);\n+        \n+        // create additional addresses\n+        List<Address__c> addrs = UTIL_UnitTestData_TEST.initTestAddr(2);\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            addrs[i].Parent_Contact__c = contactsAddrs.contacts[i].Id;\n+            addrs[i].Default_Address__c = false;\n+            addrs[i].MailingStreet__c = 'override' + i;\n+            addrs[i].MailingCity__c = 'override' + i;\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        insert addrs;\n+        \n+        // set the Contacts' address overrides\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            Contact contact = contactsAddrs.contacts[i];\n+            contact.Current_Address__c = addrs[i].Id;\n+            contact.is_Address_Override__c = true;\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        update contactsAddrs.contacts;        \n+        \n+        // now let's delete the override Addresses\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        Test.startTest();\n+        delete addrs;\n+        Test.stopTest();\n+    \n+        // verify that the Contact address fields went back to the default\n+        map<Id, Contact> mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c from Contact]);\n+        \n+        for (Contact contact : mapAccIdAcc.values()) {\n+            system.assert(contact.MailingStreet.contains('Street'));\n+            system.assert(contact.MailingCity.contains('City')); \n+            system.assertEquals(false, contact.is_Address_Override__c);\n+            system.assertNotEquals(null, contact.Current_Address__c);                \n+        }\n+    }\n+\n+    /*********************************************************************************************************\n+    @description Making an Address non-default. That is, the address is no longer the default one for the Contact.  \n+    verify: no change to Contact address\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void updateNonDefaultAddr() {\n+        configSettings();\n+        \n+        // this creates a default Address for each Contact\n+        UTIL_UnitTestData_TEST.ContactsWithAddrs contactsAddrs = UTIL_UnitTestData_TEST.createTestContactsAddrs(2);\n+\n+        // now let's update the Addresses\n+        for (Integer i = 0; i < contactsAddrs.addrs.size(); i++) {\n+            Address__c addr = contactsAddrs.addrs[i];\n+            addr.Default_Address__c = false;\n+        }\n+        system.assertEquals(false, ADDR_Addresses_TDTM.hasRunAddrTrigger);\n+        Test.startTest();\n+        update contactsAddrs.addrs;\n+        Test.stopTest();\n+    \n+        // verify that the Contact and Contacts don't share the same address and it's new for the Contact!\n+        map<Id, Contact> mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c \n+        from Contact]);\n+        \n+        for (Contact contact : mapAccIdAcc.values()) {\n+            system.assertEquals(null, contact.MailingStreet); //address information has been cleared because address is no longer the default\n+            system.assertEquals(null, contact.MailingCity); //address information has been cleared because address is no longer the default\n+            system.assertEquals(false, contact.is_Address_Override__c);\n+            system.assertEquals(null, contact.Current_Address__c); //Contact no longer has a current address, since address is no longer the defaults\n+        }\n+    }\n+\n+    /*********************************************************************************************************\n+    @description Set Contact address override.  \n+    verify: Contact's address matches override\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void setAddrOverride() {\n+        configSettings();\n+        \n+        // this creates a default Address for the Contact\n+        UTIL_UnitTestData_TEST.ContactsWithAddrs contactsAddrs = UTIL_UnitTestData_TEST.createTestContactsAddrs(2);\n+\n+        // create new non-default address\n+        Address__c addrNew = new Address__c();\n+        addrNew.MailingStreet__c = 'street override';\n+        addrNew.MailingCity__c = 'city override';\n+        addrNew.Default_Address__c = false;\n+        // assign it to the second Contact\n+        addrNew.Parent_Contact__c = contactsAddrs.contacts[1].Id;\n+        \n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        insert addrNew;\n+        \n+        // set Contact's address override\n+        contactsAddrs.contacts[1].Current_Address__c = addrNew.Id;\n+        contactsAddrs.contacts[1].is_Address_Override__c = true;\n+        \n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        update contactsAddrs.contacts[0];\n+    \n+        // now let's update the default Address for both Contacts\n+        contactsAddrs.addrs[0].MailingStreet__c = 'New Street';\n+        contactsAddrs.addrs[0].MailingCity__c = 'New City';\n+        contactsAddrs.addrs[1].MailingStreet__c = 'New Street';\n+        contactsAddrs.addrs[1].MailingCity__c = 'New City';\n+\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        Test.startTest();\n+        update contactsAddrs.addrs;\n+        Test.stopTest();\n+        \n+        map<Id, Contact> mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c from Contact]);\n+        \n+        for (Contact contact : mapAccIdAcc.values()) {\n+            // verify that the Contact address is override\n+            if (contact.is_Address_Override__c) { \n+                system.assert(!contact.MailingStreet.contains('street override'));\n+                system.assert(!contact.MailingCity.contains('city override'));\n+                system.assertEquals(contact.Current_Address__c, addrNew.Id);            \n+            // verify that the Contact address is new\n+            } else { \n+                system.assert(contact.MailingStreet.contains('New Street'));\n+                system.assert(contact.MailingCity.contains('New City'));\n+                system.assertNotEquals(null, contact.Current_Address__c);\n+            }\n+        }\n+    }\n+\n+    /*********************************************************************************************************\n+    @description Insert new default addresses to Contact w/ existing default addresses  \n+    verify:\n+        Contact address matches new default\n+        old default addresses no longer marked default\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void insertNewDefaultAddr() {\n+        configSettings();\n+        \n+        // this creates a default Address for each Contact\n+        UTIL_UnitTestData_TEST.ContactsWithAddrs contactsAddrs = UTIL_UnitTestData_TEST.createTestContactsAddrs(2);\n+        \n+        // create additional addresses\n+        List<Address__c> addrs = UTIL_UnitTestData_TEST.initTestAddr(2);\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            addrs[i].Parent_Contact__c = contactsAddrs.contacts[i].Id;\n+            addrs[i].Default_Address__c = true;\n+            addrs[i].MailingStreet__c = 'New Default Street' + i;\n+            addrs[i].MailingCity__c = 'New Default City' + i;\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        Test.startTest();\n+        insert addrs;\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;        \n+        Test.stopTest();\n+\n+        // verify that the Contact addresses are new\n+        map<Id, Contact> mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c from Contact]);\n+        \n+        for (Contact contact : mapAccIdAcc.values()) {\n+            system.assert(contact.MailingStreet.contains('New Default Street'));\n+            system.assert(contact.MailingCity.contains('New Default City'));\n+            system.assertEquals(false, contact.is_Address_Override__c);\n+            system.assertNotEquals(null, contact.Current_Address__c);\n+        }\n+        \n+        // verify the previous addresses got Default cleared.\n+        // and verify latest start date and latest end date appropriately set.\n+        List<Address__c> ListAddr = [select Id, Default_Address__c, MailingStreet__c, Parent_Contact__c, Latest_Start_Date__c, \n+        Latest_End_Date__c from Address__c];\n+        system.assertEquals(4, ListAddr.size());\n+        for (Address__c addr : ListAddr) {\n+            boolean fNewDefault = (addr.MailingStreet__c.contains('New Default Street'));\n+            system.assertEquals(fNewDefault, addr.Default_Address__c);\n+            if (fNewDefault) {\n+               system.assertEquals(system.today(), addr.Latest_Start_Date__c);\n+               system.assertEquals(null, addr.Latest_End_Date__c);\n+            } else {\n+               system.assertEquals(system.today(), addr.Latest_End_Date__c);                \n+            }\n+        }        \n+    }\n+    \n+    /*********************************************************************************************************\n+    @description Insert new default addresses to Contact with existing default addresses, and then go back  \n+    verify:\n+        Contact address matches original default\n+        new default addresses no longer marked default\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void insertNewDefaultAddrAndReset() {\n+        configSettings();\n+        \n+        // this creates a default Address for each Contact\n+        UTIL_UnitTestData_TEST.ContactsWithAddrs contactsAddrs = UTIL_UnitTestData_TEST.createTestContactsAddrs(2);\n+        List<Address__c> ListAddrOriginal = contactsAddrs.addrs;\n+        \n+        // create additional addresses\n+        List<Address__c> addrs = UTIL_UnitTestData_TEST.initTestAddr(2);\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            addrs[i].Parent_Contact__c = contactsAddrs.contacts[i].Id;\n+            addrs[i].Default_Address__c = true;\n+            addrs[i].MailingStreet__c = 'New Default Street' + i;\n+            addrs[i].MailingCity__c = 'New Default City' + i;\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        insert addrs;\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        \n+        // go back to original default addresses\n+        // added this extra set to test fix where we didn't use the correct default\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            ListAddrOriginal[i].Default_Address__c = true;\n+            ListAddrOriginal[i].MailingStreet__c = 'Original Default Street' + i;\n+            ListAddrOriginal[i].MailingCity__c = 'Original Default City' + i;\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        Test.startTest();\n+        update ListAddrOriginal;\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        Test.stopTest();\n+        \n+        // verify the additional addresses got Default cleared.\n+        // and verify latest start date and latest end date appropriately set.\n+        List<Address__c> ListAddr = [select Id, Default_Address__c, MailingStreet__c, Parent_Contact__c, Latest_Start_Date__c, \n+        Latest_End_Date__c from Address__c];\n+        system.assertEquals(4, ListAddr.size());\n+        for (Address__c addr : ListAddr) {\n+            boolean fNewDefault = (addr.MailingStreet__c.contains('Original Default Street'));\n+            system.assertEquals(fNewDefault, addr.Default_Address__c);\n+            if (fNewDefault) {\n+               system.assertEquals(system.today(), addr.Latest_Start_Date__c);\n+               system.assertEquals(null, addr.Latest_End_Date__c);\n+            } else {\n+               system.assertEquals(system.today(), addr.Latest_End_Date__c);                \n+            }\n+        }        \n+    }\n+\n+    /*********************************************************************************************************\n+    @description Update contacts' mailing address to cause creation of new default Address object.  \n+    verify:\n+        new Default Address created\n+        Contacts get new Address\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void updateAddrNew() {\n+        configSettings();\n+        \n+        // this creates a default Address for each Contact\n+        UTIL_UnitTestData_TEST.ContactsWithAddrs contactsAddrs = UTIL_UnitTestData_TEST.createTestContactsAddrs(4);\n+\n+        // modify some of the Contact addresses directly\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            contactsAddrs.contacts[i].MailingStreet = 'Direct Street Edit';\n+            contactsAddrs.contacts[i].MailingCity = 'Direct City Edit';\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        update contactsAddrs.contacts;\n+\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            contactsAddrs.contacts[i].MailingStreet = 'another Street Edit';\n+            contactsAddrs.contacts[i].MailingCity = 'another City Edit';\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        update contactsAddrs.contacts;\n+\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            contactsAddrs.contacts[i].MailingStreet = 'final Street Edit';\n+            contactsAddrs.contacts[i].MailingCity = 'final City Edit';\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        Test.startTest();\n+        update contactsAddrs.contacts;\n+        Test.stopTest();\n+        \n+        map<Id, Contact> mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c from Contact]);\n+        \n+        for (Contact contact : mapAccIdAcc.values()) {\n+            system.assert(contact.MailingStreet.contains('final Street Edit'));\n+            system.assert(contact.MailingCity.contains('final City Edit'));\n+            system.assertEquals(false, contact.is_Address_Override__c);\n+            system.assertNotEquals(null, contact.Current_Address__c);\n+        }\n+ \n+         // verify the previous addresses got Default cleared.\n+        List<Address__c> ListAddr = [select Id, Default_Address__c, MailingStreet__c, Parent_Contact__c from Address__c];\n+        // each set of edits created a new address object \n+        system.assertEquals(16, ListAddr.size());\n+        for (Address__c addr : ListAddr) {\n+            boolean fNewDefault = (addr.MailingStreet__c.contains('final Street Edit'));\n+            system.assertEquals(fNewDefault, addr.Default_Address__c);\n+        }                \n+    }\n+\n+    /*********************************************************************************************************\n+    @description\n+        update Address' Mailing address and mark it as override, to cause creation of new non-default Address object  \n+    verify:\n+        new Address created\n+        original Addresses still default    \n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void updateAddrMarkOverride() {\n+        configSettings();\n+        \n+        // this creates a default Address for each Contact\n+        UTIL_UnitTestData_TEST.ContactsWithAddrs contactsAddrs = UTIL_UnitTestData_TEST.createTestContactsAddrs(2);\n+\n+        // modify the Contact addresses directly, and set override\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            contactsAddrs.contacts[i].MailingStreet = 'Direct Street Edit';\n+            contactsAddrs.contacts[i].MailingCity = 'Direct City Edit';\n+            contactsAddrs.contacts[i].is_Address_Override__c = true;\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        Test.startTest();\n+        update contactsAddrs.contacts;\n+        Test.stopTest();\n+        \n+        map<Id, Contact> mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c from Contact]);\n+        \n+        system.assertEquals('Direct Street Edit', mapAccIdAcc.values()[0].MailingStreet);\n+        system.assertEquals('Direct City Edit', mapAccIdAcc.values()[0].MailingCity);\n+        system.assertEquals(true, mapAccIdAcc.values()[0].is_Address_Override__c);\n+        system.assertEquals('Direct Street Edit', mapAccIdAcc.values()[1].MailingStreet);\n+        system.assertEquals('Direct City Edit', mapAccIdAcc.values()[1].MailingCity);\n+        system.assertEquals(true, mapAccIdAcc.values()[1].is_Address_Override__c);\n+ \n+         // verify the previous addresses didn't get Default cleared.\n+        List<Address__c> ListAddr = [select Id, Default_Address__c, MailingStreet__c, Parent_Contact__c from Address__c];\n+        system.assertEquals(4, ListAddr.size());\n+        for (Address__c addr : ListAddr) {\n+            boolean isNewEdit = (addr.MailingStreet__c.contains('Direct Street Edit'));\n+            if(isNewEdit) {\n+                system.assertNotEquals(false, addr.Default_Address__c);\n+            }\n+        }\n+    }\n+\n+    /*********************************************************************************************************\n+    @description Update Contact's Mailing address with just a case change, to cause an update to default Address object  \n+    verify:\n+        existing Default Address updated\n+        Contact has updated Address\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void updateAddrExistingCaseOnly() { \n+        configSettings();\n+        \n+        // this creates a default Address for each Contact\n+        UTIL_UnitTestData_TEST.ContactsWithAddrs contactsAddrs = UTIL_UnitTestData_TEST.createTestContactsAddrs(2);\n+\n+        // modify some of the Contact addresses directly\n+        // NOTE: we only modify 1 field, so it will be treated as an update to an existing address!\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            contactsAddrs.contacts[i].MailingStreet = 'Direct Street Edit';\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        update contactsAddrs.contacts;\n+\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            contactsAddrs.contacts[i].MailingState = 'Washington';\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        update contactsAddrs.contacts;\n+\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            contactsAddrs.contacts[i].MailingStreet = ' direct street  edit ';  // whitespace and casing should not count as a real edit.\n+            contactsAddrs.contacts[i].MailingState = 'Oregon';\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        update contactsAddrs.contacts;\n+\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            contactsAddrs.contacts[i].MailingStreet = ' DIRECT STREET  EDIT ';  // only change casing.\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        Test.startTest();\n+        update contactsAddrs.contacts;\n+        Test.stopTest();\n+        \n+        map<Id, Contact> mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c from Contact]);\n+        \n+        for (Contact contact : mapAccIdAcc.values()) {\n+            system.assert(contact.MailingStreet.equals('DIRECT STREET  EDIT'));\n+            system.assertEquals(false, contact.is_Address_Override__c);\n+            system.assertNotEquals(null, contact.Current_Address__c);\n+        }\n+ \n+        // verify that no new address was created\n+        List<Address__c> ListAddr = [select Id, Default_Address__c, MailingStreet__c, Parent_Contact__c from Address__c];\n+        system.assertEquals(2, ListAddr.size());\n+        for (Address__c addr : ListAddr) {\n+            system.assert(addr.MailingStreet__c.equals('DIRECT STREET  EDIT'));\n+        }\n+        \n+        // now test that changing the case from the Contact updates all addresses\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            Contact contact = contactsAddrs.contacts[i];\n+            contact.MailingStreet = 'direct street  edit';\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        update contactsAddrs.contacts;\n+        \n+        // verify that the Contact address\n+        mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c from Contact]);\n+        \n+        for (Contact contact : mapAccIdAcc.values()) {\n+            system.assert(contact.MailingStreet.equals('direct street  edit'));\n+            system.assertEquals(false, contact.is_Address_Override__c);\n+            system.assertNotEquals(null, contact.Current_Address__c);\n+        }\n+ \n+        // verify that no new address was created\n+        ListAddr = [select Id, Default_Address__c, MailingStreet__c, Parent_Contact__c from Address__c];\n+        system.assertEquals(2, ListAddr.size());\n+        for (Address__c addr : ListAddr) {\n+            system.assert(addr.MailingStreet__c.equals('direct street  edit'));\n+        }                   \n+    }\n+\n+    /*********************************************************************************************************\n+    @description Update Contacts' Mailing address to cause an update of the default Address object.  \n+    verify:\n+        existing Default Address updated\n+        Contact get updated Address\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void updateAddrExisting() {\n+        configSettings();\n+        \n+        // this creates a default Address for each Contact\n+        UTIL_UnitTestData_TEST.ContactsWithAddrs contactsAddrs = UTIL_UnitTestData_TEST.createTestContactsAddrs(2);\n+\n+        // modify some of the Contact addresses directly\n+        // NOTE: we only modify 1 field, so it will be treated as an update to an existing address!\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            contactsAddrs.contacts[i].MailingStreet = 'Direct Street Edit';\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        update contactsAddrs.contacts;\n+\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            contactsAddrs.contacts[i].MailingState = 'Washington';\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        update contactsAddrs.contacts;\n+\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            contactsAddrs.contacts[i].MailingStreet = ' direct street  edit ';    // whitespace and casing should not count as real edit.\n+            contactsAddrs.contacts[i].MailingState = 'Oregon';\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        Test.startTest();\n+        update contactsAddrs.contacts;\n+        Test.stopTest();\n+        \n+        map<Id, Contact> mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c from Contact]);\n+        \n+        for (Contact contact : mapAccIdAcc.values()) {\n+            system.assert(contact.MailingStreet.contains('direct street  edit'));\n+            system.assert(contact.MailingState.contains('Oregon')); \n+            system.assertEquals(false, contact.is_Address_Override__c);\n+            system.assertNotEquals(null, contact.Current_Address__c);\n+        }\n+ \n+        // verify that no new address was created\n+        List<Address__c> ListAddr = [select Id, Default_Address__c, MailingStreet__c, Parent_Contact__c from Address__c];\n+        system.assertEquals(2, ListAddr.size());\n+        for (Address__c addr : ListAddr) {\n+            system.assertEquals('direct street  edit', addr.MailingStreet__c);\n+        }        \n+    }\n+\n+    /*********************************************************************************************************\n+    @description Create an Address with no Contact \n+    verify: runtime error\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void newAddrNoParent() {        \n+        List<Address__c> addrs = UTIL_UnitTestData_TEST.initTestAddr(2);\n+        for (Integer i = 0; i < addrs.size(); i++) {\n+            system.assertEquals(null, addrs[i].Parent_Contact__c);\n+        }\n+        \n+        try {\n+            insert addrs;\n+        } catch (Exception ex) {\n+            system.assert(ex.getMessage().contains(Label.addrValidParentObjects));\n+            return;\n+        }\n+        system.assert(false); //we shouldn't get here!\n+    }\n+ \n+    /*********************************************************************************************************\n+    @description Create N new duplicate Addresses from Contact  \n+    verify:\n+        duplicates not created\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void newDupeAddr() {\n+        configSettings();\n+        \n+        // this creates a default Address for each Contact\n+        UTIL_UnitTestData_TEST.ContactsWithAddrs contactsAddrs = UTIL_UnitTestData_TEST.createTestContactsAddrs(2);\n+\n+        // create additional addresses thru the Contact.\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            contactsAddrs.contacts[i].MailingStreet = contactsAddrs.addrs[i].MailingStreet__c;\n+            contactsAddrs.contacts[i].MailingCity = contactsAddrs.addrs[i].MailingCity__c;\n+            contactsAddrs.contacts[i].MailingState = contactsAddrs.addrs[i].MailingState__c;\n+            contactsAddrs.contacts[i].MailingPostalCode = contactsAddrs.addrs[i].MailingPostalCode__c;\n+            contactsAddrs.contacts[i].MailingCountry = contactsAddrs.addrs[i].MailingCountry__c;\n+        }        \n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        Test.startTest();\n+        update contactsAddrs.contacts;\n+        Test.stopTest();\n+        \n+        // verify that we don't have new Addresses\n+        List<Address__c> ListAddr = [select Id from Address__c];\n+        system.assertEquals(2, ListAddr.size());\n+    }\n+\n+    /*********************************************************************************************************\n+    @description Create N new duplicate Addresses from Contact, with non-default existing  \n+    verify:\n+        duplicates not created\n+        found match becomes Default\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void newDupeAddrNonDefault() {\n+        configSettings();\n+        \n+        // this creates a default Address for each Contact\n+        UTIL_UnitTestData_TEST.ContactsWithAddrs contactsAddrs = UTIL_UnitTestData_TEST.createTestContactsAddrs(2);\n+\n+        // create additional non-default addresses\n+        List<Address__c> addrs = UTIL_UnitTestData_TEST.initTestAddr(2);\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            addrs[i].Parent_Contact__c = contactsAddrs.contacts[i].Id;\n+            addrs[i].Default_Address__c = false;\n+            addrs[i].MailingStreet__c = 'New Street' + i;\n+            addrs[i].MailingCity__c = 'New City' + i;\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        insert addrs;\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;        \n+ \n+        // create additional addresses thru the Contact.\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            contactsAddrs.contacts[i].MailingStreet = addrs[i].MailingStreet__c;\n+            contactsAddrs.contacts[i].MailingCity = addrs[i].MailingCity__c;\n+            contactsAddrs.contacts[i].MailingState = addrs[i].MailingState__c;\n+            contactsAddrs.contacts[i].MailingPostalCode = addrs[i].MailingPostalCode__c;\n+            contactsAddrs.contacts[i].MailingCountry = addrs[i].MailingCountry__c;\n+        }        \n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        Test.startTest();\n+        update contactsAddrs.contacts;\n+        Test.stopTest();\n+        \n+        map<Id, Contact> mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c from Contact]);\n+        \n+        for (Contact contact : mapAccIdAcc.values()) {\n+            system.assert(contact.MailingStreet.contains('New Street'));\n+            system.assert(contact.MailingCity.contains('New City'));\n+            system.assertEquals(false, contact.is_Address_Override__c);\n+            system.assertNotEquals(null, contact.Current_Address__c);\n+        }\n+        \n+        // verify the new addresses still are Default and we don't have too many\n+        List<Address__c> ListAddr = [select Id, Default_Address__c, MailingStreet__c, Parent_Contact__c, Latest_Start_Date__c, \n+        Latest_End_Date__c from Address__c];\n+        system.assertEquals(2 * 2, ListAddr.size());\n+        for (Address__c addr : ListAddr) {\n+            boolean isNew = (addr.MailingStreet__c.contains('New Street'));\n+            system.assertEquals(isNew, addr.Default_Address__c);\n+        }\n+    }\n+\n+    /*********************************************************************************************************\n+    @description Insert Contact w/ multiline street address\n+    verify: new default Address created and the street address is broken up into street and street2\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void insertMultilineStreetAddress() {\n+        UTIL_CustomSettingsFacade.getSettingsForTests(new Hierarchy_Settings__c(Contacts_Addresses_Enabled__c = true));\n+    \n+        List<Contact> contacts = UTIL_UnitTestData_TEST.CreateMultipleTestContacts(2);\n+        for (Contact contact : contacts) {\n+            contact.MailingStreet = 'new street\\r\\nsecond line';\n+            contact.MailingCity = 'new city';\n+        }\n+        Test.startTest();\n+        insert contacts; \n+        Test.stopTest();       \n+        \n+        // verify the Address objects split street.\n+        List<Address__c> ListAddr = [select Id, MailingStreet__c, MailingStreet2__c, Formula_MailingStreetAddress__c from Address__c];\n+        System.assertEquals(2, ListAddr.size());\n+        for (Address__c addr : ListAddr) {\n+            system.assertEquals('new street', addr.MailingStreet__c);\n+            system.assertEquals('second line', addr.MailingStreet2__c);\n+            system.assertEquals('new street, second line', addr.Formula_MailingStreetAddress__c);\n+        }\n+\n+        map<Id, Contact> mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c from Contact]);\n+        \n+        for (Contact contact : mapAccIdAcc.values()) {\n+            system.assertEquals('new street\\r\\nsecond line', contact.MailingStreet);\n+            system.assertEquals(false, contact.is_Address_Override__c);\n+            system.assertNotEquals(null, contact.Current_Address__c);\n+        }\n+    }\n+\n+    /*********************************************************************************************************\n+    @description Insert new default multiline street addresses w/ existing default addresses  \n+    verify:\n+        Contact address matches new default\n+        street & street2 combined into contact and Contact single street field\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void insertNewDefaultMultilineStreetAddr() {\n+        configSettings();\n+                \n+        // this creates a default Address for each Contact\n+        UTIL_UnitTestData_TEST.ContactsWithAddrs contactsAddrs = UTIL_UnitTestData_TEST.createTestContactsAddrs(2);\n+\n+        // create additional addresses\n+        List<Address__c> addrs = UTIL_UnitTestData_TEST.initTestAddr(2);\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            addrs[i].Parent_Contact__c = contactsAddrs.contacts[i].Id;\n+            addrs[i].Default_Address__c = true;\n+            addrs[i].MailingStreet__c = 'New Default Street';\n+            addrs[i].MailingStreet2__c = 'Second Line';\n+            addrs[i].MailingCity__c = 'New Default City' + i;\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        Test.startTest();\n+        insert addrs;\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;        \n+        Test.stopTest();\n+\n+        // verify Contact address is new\n+        map<Id, Contact> mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c from Contact]);\n+        \n+        for (Contact contact : mapAccIdAcc.values()) {\n+            system.assertEquals('New Default Street\\r\\nSecond Line', contact.MailingStreet);\n+            system.assertEquals('New Default Street\\r\\nSecond Line', contact.MailingStreet);\n+        }\n+        \n+    }\n+    \n+    /*********************************************************************************************************\n+    @description Update Contacts' Mailing address with multiline street address  \n+    verify:\n+        new Default Address created\n+        Contacts get new Address\n+        new Addresss has multiline street split into Street and Street2 fields\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void updateMultilineStreetAddr() {\n+        configSettings();\n+         \n+        // this creates a default Address for each Contact\n+        UTIL_UnitTestData_TEST.ContactsWithAddrs contactsAddrs = UTIL_UnitTestData_TEST.createTestContactsAddrs(2);\n+\n+        // modify some of the Contact addresses directly\n+        for (Integer i = 0; i < contactsAddrs.contacts.size(); i++) {\n+            Contact contact = contactsAddrs.contacts[i];\n+            contact.MailingStreet = 'Direct Street Edit\\r\\nSecond Line';\n+            contact.MailingCity = 'Direct City Edit';\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        Test.startTest();\n+        update contactsAddrs.contacts;\n+        Test.stopTest();\n+        \n+        // verify Contact address\n+        map<Id, Contact> mapAccIdAcc = new map<Id, Contact>([select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c from Contact]);\n+        \n+        for (Contact contact : mapAccIdAcc.values()) {\n+            system.assertEquals('Direct Street Edit\\r\\nSecond Line', contact.MailingStreet);\n+            system.assertEquals('Direct Street Edit\\r\\nSecond Line', contact.MailingStreet);\n+            system.assertEquals(false, contact.is_Address_Override__c);\n+            system.assertNotEquals(null, contact.Current_Address__c);\n+        }\n+ \n+        // verify the Address objects split street.\n+        List<Address__c> ListAddr = [select Id, MailingStreet__c, MailingStreet2__c, Formula_MailingStreetAddress__c, Default_Address__c from Address__c];\n+        for (Address__c addr : ListAddr) {\n+            if (addr.Default_Address__c) {\n+                system.assertEquals('Direct Street Edit', addr.MailingStreet__c);\n+                system.assertEquals('Second Line', addr.MailingStreet2__c);\n+                system.assertEquals('Direct Street Edit, Second Line', addr.Formula_MailingStreetAddress__c);\n+            }\n+        }\n+    }\n+\n+    /*********************************************************************************************************\n+    @description Update N organizational Contacts with Mailing addresses \n+    verify:\n+        N addresses created\n+        Contact addresses updated\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void updateRecordsWithAddrInfo() {         \n+        UTIL_CustomSettingsFacade.getSettingsForTests(new Hierarchy_Settings__c(Contacts_Addresses_Enabled__c = true));\n+ \n+        // create Contacts without addresses\n+        Integer contactCount = 3;\n+        List<Contact> contacts = UTIL_UnitTestData_TEST.createMultipleTestContacts(contactCount);\n+        insert contacts;\n+\n+        // update the Contacts' address\n+        for (Contact contact : contacts) {\n+            contact.MailingStreet = '123 45th';\n+            contact.MailingCity = 'Seattle';\n+        }\n+        Test.startTest();\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        update contacts;\n+        Test.stopTest();\n+\n+        // verify results\n+        contacts = [select Id, Name, MailingStreet, MailingCity, MailingState, MailingPostalCode, MailingCountry, \n+                   Current_Address__c from Contact order by Contact.Name];\n+        system.assertEquals(contactCount, contacts.size());\n+        \n+        List<Address__c> ListAddr = [select Id, Default_Address__c, MailingStreet__c, MailingCity__c, \n+        Parent_Contact__c, Latest_Start_Date__c, Latest_End_Date__c from Address__c \n+        order by Parent_Contact__r.Name];\n+        system.assertEquals(contactCount, ListAddr.size());\n+                \n+        for (Integer i = 0; i < contactCount; i++) {\n+            Contact contact = contacts[i];\n+            Address__c addr = ListAddr[i];\n+            system.assertEquals(contact.MailingStreet, addr.MailingStreet__c);\n+            system.assertEquals(contact.MailingCity, addr.MailingCity__c);\n+            system.assertNotEquals(null, contact.MailingStreet);\n+            system.assertNotEquals(null, contact.MailingCity);\n+            system.assertEquals(true, addr.Default_Address__c);\n+            system.assertNotEquals(null, contact.Current_Address__c);\n+        }\n+    }\n+    \n+    /*********************************************************************************************************\n+    @description Update N Contacts with address objects \n+    verify:\n+        Contact addresses updated\n+        contact addresses not updated\n+    **********************************************************************************************************/            \n+    @isTest\n+    public static void newAddrForContacts() {           \n+        UTIL_CustomSettingsFacade.getSettingsForTests(new Hierarchy_Settings__c(Contacts_Addresses_Enabled__c = true));\n+ \n+        // create Contacts without addresses\n+        List<Contact> contacts = UTIL_UnitTestData_TEST.CreateMultipleTestContacts(3);\n+        insert contacts;\n+\n+         // create addresses for the Contacts\n+        List<Address__c> addrs = UTIL_UnitTestData_TEST.initTestAddr(contacts.size());\n+        for (Integer i = 0; i < contacts.size(); i++) {\n+            addrs[i].Parent_Contact__c = contacts[i].Id;\n+            addrs[i].Default_Address__c = true;\n+        }\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        insert addrs;\n+        ADDR_Addresses_TDTM.hasRunAddrTrigger = false;\n+        \n+        // verify results\n+        contacts = [select Id, Name, MailingStreet, MailingCity, MailingState, \n+        MailingPostalCode, MailingCountry, MailingLatitude, MailingLongitude, is_Address_Override__c, Current_Address__c \n+        from Contact order by Contact.Name];\n+        system.assertEquals(3, contacts.size());\n+        \n+        addrs = [select Id, Default_Address__c, MailingStreet__c, MailingCity__c, Parent_Contact__c, ","path":"src/classes/ADDR_Contact_TEST.cls","position":1027,"original_position":1027,"commit_id":"02c93308a503a044001c9cdbca054998f9ae4c84","original_commit_id":"02c93308a503a044001c9cdbca054998f9ae4c84","user":{"login":"eroispaziali","id":1273282,"avatar_url":"https://avatars.githubusercontent.com/u/1273282?v=3","gravatar_id":"","url":"https://api.github.com/users/eroispaziali","html_url":"https://github.com/eroispaziali","followers_url":"https://api.github.com/users/eroispaziali/followers","following_url":"https://api.github.com/users/eroispaziali/following{/other_user}","gists_url":"https://api.github.com/users/eroispaziali/gists{/gist_id}","starred_url":"https://api.github.com/users/eroispaziali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eroispaziali/subscriptions","organizations_url":"https://api.github.com/users/eroispaziali/orgs","repos_url":"https://api.github.com/users/eroispaziali/repos","events_url":"https://api.github.com/users/eroispaziali/events{/privacy}","received_events_url":"https://api.github.com/users/eroispaziali/received_events","type":"User","site_admin":false},"body":"If the table in this query contains more than 50'000 records a runtime exception will be thrown. Consider either introducing a `WHERE` clause, or adding a `LIMIT` to contain the number of records returned.","created_at":"2016-07-14T00:30:14Z","updated_at":"2016-07-14T00:30:14Z","html_url":"https://github.com/eroispaziali/HEDAP/pull/2#discussion_r70732294","pull_request_url":"https://api.github.com/repos/eroispaziali/HEDAP/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/eroispaziali/HEDAP/pulls/comments/70732294"},"html":{"href":"https://github.com/eroispaziali/HEDAP/pull/2#discussion_r70732294"},"pull_request":{"href":"https://api.github.com/repos/eroispaziali/HEDAP/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/eroispaziali/HEDAP/pulls/2","id":76068551,"html_url":"https://github.com/eroispaziali/HEDAP/pull/2","diff_url":"https://github.com/eroispaziali/HEDAP/pull/2.diff","patch_url":"https://github.com/eroispaziali/HEDAP/pull/2.patch","issue_url":"https://api.github.com/repos/eroispaziali/HEDAP/issues/2","number":2,"state":"open","locked":false,"title":"Feature/245 contact addresses","user":{"login":"eroispaziali","id":1273282,"avatar_url":"https://avatars.githubusercontent.com/u/1273282?v=3","gravatar_id":"","url":"https://api.github.com/users/eroispaziali","html_url":"https://github.com/eroispaziali","followers_url":"https://api.github.com/users/eroispaziali/followers","following_url":"https://api.github.com/users/eroispaziali/following{/other_user}","gists_url":"https://api.github.com/users/eroispaziali/gists{/gist_id}","starred_url":"https://api.github.com/users/eroispaziali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eroispaziali/subscriptions","organizations_url":"https://api.github.com/users/eroispaziali/orgs","repos_url":"https://api.github.com/users/eroispaziali/repos","events_url":"https://api.github.com/users/eroispaziali/events{/privacy}","received_events_url":"https://api.github.com/users/eroispaziali/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-02T16:14:15Z","updated_at":"2016-07-14T00:30:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59f0c32def2d333e0e9fc9b2f0112f90e77326e4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/eroispaziali/HEDAP/pulls/2/commits","review_comments_url":"https://api.github.com/repos/eroispaziali/HEDAP/pulls/2/comments","review_comment_url":"https://api.github.com/repos/eroispaziali/HEDAP/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eroispaziali/HEDAP/issues/2/comments","statuses_url":"https://api.github.com/repos/eroispaziali/HEDAP/statuses/02c93308a503a044001c9cdbca054998f9ae4c84","head":{"label":"eroispaziali:feature/245-contact-addresses","ref":"feature/245-contact-addresses","sha":"02c93308a503a044001c9cdbca054998f9ae4c84","user":{"login":"eroispaziali","id":1273282,"avatar_url":"https://avatars.githubusercontent.com/u/1273282?v=3","gravatar_id":"","url":"https://api.github.com/users/eroispaziali","html_url":"https://github.com/eroispaziali","followers_url":"https://api.github.com/users/eroispaziali/followers","following_url":"https://api.github.com/users/eroispaziali/following{/other_user}","gists_url":"https://api.github.com/users/eroispaziali/gists{/gist_id}","starred_url":"https://api.github.com/users/eroispaziali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eroispaziali/subscriptions","organizations_url":"https://api.github.com/users/eroispaziali/orgs","repos_url":"https://api.github.com/users/eroispaziali/repos","events_url":"https://api.github.com/users/eroispaziali/events{/privacy}","received_events_url":"https://api.github.com/users/eroispaziali/received_events","type":"User","site_admin":false},"repo":{"id":62459018,"name":"HEDAP","full_name":"eroispaziali/HEDAP","owner":{"login":"eroispaziali","id":1273282,"avatar_url":"https://avatars.githubusercontent.com/u/1273282?v=3","gravatar_id":"","url":"https://api.github.com/users/eroispaziali","html_url":"https://github.com/eroispaziali","followers_url":"https://api.github.com/users/eroispaziali/followers","following_url":"https://api.github.com/users/eroispaziali/following{/other_user}","gists_url":"https://api.github.com/users/eroispaziali/gists{/gist_id}","starred_url":"https://api.github.com/users/eroispaziali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eroispaziali/subscriptions","organizations_url":"https://api.github.com/users/eroispaziali/orgs","repos_url":"https://api.github.com/users/eroispaziali/repos","events_url":"https://api.github.com/users/eroispaziali/events{/privacy}","received_events_url":"https://api.github.com/users/eroispaziali/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eroispaziali/HEDAP","description":"Higher Education Data Architecture Package","fork":true,"url":"https://api.github.com/repos/eroispaziali/HEDAP","forks_url":"https://api.github.com/repos/eroispaziali/HEDAP/forks","keys_url":"https://api.github.com/repos/eroispaziali/HEDAP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eroispaziali/HEDAP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eroispaziali/HEDAP/teams","hooks_url":"https://api.github.com/repos/eroispaziali/HEDAP/hooks","issue_events_url":"https://api.github.com/repos/eroispaziali/HEDAP/issues/events{/number}","events_url":"https://api.github.com/repos/eroispaziali/HEDAP/events","assignees_url":"https://api.github.com/repos/eroispaziali/HEDAP/assignees{/user}","branches_url":"https://api.github.com/repos/eroispaziali/HEDAP/branches{/branch}","tags_url":"https://api.github.com/repos/eroispaziali/HEDAP/tags","blobs_url":"https://api.github.com/repos/eroispaziali/HEDAP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eroispaziali/HEDAP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eroispaziali/HEDAP/git/refs{/sha}","trees_url":"https://api.github.com/repos/eroispaziali/HEDAP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eroispaziali/HEDAP/statuses/{sha}","languages_url":"https://api.github.com/repos/eroispaziali/HEDAP/languages","stargazers_url":"https://api.github.com/repos/eroispaziali/HEDAP/stargazers","contributors_url":"https://api.github.com/repos/eroispaziali/HEDAP/contributors","subscribers_url":"https://api.github.com/repos/eroispaziali/HEDAP/subscribers","subscription_url":"https://api.github.com/repos/eroispaziali/HEDAP/subscription","commits_url":"https://api.github.com/repos/eroispaziali/HEDAP/commits{/sha}","git_commits_url":"https://api.github.com/repos/eroispaziali/HEDAP/git/commits{/sha}","comments_url":"https://api.github.com/repos/eroispaziali/HEDAP/comments{/number}","issue_comment_url":"https://api.github.com/repos/eroispaziali/HEDAP/issues/comments{/number}","contents_url":"https://api.github.com/repos/eroispaziali/HEDAP/contents/{+path}","compare_url":"https://api.github.com/repos/eroispaziali/HEDAP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eroispaziali/HEDAP/merges","archive_url":"https://api.github.com/repos/eroispaziali/HEDAP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eroispaziali/HEDAP/downloads","issues_url":"https://api.github.com/repos/eroispaziali/HEDAP/issues{/number}","pulls_url":"https://api.github.com/repos/eroispaziali/HEDAP/pulls{/number}","milestones_url":"https://api.github.com/repos/eroispaziali/HEDAP/milestones{/number}","notifications_url":"https://api.github.com/repos/eroispaziali/HEDAP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eroispaziali/HEDAP/labels{/name}","releases_url":"https://api.github.com/repos/eroispaziali/HEDAP/releases{/id}","deployments_url":"https://api.github.com/repos/eroispaziali/HEDAP/deployments","created_at":"2016-07-02T16:07:23Z","updated_at":"2016-07-02T16:07:25Z","pushed_at":"2016-07-02T16:14:16Z","git_url":"git://github.com/eroispaziali/HEDAP.git","ssh_url":"git@github.com:eroispaziali/HEDAP.git","clone_url":"https://github.com/eroispaziali/HEDAP.git","svn_url":"https://github.com/eroispaziali/HEDAP","homepage":"","size":13459,"stargazers_count":0,"watchers_count":0,"language":"Apex","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"eroispaziali:master","ref":"master","sha":"5e9b95eb2b8728819171cb0bc7852db3e957c321","user":{"login":"eroispaziali","id":1273282,"avatar_url":"https://avatars.githubusercontent.com/u/1273282?v=3","gravatar_id":"","url":"https://api.github.com/users/eroispaziali","html_url":"https://github.com/eroispaziali","followers_url":"https://api.github.com/users/eroispaziali/followers","following_url":"https://api.github.com/users/eroispaziali/following{/other_user}","gists_url":"https://api.github.com/users/eroispaziali/gists{/gist_id}","starred_url":"https://api.github.com/users/eroispaziali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eroispaziali/subscriptions","organizations_url":"https://api.github.com/users/eroispaziali/orgs","repos_url":"https://api.github.com/users/eroispaziali/repos","events_url":"https://api.github.com/users/eroispaziali/events{/privacy}","received_events_url":"https://api.github.com/users/eroispaziali/received_events","type":"User","site_admin":false},"repo":{"id":62459018,"name":"HEDAP","full_name":"eroispaziali/HEDAP","owner":{"login":"eroispaziali","id":1273282,"avatar_url":"https://avatars.githubusercontent.com/u/1273282?v=3","gravatar_id":"","url":"https://api.github.com/users/eroispaziali","html_url":"https://github.com/eroispaziali","followers_url":"https://api.github.com/users/eroispaziali/followers","following_url":"https://api.github.com/users/eroispaziali/following{/other_user}","gists_url":"https://api.github.com/users/eroispaziali/gists{/gist_id}","starred_url":"https://api.github.com/users/eroispaziali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eroispaziali/subscriptions","organizations_url":"https://api.github.com/users/eroispaziali/orgs","repos_url":"https://api.github.com/users/eroispaziali/repos","events_url":"https://api.github.com/users/eroispaziali/events{/privacy}","received_events_url":"https://api.github.com/users/eroispaziali/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eroispaziali/HEDAP","description":"Higher Education Data Architecture Package","fork":true,"url":"https://api.github.com/repos/eroispaziali/HEDAP","forks_url":"https://api.github.com/repos/eroispaziali/HEDAP/forks","keys_url":"https://api.github.com/repos/eroispaziali/HEDAP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eroispaziali/HEDAP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eroispaziali/HEDAP/teams","hooks_url":"https://api.github.com/repos/eroispaziali/HEDAP/hooks","issue_events_url":"https://api.github.com/repos/eroispaziali/HEDAP/issues/events{/number}","events_url":"https://api.github.com/repos/eroispaziali/HEDAP/events","assignees_url":"https://api.github.com/repos/eroispaziali/HEDAP/assignees{/user}","branches_url":"https://api.github.com/repos/eroispaziali/HEDAP/branches{/branch}","tags_url":"https://api.github.com/repos/eroispaziali/HEDAP/tags","blobs_url":"https://api.github.com/repos/eroispaziali/HEDAP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eroispaziali/HEDAP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eroispaziali/HEDAP/git/refs{/sha}","trees_url":"https://api.github.com/repos/eroispaziali/HEDAP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eroispaziali/HEDAP/statuses/{sha}","languages_url":"https://api.github.com/repos/eroispaziali/HEDAP/languages","stargazers_url":"https://api.github.com/repos/eroispaziali/HEDAP/stargazers","contributors_url":"https://api.github.com/repos/eroispaziali/HEDAP/contributors","subscribers_url":"https://api.github.com/repos/eroispaziali/HEDAP/subscribers","subscription_url":"https://api.github.com/repos/eroispaziali/HEDAP/subscription","commits_url":"https://api.github.com/repos/eroispaziali/HEDAP/commits{/sha}","git_commits_url":"https://api.github.com/repos/eroispaziali/HEDAP/git/commits{/sha}","comments_url":"https://api.github.com/repos/eroispaziali/HEDAP/comments{/number}","issue_comment_url":"https://api.github.com/repos/eroispaziali/HEDAP/issues/comments{/number}","contents_url":"https://api.github.com/repos/eroispaziali/HEDAP/contents/{+path}","compare_url":"https://api.github.com/repos/eroispaziali/HEDAP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eroispaziali/HEDAP/merges","archive_url":"https://api.github.com/repos/eroispaziali/HEDAP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eroispaziali/HEDAP/downloads","issues_url":"https://api.github.com/repos/eroispaziali/HEDAP/issues{/number}","pulls_url":"https://api.github.com/repos/eroispaziali/HEDAP/pulls{/number}","milestones_url":"https://api.github.com/repos/eroispaziali/HEDAP/milestones{/number}","notifications_url":"https://api.github.com/repos/eroispaziali/HEDAP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eroispaziali/HEDAP/labels{/name}","releases_url":"https://api.github.com/repos/eroispaziali/HEDAP/releases{/id}","deployments_url":"https://api.github.com/repos/eroispaziali/HEDAP/deployments","created_at":"2016-07-02T16:07:23Z","updated_at":"2016-07-02T16:07:25Z","pushed_at":"2016-07-02T16:14:16Z","git_url":"git://github.com/eroispaziali/HEDAP.git","ssh_url":"git@github.com:eroispaziali/HEDAP.git","clone_url":"https://github.com/eroispaziali/HEDAP.git","svn_url":"https://github.com/eroispaziali/HEDAP","homepage":"","size":13459,"stargazers_count":0,"watchers_count":0,"language":"Apex","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eroispaziali/HEDAP/pulls/2"},"html":{"href":"https://github.com/eroispaziali/HEDAP/pull/2"},"issue":{"href":"https://api.github.com/repos/eroispaziali/HEDAP/issues/2"},"comments":{"href":"https://api.github.com/repos/eroispaziali/HEDAP/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/eroispaziali/HEDAP/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/eroispaziali/HEDAP/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eroispaziali/HEDAP/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/eroispaziali/HEDAP/statuses/02c93308a503a044001c9cdbca054998f9ae4c84"}}}}
{"actor":{"display_login":"eroispaziali"}}