Skip to content

Instantly share code, notes, and snippets.

@zaynelt
Last active March 14, 2016 01:23
Show Gist options
  • Save zaynelt/3ecb7148cb69bad1851c to your computer and use it in GitHub Desktop.
Save zaynelt/3ecb7148cb69bad1851c to your computer and use it in GitHub Desktop.
RAD Q1 2016 - Final Project Hints
//Object Oriented Class that represents our Stock_Item__c Object and provides functionality
public with sharing class StockItem {
//class variables defined here
//Example: String name;
//default constructor should take in arguments that can be used to instatiate a new StockItem object
//Create methods to execute the functionality described in the requirements.
}
//A Utility class to process Stock Item records from the Stock Item Handler
public with sharing class StockItemHandler {
//Default Constructor
public StockItemHandler() {
}
//Create methods here to handle the before insert, before delete and utility processes described in the requirements
//They should accept lists of Stock_Item__c records from the trigger
}
@isTest
private class StockItemHandler_Test {
@isTest static void testBeforeInsertFunctionality() {
// Implement test code
}
@isTest static void testBeforeDeleteFunctionality() {
// Implement test code
}
@isTest static void testgetLowStockItems() {
// Implement test code
}
}
trigger StockItemTrigger on Stock_Item__c (before insert, before delete) {
//Instantiate StockItemHandler
//Before Insert Handling
if(Trigger.isInsert && Trigger.isBefore) {
//call the class in your handler for before insert
}
//Before Delete Handling
if(Trigger.isDelete && Trigger.isBefore) {
//call the class in your handler for before delete
}
}
/*
* NOTE: THIS IS JUST A COMPLETED VERSION OF THE .trigger FILE ABOVE.
*/
trigger CompletedStockItemTrigger on Stock_Item__c (before insert, before delete) {
//Instantiate StockItemHandler
StockItemHandler handler = new StockItemHandler();
//Before Insert Handling
if(Trigger.isInsert && Trigger.isBefore) {
handler.OnBeforeInsert(Trigger.new);
}
//Before Delete Handling
if(Trigger.isDelete && Trigger.isBefore) {
handler.OnBeforeDelete(Trigger.old);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment