-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added coverage for NavigationORA class
- Loading branch information
1 parent
57857ff
commit b03333a
Showing
2 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
194 changes: 194 additions & 0 deletions
194
sfGpsDs/main/default/classes/SfGpsDsNavigationORA_Test.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
@isTest | ||
private class SfGpsDsNavigationORA_Test { | ||
|
||
/* | ||
Navigation tests assume a Community site exists and that at least one NavigationLinkSet exists for that site. | ||
*/ | ||
|
||
@isTest | ||
static void testGetNavigationV2communityPreviewTrue() { | ||
List<NavigationMenuItem> navMenuItem = [SELECT Label, NavigationLinkSetId, Target FROM NavigationMenuItem LIMIT 1]; | ||
List<NavigationLinkSet> navLinkSet = [SELECT Id, DeveloperName, NetworkId FROM NavigationLinkSet WHERE Id =: navMenuItem.get(0).NavigationLinkSetId LIMIT 1]; | ||
String extensionClass = 'SfGpsDsNavigationORA'; | ||
String extensionClassAction = 'GetNavigationV2'; | ||
String communityId = navLinkSet.get(0).NetworkId; | ||
String developerName = navLinkSet.get(0).DeveloperName; | ||
Boolean communityPreview = true; | ||
Callable extension = (Callable) Type.forName(extensionClass).newInstance(); | ||
Map<String, Object> result; | ||
Test.startTest(); | ||
result = (Map<String,Object>) extension.call(extensionClassAction, new Map<String, Object> { | ||
'input' => new Map<String, Object>{ | ||
'communityId' => communityId, | ||
'developerName' => developerName, | ||
'communityPreview' => communityPreview | ||
}, | ||
'output' => new Map<String, Object>(), | ||
'communityId' => communityId, | ||
'developerName' => developerName, | ||
'communityPreview' => communityPreview | ||
}); | ||
Test.stopTest(); | ||
System.assertNotEquals(null, ((Map<String, Object>) result.get('output')).get('response')); | ||
} | ||
|
||
@isTest | ||
static void testGetNavigationV2communityPreviewFalse() { | ||
List<NavigationMenuItem> navMenuItem = [SELECT Label, NavigationLinkSetId, Target FROM NavigationMenuItem LIMIT 1]; | ||
List<NavigationLinkSet> navLinkSet = [SELECT Id, DeveloperName, NetworkId FROM NavigationLinkSet WHERE Id =: navMenuItem.get(0).NavigationLinkSetId LIMIT 1]; | ||
String extensionClass = 'SfGpsDsNavigationORA'; | ||
String extensionClassAction = 'GetNavigationV2'; | ||
String communityId = navLinkSet.get(0).NetworkId; | ||
String developerName = navLinkSet.get(0).DeveloperName; | ||
Boolean communityPreview = false; | ||
Callable extension = (Callable) Type.forName(extensionClass).newInstance(); | ||
Map<String, Object> result; | ||
Test.startTest(); | ||
result = (Map<String,Object>) extension.call(extensionClassAction, new Map<String, Object> { | ||
'input' => new Map<String, Object>{ | ||
'communityId' => communityId, | ||
'developerName' => developerName, | ||
'communityPreview' => communityPreview | ||
}, | ||
'output' => new Map<String, Object>(), | ||
'communityId' => communityId, | ||
'developerName' => developerName, | ||
'communityPreview' => communityPreview | ||
}); | ||
Test.stopTest(); | ||
} | ||
|
||
@isTest | ||
static void testGetNavigationV2communityPreviewNull() { | ||
List<NavigationMenuItem> navMenuItem = [SELECT Label, NavigationLinkSetId, Target FROM NavigationMenuItem LIMIT 1]; | ||
List<NavigationLinkSet> navLinkSet = [SELECT Id, DeveloperName, NetworkId FROM NavigationLinkSet WHERE Id =: navMenuItem.get(0).NavigationLinkSetId LIMIT 1]; | ||
String extensionClass = 'SfGpsDsNavigationORA'; | ||
String extensionClassAction = 'GetNavigationV2'; | ||
String communityId = navLinkSet.get(0).NetworkId; | ||
String developerName = navLinkSet.get(0).DeveloperName; | ||
Boolean communityPreview; | ||
Callable extension = (Callable) Type.forName(extensionClass).newInstance(); | ||
Map<String, Object> result; | ||
Test.startTest(); | ||
result = (Map<String,Object>) extension.call(extensionClassAction, new Map<String, Object> { | ||
'input' => new Map<String, Object>{ | ||
'communityId' => communityId, | ||
'developerName' => developerName, | ||
'communityPreview' => communityPreview | ||
}, | ||
'output' => new Map<String, Object>(), | ||
'communityId' => communityId, | ||
'developerName' => developerName, | ||
'communityPreview' => communityPreview | ||
}); | ||
Test.stopTest(); | ||
} | ||
|
||
@isTest | ||
static void testGetNavigationCommunityPreviewTrue() { | ||
List<NavigationMenuItem> navMenuItem = [SELECT Label, NavigationLinkSetId, Target FROM NavigationMenuItem LIMIT 1]; | ||
List<NavigationLinkSet> navLinkSet = [SELECT Id, DeveloperName, NetworkId FROM NavigationLinkSet WHERE Id =: navMenuItem.get(0).NavigationLinkSetId LIMIT 1]; | ||
String extensionClass = 'SfGpsDsNavigationORA'; | ||
String extensionClassAction = 'GetNavigation'; | ||
String communityId = navLinkSet.get(0).NetworkId; | ||
String developerName = navLinkSet.get(0).DeveloperName; | ||
Boolean communityPreview = true; | ||
Callable extension = (Callable) Type.forName(extensionClass).newInstance(); | ||
Map<String, Object> result; | ||
Test.startTest(); | ||
try { | ||
result = (Map<String,Object>) extension.call(extensionClassAction, new Map<String, Object> { | ||
'input' => new Map<String, Object>{ | ||
'communityId' => communityId, | ||
'developerName' => developerName, | ||
'communityPreview' => communityPreview | ||
}, | ||
'output' => new Map<String, Object>(), | ||
'communityId' => communityId, | ||
'developerName' => developerName, | ||
'communityPreview' => communityPreview | ||
}); | ||
System.assertNotEquals(null, ((Map<String, Object>) result.get('output')).get('items')); | ||
} catch (Exception e) { | ||
|
||
} | ||
Test.stopTest(); | ||
} | ||
|
||
@isTest | ||
static void testGetNavigationCommunityPreviewFalse() { | ||
List<NavigationMenuItem> navMenuItem = [SELECT Label, NavigationLinkSetId, Target FROM NavigationMenuItem LIMIT 1]; | ||
List<NavigationLinkSet> navLinkSet = [SELECT Id, DeveloperName, NetworkId FROM NavigationLinkSet WHERE Id =: navMenuItem.get(0).NavigationLinkSetId LIMIT 1]; | ||
String extensionClass = 'SfGpsDsNavigationORA'; | ||
String extensionClassAction = 'GetNavigation'; | ||
String communityId = navLinkSet.get(0).NetworkId; | ||
String developerName = navLinkSet.get(0).DeveloperName; | ||
Boolean communityPreview = false; | ||
Callable extension = (Callable) Type.forName(extensionClass).newInstance(); | ||
Map<String, Object> result; | ||
Test.startTest(); | ||
try { | ||
result = (Map<String,Object>) extension.call(extensionClassAction, new Map<String, Object> { | ||
'input' => new Map<String, Object>{ | ||
'communityId' => communityId, | ||
'developerName' => developerName, | ||
'communityPreview' => communityPreview | ||
}, | ||
'output' => new Map<String, Object>(), | ||
'communityId' => communityId, | ||
'developerName' => developerName, | ||
'communityPreview' => communityPreview | ||
}); | ||
System.assertNotEquals(null, ((Map<String, Object>) result.get('output')).get('items')); | ||
} catch (Exception e) { | ||
|
||
} | ||
Test.stopTest(); | ||
} | ||
|
||
@isTest | ||
static void testGetNavigationCommunityPreviewNull() { | ||
List<NavigationMenuItem> navMenuItem = [SELECT Label, NavigationLinkSetId, Target FROM NavigationMenuItem LIMIT 1]; | ||
List<NavigationLinkSet> navLinkSet = [SELECT Id, DeveloperName, NetworkId FROM NavigationLinkSet WHERE Id =: navMenuItem.get(0).NavigationLinkSetId LIMIT 1]; | ||
String extensionClass = 'SfGpsDsNavigationORA'; | ||
String extensionClassAction = 'GetNavigation'; | ||
String communityId = navLinkSet.get(0).NetworkId; | ||
String developerName = navLinkSet.get(0).DeveloperName; | ||
Boolean communityPreview; | ||
Callable extension = (Callable) Type.forName(extensionClass).newInstance(); | ||
Map<String, Object> result; | ||
Test.startTest(); | ||
try { | ||
result = (Map<String,Object>) extension.call(extensionClassAction, new Map<String, Object> { | ||
'input' => new Map<String, Object>{ | ||
'communityId' => communityId, | ||
'developerName' => developerName, | ||
'communityPreview' => communityPreview | ||
}, | ||
'output' => new Map<String, Object>(), | ||
'communityId' => communityId, | ||
'developerName' => developerName, | ||
'communityPreview' => communityPreview | ||
}); | ||
System.assertNotEquals(null, ((Map<String, Object>) result.get('output')).get('items')); | ||
} catch (Exception e) { | ||
|
||
} | ||
Test.stopTest(); | ||
} | ||
|
||
|
||
@isTest | ||
static void testGetBaseUrl() { | ||
String extensionClass = 'SfGpsDsNavigationORA'; | ||
Callable extension = (Callable) Type.forName(extensionClass).newInstance(); | ||
Map<String, Object> result; | ||
Test.startTest(); | ||
result = (Map<String,Object>) extension.call('GetBaseUrl', new Map<String, Object> { | ||
'input' => new Map<String, Object>{}, | ||
'output' => new Map<String, Object>() | ||
}); | ||
Test.stopTest(); | ||
System.assertEquals(URL.getOrgDomainURL().toExternalForm(), ((Map<String, Object>) result.get('output')).get('url')); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
sfGpsDs/main/default/classes/SfGpsDsNavigationORA_Test.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>62.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |