forked from jamessimone/apex-dml-mocking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RepoFactory.cls
43 lines (39 loc) · 1.47 KB
/
RepoFactory.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
public virtual class RepoFactory {
public virtual IAggregateRepository getOppRepo() {
List<Schema.SObjectField> queryFields = new List<Schema.SObjectField>{
Opportunity.IsWon,
Opportunity.StageName
// etc ...
};
IAggregateRepository oppRepo = new FieldLevelHistoryRepo(Opportunity.SObjectType, queryFields, this);
oppRepo.addParentFields(
new List<Schema.SObjectField>{ Opportunity.AccountId },
new List<Schema.SObjectField>{ Opportunity.Account.Id }
);
return oppRepo;
}
public virtual IAggregateRepository getAccountRepo() {
IAggregateRepository accountRepo = new FieldLevelHistoryRepo(
Account.SObjectType,
new List<Schema.SObjectField>{ Account.Name },
this
);
accountRepo.addChildFields(Contact.AccountId, new List<Schema.SObjectField>{ Contact.LastName });
return accountRepo;
}
public virtual IHistoryRepository getOppLineItemRepo() {
List<Schema.SObjectField> queryFields = new List<Schema.SObjectField>{
OpportunityLineItem.Description,
OpportunityLineItem.OpportunityId
// etc
};
return new FieldLevelHistoryRepo(OpportunityLineItem.SObjectType, queryFields, this);
}
public virtual IHistoryRepository getProfileRepo() {
List<Schema.SObjectField> queryFields = new List<Schema.SObjectField>{ Profile.Name };
return new FieldLevelHistoryRepo(Profile.SObjectType, queryFields, this);
}
public virtual IDML getDML() {
return new DML();
}
}