Skip to content

Commit 6678620

Browse files
AshRelateIQGitHub Enterprise
authored andcommitted
Merge pull request #21 from communities/master
check in State to payment controller
2 parents 328ac44 + 15bb4a7 commit 6678620

2 files changed

Lines changed: 20 additions & 18 deletions

File tree

examples/lwc/force-app/main/default/classes/B2BPaymentController.cls

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public with sharing class B2BPaymentController {
6666
bill.put('name', cpa.Name);
6767
bill.put('street', cpa.Street);
6868
bill.put('city', cpa.City);
69+
bill.put('state', cpa.State);
6970
bill.put('country', cpa.Country);
7071
bill.put('postalCode', cpa.PostalCode);
7172
bill.put('latitude', cpa.Latitude);
@@ -86,6 +87,7 @@ public with sharing class B2BPaymentController {
8687
bill.put('id', id);
8788
bill.put('street', address.Street);
8889
bill.put('city', address.City);
90+
bill.put('state', address.State);
8991
bill.put('country', address.Country);
9092
bill.put('postalCode', address.PostalCode);
9193
bill.put('latitude', address.Latitude);

examples/lwc/force-app/main/default/classes/B2BPaymentControllerTest.cls

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public class B2BPaymentControllerTest {
1717
insert cartDeliveryGroup;
1818

1919
// The cpas are related to the account (and through it to the contact)
20-
ContactPointAddress cpa1 = new ContactPointAddress(Name='CPA1', Street='Street1', City='city1',
20+
ContactPointAddress cpa1 = new ContactPointAddress(Name='CPA1', Street='Street1', City='city1', State='state1',
2121
Country='country1', PostalCode='12345', IsDefault=true, AddressType='Billing', ParentId=account.Id);
22-
ContactPointAddress cpa2 = new ContactPointAddress(Name='CPA2', Street='Street2', City='city2',
22+
ContactPointAddress cpa2 = new ContactPointAddress(Name='CPA2', Street='Street2', City='city2', State='state2',
2323
Country='country2', PostalCode='12345', IsDefault=false, AddressType='Billing', ParentId=account.Id);
2424

2525
// This contact point address should not show up because it's set to AddressType Shipping
@@ -48,9 +48,9 @@ public class B2BPaymentControllerTest {
4848
// Get the data we'll need to use for running the test or for verification
4949
WebCart webCart = [SELECT Id FROM WebCart WHERE Name='Cart' LIMIT 1];
5050
User buyer = [SELECT Id FROM User WHERE Username='buyer@example.com'];
51-
ContactPointAddress cpa1 = [SELECT Id, Name, Street, City, Country, PostalCode, IsDefault, ParentId
51+
ContactPointAddress cpa1 = [SELECT Id, Name, Street, City, State, Country, PostalCode, IsDefault, ParentId
5252
FROM ContactPointAddress WHERE Name='CPA1'];
53-
ContactPointAddress cpa2 = [SELECT Id, Name, Street, City, Country, PostalCode, IsDefault, ParentId
53+
ContactPointAddress cpa2 = [SELECT Id, Name, Street, City, State, Country, PostalCode, IsDefault, ParentId
5454
FROM ContactPointAddress WHERE Name='CPA2'];
5555

5656
Test.startTest();
@@ -71,8 +71,8 @@ public class B2BPaymentControllerTest {
7171
Map<String, Object> address1 = addresses.get(0);
7272
Map<String, Object> address2 = addresses.get(1);
7373

74-
testAddressMatches(address1, cpa1.Id, cpa1.Name, cpa1.Street, cpa1.City, cpa1.Country, cpa1.PostalCode, cpa1.IsDefault, false);
75-
testAddressMatches(address2, cpa2.Id, cpa2.Name, cpa2.Street, cpa2.City, cpa2.Country, cpa2.PostalCode, cpa2.IsDefault, false);
74+
testAddressMatches(address1, cpa1.Id, cpa1.Name, cpa1.Street, cpa1.City, cpa1.State, cpa1.Country, cpa1.PostalCode, cpa1.IsDefault, false);
75+
testAddressMatches(address2, cpa2.Id, cpa2.Name, cpa2.Street, cpa2.City, cpa2.State, cpa2.Country, cpa2.PostalCode, cpa2.IsDefault, false);
7676

7777
Test.stopTest();
7878
}
@@ -82,9 +82,9 @@ public class B2BPaymentControllerTest {
8282
// Get the data we'll need to use for running the test or for verification
8383
WebCart webCart = [SELECT Id FROM WebCart WHERE Name='Cart' LIMIT 1];
8484
User buyer = [SELECT Id FROM User WHERE Username='buyer@example.com'];
85-
ContactPointAddress cpa1 = [SELECT Id, Name, Street, City, Country, PostalCode, IsDefault, ParentId, Address
85+
ContactPointAddress cpa1 = [SELECT Id, Name, Street, City, State, Country, PostalCode, IsDefault, ParentId, Address
8686
FROM ContactPointAddress WHERE Name='CPA1'];
87-
ContactPointAddress cpa2 = [SELECT Id, Name, Street, City, Country, PostalCode, IsDefault, ParentId
87+
ContactPointAddress cpa2 = [SELECT Id, Name, Street, City, State, Country, PostalCode, IsDefault, ParentId
8888
FROM ContactPointAddress WHERE Name='CPA2'];
8989

9090
// This change could affect other tests, so make sure to undo this at the end of the test
@@ -111,8 +111,8 @@ public class B2BPaymentControllerTest {
111111
Map<String, Object> address1 = addresses.get(0);
112112
Map<String, Object> address2 = addresses.get(1);
113113

114-
testAddressMatches(address1, cpa1.Id, cpa1.Name, cpa1.Street, cpa1.City, cpa1.Country, cpa1.PostalCode, cpa1.IsDefault, true);
115-
testAddressMatches(address2, cpa2.Id, cpa2.Name, cpa2.Street, cpa2.City, cpa2.Country, cpa2.PostalCode, cpa2.IsDefault, false);
114+
testAddressMatches(address1, cpa1.Id, cpa1.Name, cpa1.Street, cpa1.City, cpa1.State, cpa1.Country, cpa1.PostalCode, cpa1.IsDefault, true);
115+
testAddressMatches(address2, cpa2.Id, cpa2.Name, cpa2.Street, cpa2.City, cpa2.State, cpa2.Country, cpa2.PostalCode, cpa2.IsDefault, false);
116116

117117
Test.stopTest();
118118
} finally {
@@ -128,9 +128,9 @@ public class B2BPaymentControllerTest {
128128
// Get the data we'll need to use for running the test or for verification
129129
WebCart webCart = [SELECT Id FROM WebCart WHERE Name='Cart' LIMIT 1];
130130
User buyer = [SELECT Id FROM User WHERE Username='buyer@example.com'];
131-
ContactPointAddress cpa1 = [SELECT Id, Name, Street, City, Country, PostalCode, IsDefault, ParentId, Address
131+
ContactPointAddress cpa1 = [SELECT Id, Name, Street, City, State, Country, PostalCode, IsDefault, ParentId, Address
132132
FROM ContactPointAddress WHERE Name='CPA1'];
133-
ContactPointAddress cpa2 = [SELECT Id, Name, Street, City, Country, PostalCode, IsDefault, ParentId
133+
ContactPointAddress cpa2 = [SELECT Id, Name, Street, City, State, Country, PostalCode, IsDefault, ParentId
134134
FROM ContactPointAddress WHERE Name='CPA2'];
135135

136136
// This change could affect other tests, so make sure to undo this at the end of the test
@@ -161,9 +161,9 @@ public class B2BPaymentControllerTest {
161161

162162
final String noName = null;
163163
testAddressMatches(selectedAddress, webCart.Id, noName, webCartBillingAddress.Street, webCartBillingAddress.City,
164-
webCartBillingAddress.Country, webCartBillingAddress.PostalCode, false, true);
165-
testAddressMatches(address1, cpa1.Id, cpa1.Name, cpa1.Street, cpa1.City, cpa1.Country, cpa1.PostalCode, cpa1.IsDefault, false);
166-
testAddressMatches(address2, cpa2.Id, cpa2.Name, cpa2.Street, cpa2.City, cpa2.Country, cpa2.PostalCode, cpa2.IsDefault, false);
164+
webCartBillingAddress.State, webCartBillingAddress.Country, webCartBillingAddress.PostalCode, false, true);
165+
testAddressMatches(address1, cpa1.Id, cpa1.Name, cpa1.Street, cpa1.City, cpa1.State, cpa1.Country, cpa1.PostalCode, cpa1.IsDefault, false);
166+
testAddressMatches(address2, cpa2.Id, cpa2.Name, cpa2.Street, cpa2.City, cpa2.State, cpa2.Country, cpa2.PostalCode, cpa2.IsDefault, false);
167167

168168
Test.stopTest();
169169
} finally {
@@ -175,7 +175,7 @@ public class B2BPaymentControllerTest {
175175
// Verifies that the purchase order can be set in the setPayment class
176176
@isTest static void testSetPurchaseOrderNumber() {
177177
WebCart webCart = [SELECT Id FROM WebCart WHERE Name='Cart' LIMIT 1];
178-
ContactPointAddress cpa1 = [SELECT Id, Name, Street, City, Country, PostalCode, IsDefault, ParentId, Address
178+
ContactPointAddress cpa1 = [SELECT Id, Name, Street, City, State, Country, PostalCode, IsDefault, ParentId, Address
179179
FROM ContactPointAddress WHERE Name='CPA1'];
180180

181181
String expectedPONumber = 'ImAPoNumber';
@@ -195,7 +195,6 @@ public class B2BPaymentControllerTest {
195195
System.assertEquals(expectedPONumber, updatedCart.PONumber);
196196

197197
Test.stopTest();
198-
199198
}
200199

201200
// Tests credit card but without providing a payment gateway
@@ -254,11 +253,12 @@ public class B2BPaymentControllerTest {
254253

255254
// Verifies that the address matches the expected values
256255
static void testAddressMatches(Map<String, Object> address, Id id, String name, String street, String city,
257-
String country, String postalCode, Boolean isDefault, Boolean isSelected) {
256+
String state, String country, String postalCode, Boolean isDefault, Boolean isSelected) {
258257
System.assertEquals(id, address.get('id'));
259258
System.assertEquals(name, address.get('name'));
260259
System.assertEquals(street, address.get('street'));
261260
System.assertEquals(city, address.get('city'));
261+
System.assertEquals(state, address.get('state'));
262262
System.assertEquals(country, address.get('country'));
263263
System.assertEquals(postalCode, address.get('postalCode'));
264264
System.assertEquals(isDefault, address.get('default'));

0 commit comments

Comments
 (0)