Skip to content

Instantly share code, notes, and snippets.

View gitmatheus's full-sized avatar

Matheus Gonçalves gitmatheus

View GitHub Profile
public class CodeCoverageHelper {
//This method will return a Map of Classes Names and the respective Code Coverage
public static Map<String, Decimal> getCodeCoverage() {
Map<String, Decimal> resultMap = new Map<String, Decimal>();
string queryStr = 'SELECT+NumLinesCovered,ApexClassOrTriggerId,ApexClassOrTrigger.Name,NumLinesUncovered,Coverage+FROM+ApexCodeCoverageAggregate+ORDER+BY+ApexClassOrTrigger.Name';
String ENDPOINT = 'https://' + System.URL.getSalesforceBaseUrl().getHost() + '/services/data/v40.0/tooling/';
public class CodeCoverageController {
public String messageUnder10 {
get { return CodeCoverageHelper.MESSAGE_UNDER_10; }
private set;
}
public String messageUnder75 {
get { return CodeCoverageHelper.MESSAGE_UNDER_75; }
private set;
<apex:page controller="CodeCoverageController" showHeader="true" sidebar="false" docType="html-5.0">
<apex:slds />
<apex:form id="codeCoverageForm">
<apex:outputPanel id="codeCoverageRepeat" style="justify-content: left;">
<br/>
<div class="centered">
<div class="slds-text-heading_large">
<span>
<h2 style="justify-content: center;">Code Coverage information: </h2>
</span>
{
"orgName": "Dreamhouse",
"edition": "Developer",
"release": "Preview",
"settings": {
"orgPreferenceSettings": {
"s1DesktopEnabled": true,
"selfSetPasswordInApi": true,
"s1EncryptedStoragePref2": false
}
sfdx force:org:create -f config/project-scratch-def.json -a PreviewOrg -v DevHub release=Preview
sfdx force:config:set apiVersion=46.0 --global
SFDX_API_VERSION=46.0 sfdx force:org:create -f config/project-scratch-def.json -a PreviewOrg -v DevHub release=Preview
// Creates an instance of the class MyUser
MyUser adminUser = new MyUser();
adminUser.username = 'admin';
adminUser.password = 'admin';
// non-static method, it needs to be called from each instance
adminUser.validateCredentials();
// Creates another instance of the class MyUser
MyUser regularUser = new MyUser();
public class MySecurityClass {
public static Boolean validateCredentials(String username, String password){
if (username == 'admin' && password == 'admin'){
return true;
} else {
return false;
}
}
}
public class MyUser {
public String username;
public String password;
public void validateCredentials() {
// calling an static method without creating a new instance of MySecurityClass
Boolean authenticated = MySecurityClass.validateCredentials(username, password);
System.debug('User username: ' + username);
System.debug('User Authentication: ' + authenticated);