Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 748caa4

Browse files
committed
Merge pull request apex-enterprise-patterns#114 from Autobat/master
Update fflib_SObjectDomain.cls
2 parents 0ab6db6 + a103a93 commit 748caa4

File tree

1 file changed

+60
-2
lines changed

1 file changed

+60
-2
lines changed

fflib/src/classes/fflib_SObjectDomain.cls

+60-2
Original file line numberDiff line numberDiff line change
@@ -973,5 +973,63 @@ public virtual with sharing class fflib_SObjectDomain
973973
{
974974
return new TestSObjectOnValidateBehaviour(sObjectList);
975975
}
976-
}
977-
}
976+
}
977+
978+
/**
979+
* Test domain class (ideally this would be in the test class, however Type.newInstance does not see such classes)
980+
**/
981+
public with sharing class TestSObjectDisableBehaviour
982+
extends fflib_SObjectDomain
983+
{
984+
public TestSObjectDisableBehaviour(List<Opportunity> sObjectList)
985+
{
986+
super(sObjectList);
987+
}
988+
989+
public override void onAfterInsert() {
990+
// Throw exception to give the test somethign to assert on
991+
throw new DomainException('onAfterInsert called');
992+
}
993+
994+
public override void onBeforeInsert() {
995+
// Throw exception to give the test somethign to assert on
996+
throw new DomainException('onBeforeInsert called');
997+
}
998+
999+
public override void onAfterUpdate(map<id, SObject> existing) {
1000+
// Throw exception to give the test somethign to assert on
1001+
throw new DomainException('onAfterUpdate called');
1002+
}
1003+
1004+
public override void onBeforeUpdate(map<id, SObject> existing) {
1005+
// Throw exception to give the test somethign to assert on
1006+
throw new DomainException('onBeforeUpdate called');
1007+
}
1008+
1009+
public override void onAfterDelete() {
1010+
// Throw exception to give the test somethign to assert on
1011+
throw new DomainException('onAfterDelete called');
1012+
}
1013+
1014+
public override void onBeforeDelete() {
1015+
// Throw exception to give the test somethign to assert on
1016+
throw new DomainException('onBeforeDelete called');
1017+
}
1018+
1019+
public override void onAfterUndelete() {
1020+
// Throw exception to give the test somethign to assert on
1021+
throw new DomainException('onAfterUndelete called');
1022+
}
1023+
}
1024+
1025+
/**
1026+
* Typically an inner class to the domain class, supported here for test purposes
1027+
**/
1028+
public class TestSObjectDisableBehaviourConstructor implements fflib_SObjectDomain.IConstructable
1029+
{
1030+
public fflib_SObjectDomain construct(List<SObject> sObjectList)
1031+
{
1032+
return new TestSObjectDisableBehaviour(sObjectList);
1033+
}
1034+
}
1035+
}

0 commit comments

Comments
 (0)