Skip to content

Instantly share code, notes, and snippets.

View gitmatheus's full-sized avatar

Matheus Gonçalves gitmatheus

View GitHub Profile
public class ChildComponentController {
public String controllerValue;
public void setControllerValue (String s) {
controllerValue = s.toLowerCase();
}
public String getControllerValue() {
return controllerValue;
<apex:component controller="ChildComponentController">
<apex:attribute name="componentValue" description="Attribute on the component."
type="String" required="required" assignTo="{!controllerValue}"/>
<apex:pageBlock title="My Child Custom Component">
<p>
<code>componentValue</code> is "{!componentValue}"
<br/>
<code>controllerValue</code> is "{!controllerValue}"
</p>
</apex:pageBlock>
sfdx force:doc:commands:list
=== Commands
force:alias:list # list username aliases for sfdx
force:alias:set # set username aliases for sfdx
force:apex:class:create # create an apex class
force:apex:execute # execute anonymous apex code
force:apex:log:get # fetch a debug log
force:apex:log:list # list debug logs
force:apex:test:report # display test results
force:apex:test:run # invoke apex tests
@gitmatheus
gitmatheus / DataLayerHandler.cls
Last active July 22, 2021 21:08
Mock relationships in Apex - 01 of 05
public class DataLayerHandler {
public interface IDataLayer {
List<Document__c> getDocumentList();
}
}
@gitmatheus
gitmatheus / DataLayerHandler.cls
Last active July 22, 2021 21:08
Mock relationships in Apex - 02 of 05
public class DataLayerHandler {
// DataLayer Class:
public class DataLayer implements IDataLayer {
List<Document__c> getDocumentList(){
return [SELECT Id, Account__r.Business__c FROM Document__c];
}
}
public interface IDataLayer {
List<Document__c> getDocumentList();
@gitmatheus
gitmatheus / DataLayerHandler.cls
Last active July 22, 2021 21:09
Mock relationships in Apex - 03 of 05
public class DataLayerHandler {
// First, create the dataLayer variable:
private IDataLayer dataLayer;
// For an empty constructor, you create a new instance of the DataLayer:
public DataLayerHandler() {
this(new DataLayer());
}
@gitmatheus
gitmatheus / DataLayerHandler_Test.cls
Last active July 22, 2021 21:09
Mock relationships in Apex - 04 of 05
@isTest
private class DataLayerHandler_Test {
private static MockDataLayer dataLayer;
public class MockDataLayer implements DataLayerHandler.IDataLayer {
List<Account> documentAccounts = new List<Account>();
List<Document__c> mockDocuments = new List<Document__c>();
@gitmatheus
gitmatheus / DataLayerHandler_Test.cls
Last active July 22, 2021 21:09
Mock relationships in Apex - 05 of 05
@isTest
private class DataLayerHandler_Test {
private static MockDataLayer dataLayer;
private static DataLayerHandler testedClass;
static {
dataLayer = new MockDataLayer();
}
String baseURL = 'https://' + System.URL.getSalesforceBaseUrl().getHost();
string queryStr = 'SELECT+NumLinesCovered,ApexClassOrTriggerId,ApexClassOrTrigger.Name,NumLinesUncovered,Coverage+FROM+ApexCodeCoverageAggregate';
String ENDPOINT = baseURL + '/services/data/v40.0/tooling/';
HttpRequest req = new HttpRequest();
req.setEndpoint(ENDPOINT + 'query/?q=' + queryStr);
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
public class CodeCoverageWrapper {
public class ApexClassOrTrigger {
public Attributes attributes {get;set;}
public String Name {get;set;}
public ApexClassOrTrigger(JSONParser parser) {
while (parser.nextToken() != System.JSONToken.END_OBJECT) {
if (parser.getCurrentToken() == System.JSONToken.FIELD_NAME) {
String text = parser.getText();