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
//Used to queue the updating of a list of SObjects | |
//Usage: | |
//ID jobID = System.enqueueJob(new AsynchObjectsUpdate(<SOBJECTSTOUPDATE>)); | |
public class AsynchObjectsUpdate implements Queueable { | |
List < SObject > objectsToUpdate; | |
//list constructor |
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
global without sharing class Job_ScheduledNutritionUpdate implements Schedulable { | |
// Usage for nightly run at 12:05 AM | |
//Job_ScheduledNutritionUpdate snu = new Job_ScheduledNutritionUpdate(); | |
//string sch = '0 05 0 * 1-12 ? *'; | |
//system.schedule('Job_ScheduledNutritionUpdate',sch, snu); | |
global void execute(SchedulableContext sc) { | |
System.debug('Ok, the Job_ScheduledNutritionUpdate is running!!!!'); |
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
// Author: Niki Vankerk | |
// Date: 10/2019 | |
public with sharing class Ingredient { | |
//class variables defined here | |
public Double measurement; | |
public String measurementType; | |
public String description; | |
public String name; |
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
@isTest | |
private class Recipe_Test { | |
/* Validate that a bad id throws an exception on instantiation */ | |
@isTest static void badIdTest() { | |
try { | |
Recipe myRecipeWithBadId = new Recipe('ThisIsNotAGoodId'); | |
} catch (Exception e) { | |
System.debug('exception : '+e); |
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
@isTest | |
private class Recipe_Test { | |
/* Validate that a bad id throws an exception on instantiation */ | |
@isTest static void badIdTest() { | |
try { | |
Recipe myRecipeWithBadId = new Recipe('ThisIsNotAGoodId'); | |
} catch (Exception e) { | |
System.debug('exception : '+e); |
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
@TestSetup | |
static void dataCreation(){ | |
Account a = TestFactory.getAccount('Muddy Waters Inc.', true); | |
Contact c = TestFactory.getContact(a.id, 'Muddy', 'Waters', true); | |
Opportunity opp = New Opportunity(); | |
opp.name = 'Long lost record'; | |
opp.accountId = a.id; | |
opp.closeDate = Date.today().addDays(14); | |
opp.stageName = 'prospecting'; | |
insert opp; |
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
@TestSetup | |
static void dataCreation(){ | |
Account a = TestFactory.getAccount('Muddy Waters Inc.', true); | |
Contact c = TestFactory.getContact(a.id, 'Muddy', 'Waters', true); | |
Opportunity opp = New Opportunity(); | |
opp.name = 'Long lost record'; | |
opp.accountId = a.id; | |
opp.closeDate = Date.today().addDays(14); | |
opp.stageName = 'prospecting'; | |
insert opp; |
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
@isTest | |
public class TestFactory { | |
public static Account getAccount(String name, Boolean doInsert){ | |
Account a = new Account(name = name); | |
if(doInsert){ | |
insert a; | |
} | |
return a; | |
} | |
public static Contact getContact(Id accountId, String fname, String lname, Boolean doInsert){ |
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
@isTest | |
private class Recipe_Test { | |
// create a test Recipe obect in memory, then call the create() method and validate that a corresponding SObject was created | |
@isTest static void createRecipeSObjectTest() { | |
// Data Setup | |
Recipe newRecipe = new Recipe(30, 'Minutes', 'Test Recipe', 4); | |
// Add a description, now a required field (TODO - the constructor should take description!) | |
newRecipe.description = 'A test recipe'; |
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
public with sharing class Recipe { | |
//class variables defined here | |
public Decimal activeMinutes; | |
public Double activeTime; | |
public String activeTimeUnits; | |
public String description; | |
public String name; | |
public String season; |