Skip to content

Instantly share code, notes, and snippets.

View gitmatheus's full-sized avatar

Matheus Gonçalves gitmatheus

View GitHub Profile
@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();
}
@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.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.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:08
Mock relationships in Apex - 01 of 05
public class DataLayerHandler {
public interface IDataLayer {
List<Document__c> getDocumentList();
}
}
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
<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>
public class ChildComponentController {
public String controllerValue;
public void setControllerValue (String s) {
controllerValue = s.toLowerCase();
}
public String getControllerValue() {
return controllerValue;
<apex:component controller="ParentComponentController">
<apex:attribute name="componentValue" description="Attribute on the component."
type="String" required="required" assignTo="{!controllerValue}"/>
<apex:pageBlock title="My Parent Custom Component">
<p>
<code>componentValue</code> is "{!componentValue}"
<br/>
<code>controllerValue</code> is "{!controllerValue}"
</p>
</apex:pageBlock>
public class ParentComponentController {
public String controllerValue;
public void setControllerValue (String s) {
controllerValue = s.toUpperCase();
}
public String getControllerValue() {
return controllerValue;