Skip to content

Instantly share code, notes, and snippets.

View jessealtman's full-sized avatar

Jesse Altman jessealtman

View GitHub Profile
@jessealtman
jessealtman / MyController
Created June 27, 2014 19:12
Real Unit Tests using ApexMocks
public class MyController{
private MyInterface myImplementation;
public Integer valueOne{get;set;}
public Integer valueTwo{get;set;}
public MyController(MyInterface myImplementation){
this.myImplementation = myImplementation;
}
public Integer calculatedTotalValue(){
@jessealtman
jessealtman / build.properties
Created June 27, 2014 19:06
ApexMocks: Setup
# Specify the login credentials for the desired Salesforce organization
sf.username = <insert username here>
sf.password = <insert password and security token>
# Use 'https://login.salesforce.com' for production or developer edition
# Use 'https://test.salesforce.com for sandbox.
sf.serverurl = https://login.salesforce.com
sf.maxPoll = 20
@jessealtman
jessealtman / ExampleController
Created April 19, 2014 14:18
Proper Unit Test Structure in Apex
public class ExampleController
public Integer differenceInFooWidgetsAndStubCount(Id fooId, Id stubId){
Foo__c foo = [
SELECT
Id,
(SELECT Id FROM Widget__r)
FROM
Foo__c
WHERE
@jessealtman
jessealtman / StackExchangeService
Created April 19, 2014 14:11
StackExchange API on Salesforce!
public class StackExchangeService{
public List<SFSEQuestion> getStackExchangeQuestionsDeserialize(){
Http httpQuestions = new Http();
HttpRequest requestQuestions = new HttpRequest();
requestQuestions.setEndpoint('http://api.stackexchange.com/2.2/users/605/questions?order=desc&sort=activity&site=salesforce');
requestQuestions.setMethod('GET');
requestQuestions.setHeader('Content-Type', 'application/json');
HTTPResponse responseQuestions = httpQuestions.send(requestQuestions);
List<SFSEQuestion> questions = new List<SFSEQuestion>();
@jessealtman
jessealtman / PaymentInterface
Created April 19, 2014 14:04
Dependency Injection in Apex
public interface PaymentInterface{
String processPayment();
}
@jessealtman
jessealtman / ChatterGalleryPage
Last active August 29, 2015 13:59
Chatter Gallery
<apex:page showHeader="true" sidebar="true" title="Chatter Gallery" controller="ChatterGalleryPageController">
<apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"/>
<apex:includeScript value="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"/>
<apex:stylesheet value="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css"/>
<apex:includeScript value="{!URLFOR($Resource.Galleria,'galleria/galleria-1.3.5.min.js')}"/>
<style>
.galleria{ width: 700px; height: 400px; background: #000 }
</style>
<apex:sectionHeader title="View Chatter Images" subtitle="Chatter Gallery" />