Skip to content

Commit c746627

Browse files
Formatting tidy
1 parent 658ce8c commit c746627

File tree

4 files changed

+109
-110
lines changed

4 files changed

+109
-110
lines changed

framework/default/ortoo-lwc-list-view-buttons/classes/AbstractRedirectToLwcTabPageController.cls

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* Includes a timestamp (Epoch time in seconds) for the generation of the URL
88
* Includes a return URL
99
*/
10-
public virtual with sharing class AbstractRedirectToLwcTabPageController {
11-
10+
public virtual with sharing class AbstractRedirectToLwcTabPageController
11+
{
1212
protected String tabPageName;
1313

1414
/**
@@ -96,11 +96,11 @@ public virtual with sharing class AbstractRedirectToLwcTabPageController {
9696
* Includes parameters for defining the return Url, the Epoch time (for checking the timely usage of the link)
9797
* and the record Ids that are to be processed.
9898
*/
99-
public PageReference redirectToTabPage() {
100-
99+
public PageReference redirectToTabPage()
100+
{
101101
Contract.requires( this.tabPageName != null, 'redirectToTabPage called with a null this.tabPageName. Ensure that the controller extension ('+ObjectUtils.getClassName( this )+') sets "this.tabPageName" in the constructor' );
102102

103-
PageReference appPage = new PageReference( '/lightning/n/' + this.tabPageName ); // TODO: may not need the 'lightning' bit...
103+
PageReference appPage = new PageReference( '/lightning/n/' + this.tabPageName );
104104
appPage.getParameters().put( 'c__returnUrl', returnUrl );
105105
appPage.getParameters().put( 'c__epoch', epochTime );
106106
appPage.getParameters().put( 'c__recordIds', serializedRecordIds );

framework/default/ortoo-lwc-list-view-buttons/classes/TimeController.cls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* A Lightning Controlller that provides access to the Epoch Time as defined by the
33
* Salesforce instance's clock
44
*/
5-
public with sharing class TimeController {
6-
5+
public with sharing class TimeController
6+
{
77
/**
88
* Returns the current Epoch time, in seconds
99
*
Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,106 @@
11
@isTest
22
public with sharing class AbstractRedirectToLwcTabPageCtrlrTest
33
{
4-
@isTest
5-
private static void hasRecords_whenRecordsAreSelected_returnsTrue() // NOPMD: Test method name format
6-
{
7-
List<Contact> context = new List<Contact>{
8-
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
9-
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
10-
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) )
11-
};
12-
13-
ApexPages.StandardSetController standardSetController = new ApexPages.StandardSetController( context );
14-
standardSetController.setSelected( context );
15-
TestableRedirectToLwcTabPageController controller = new TestableRedirectToLwcTabPageController( standardSetController );
16-
17-
Test.startTest();
18-
Boolean got = controller.hasRecords;
19-
Test.stopTest();
20-
21-
System.assertEquals( true, got, 'hasRecords, when records are selected, will return true' );
22-
}
23-
24-
@isTest
25-
private static void hasRecords_whenNoRecordsAreSelected_returnsFalse() // NOPMD: Test method name format
26-
{
27-
List<Contact> context = new List<Contact>{
28-
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
29-
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
30-
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) )
31-
};
32-
33-
ApexPages.StandardSetController standardSetController = new ApexPages.StandardSetController( context );
34-
standardSetController.setSelected( new List<Contact>() );
35-
TestableRedirectToLwcTabPageController controller = new TestableRedirectToLwcTabPageController( standardSetController );
36-
37-
Test.startTest();
38-
Boolean got = controller.hasRecords;
39-
Test.stopTest();
40-
41-
System.assertEquals( false, got, 'hasRecords, when no records are selected, will return false' );
42-
}
43-
44-
@isTest
45-
private static void redirectToTabPage_whenCalled_returnsAPageReferenceToTheTabPage() // NOPMD: Test method name format
46-
{
47-
List<Contact> context = new List<Contact>{
48-
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
49-
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
50-
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) )
51-
};
52-
53-
String expectedRecordIds = JSON.serialize( new List<Id>{ context[0].Id, context[1].Id, context[2].Id } );
54-
55-
ApexPages.StandardSetController standardSetController = new ApexPages.StandardSetController( context );
56-
standardSetController.setSelected( context );
57-
TestableRedirectToLwcTabPageController controller = new TestableRedirectToLwcTabPageController( standardSetController );
58-
59-
Test.startTest();
60-
PageReference got = controller.redirectToTabPage();
61-
Test.stopTest();
62-
63-
Amoss_Asserts.assertContains( 'tabpagename', got.getUrl(), 'redirectToTabPage, when called, will retrun a PageReference with the URL pointing to the defined tab page' );
64-
65-
Map<String,String> parameters = got.getParameters();
66-
System.assertEquals( 'testscenario', parameters.get( 'c__returnUrl' ), 'redirectToTabPage, when called, will return a PageReference with a return url parameter' );
67-
System.assertNotEquals( null, parameters.get( 'c__epoch' ), 'redirectToTabPage, when called, will return a PageReference with an epoch parameter' );
68-
System.assertEquals( expectedRecordIds, parameters.get( 'c__recordIds' ), 'redirectToTabPage, when called, will return a PageReference with a record ids parameter that contains a serialised list of the selected record ids' );
69-
}
70-
71-
@isTest
72-
private static void redirectToTabPage_whenNoRecords_returnsAPageReferenceToTheTabPage() // NOPMD: Test method name format
73-
{
74-
List<Contact> context = new List<Contact>{
75-
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
76-
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
77-
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) )
78-
};
79-
80-
String expectedRecordIds = JSON.serialize( new List<Id>() );
81-
82-
ApexPages.StandardSetController standardSetController = new ApexPages.StandardSetController( context );
83-
standardSetController.setSelected( new List<Contact>() );
84-
TestableRedirectToLwcTabPageController controller = new TestableRedirectToLwcTabPageController( standardSetController );
85-
86-
Test.startTest();
87-
PageReference got = controller.redirectToTabPage();
88-
Test.stopTest();
89-
90-
Amoss_Asserts.assertContains( 'tabpagename', got.getUrl(), 'redirectToTabPage, when no records are selected, will retrun a PageReference with the URL pointing to the defined tab page' );
91-
92-
Map<String,String> parameters = got.getParameters();
93-
System.assertEquals( 'testscenario', parameters.get( 'c__returnUrl' ), 'redirectToTabPage, when no records are selected, will return a PageReference with a return url parameter' );
94-
System.assertNotEquals( null, parameters.get( 'c__epoch' ), 'redirectToTabPage, when no records are selected, will return a PageReference with an epoch parameter' );
95-
System.assertEquals( expectedRecordIds, parameters.get( 'c__recordIds' ), 'redirectToTabPage, when no records are selected, will return a PageReference with a record ids parameter that contains a serialised empty list' );
96-
}
97-
98-
class TestableRedirectToLwcTabPageController extends AbstractRedirectToLwcTabPageController
99-
{
100-
public TestableRedirectToLwcTabPageController( ApexPages.StandardSetController controller )
101-
{
102-
super( controller );
103-
this.tabPageName = 'tabpagename';
104-
}
105-
}
4+
@isTest
5+
private static void hasRecords_whenRecordsAreSelected_returnsTrue() // NOPMD: Test method name format
6+
{
7+
List<Contact> context = new List<Contact>{
8+
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
9+
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
10+
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) )
11+
};
12+
13+
ApexPages.StandardSetController standardSetController = new ApexPages.StandardSetController( context );
14+
standardSetController.setSelected( context );
15+
TestableRedirectToLwcTabPageController controller = new TestableRedirectToLwcTabPageController( standardSetController );
16+
17+
Test.startTest();
18+
Boolean got = controller.hasRecords;
19+
Test.stopTest();
20+
21+
System.assertEquals( true, got, 'hasRecords, when records are selected, will return true' );
22+
}
23+
24+
@isTest
25+
private static void hasRecords_whenNoRecordsAreSelected_returnsFalse() // NOPMD: Test method name format
26+
{
27+
List<Contact> context = new List<Contact>{
28+
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
29+
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
30+
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) )
31+
};
32+
33+
ApexPages.StandardSetController standardSetController = new ApexPages.StandardSetController( context );
34+
standardSetController.setSelected( new List<Contact>() );
35+
TestableRedirectToLwcTabPageController controller = new TestableRedirectToLwcTabPageController( standardSetController );
36+
37+
Test.startTest();
38+
Boolean got = controller.hasRecords;
39+
Test.stopTest();
40+
41+
System.assertEquals( false, got, 'hasRecords, when no records are selected, will return false' );
42+
}
43+
44+
@isTest
45+
private static void redirectToTabPage_whenCalled_returnsAPageReferenceToTheTabPage() // NOPMD: Test method name format
46+
{
47+
List<Contact> context = new List<Contact>{
48+
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
49+
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
50+
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) )
51+
};
52+
53+
String expectedRecordIds = JSON.serialize( new List<Id>{ context[0].Id, context[1].Id, context[2].Id } );
54+
55+
ApexPages.StandardSetController standardSetController = new ApexPages.StandardSetController( context );
56+
standardSetController.setSelected( context );
57+
TestableRedirectToLwcTabPageController controller = new TestableRedirectToLwcTabPageController( standardSetController );
58+
59+
Test.startTest();
60+
PageReference got = controller.redirectToTabPage();
61+
Test.stopTest();
62+
63+
Amoss_Asserts.assertContains( 'tabpagename', got.getUrl(), 'redirectToTabPage, when called, will retrun a PageReference with the URL pointing to the defined tab page' );
64+
65+
Map<String,String> parameters = got.getParameters();
66+
System.assertEquals( 'testscenario', parameters.get( 'c__returnUrl' ), 'redirectToTabPage, when called, will return a PageReference with a return url parameter' );
67+
System.assertNotEquals( null, parameters.get( 'c__epoch' ), 'redirectToTabPage, when called, will return a PageReference with an epoch parameter' );
68+
System.assertEquals( expectedRecordIds, parameters.get( 'c__recordIds' ), 'redirectToTabPage, when called, will return a PageReference with a record ids parameter that contains a serialised list of the selected record ids' );
69+
}
70+
71+
@isTest
72+
private static void redirectToTabPage_whenNoRecords_returnsAPageReferenceToTheTabPage() // NOPMD: Test method name format
73+
{
74+
List<Contact> context = new List<Contact>{
75+
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
76+
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) ),
77+
new Contact( Id = TestIdUtils.generateId( Contact.sobjectType ) )
78+
};
79+
80+
String expectedRecordIds = JSON.serialize( new List<Id>() );
81+
82+
ApexPages.StandardSetController standardSetController = new ApexPages.StandardSetController( context );
83+
standardSetController.setSelected( new List<Contact>() );
84+
TestableRedirectToLwcTabPageController controller = new TestableRedirectToLwcTabPageController( standardSetController );
85+
86+
Test.startTest();
87+
PageReference got = controller.redirectToTabPage();
88+
Test.stopTest();
89+
90+
Amoss_Asserts.assertContains( 'tabpagename', got.getUrl(), 'redirectToTabPage, when no records are selected, will retrun a PageReference with the URL pointing to the defined tab page' );
91+
92+
Map<String,String> parameters = got.getParameters();
93+
System.assertEquals( 'testscenario', parameters.get( 'c__returnUrl' ), 'redirectToTabPage, when no records are selected, will return a PageReference with a return url parameter' );
94+
System.assertNotEquals( null, parameters.get( 'c__epoch' ), 'redirectToTabPage, when no records are selected, will return a PageReference with an epoch parameter' );
95+
System.assertEquals( expectedRecordIds, parameters.get( 'c__recordIds' ), 'redirectToTabPage, when no records are selected, will return a PageReference with a record ids parameter that contains a serialised empty list' );
96+
}
97+
98+
class TestableRedirectToLwcTabPageController extends AbstractRedirectToLwcTabPageController
99+
{
100+
public TestableRedirectToLwcTabPageController( ApexPages.StandardSetController controller )
101+
{
102+
super( controller );
103+
this.tabPageName = 'tabpagename';
104+
}
105+
}
106106
}

framework/default/ortoo-lwc-list-view-buttons/lwc/lwcListViewWrapper/lwcListViewWrapper.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import getEpochTime from '@salesforce/apex/TimeController.getEpochTime';
55

66
const LOAD_LEEWAY = 60; // number of seconds leeway between the redirection to the page and the load of it.
77

8-
// TODO: can we have a generic 'no records selected' error?
98
// TODO: clarify the error message when using an old link
109
// TODO: standards to always say how many records will be updated on the included LWC
1110
export default class LwcListViewWrapper extends NavigationMixin( LightningElement ) {

0 commit comments

Comments
 (0)