Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. @isTest
  2. public class WE_OppUpdatesTest{
  3.  
  4. @testSetup
  5. static void dataSetup() {
  6.  
  7. Profile p1 = [SELECT Id FROM Profile WHERE Name = 'System Administrator - Wex Europe'];
  8.  
  9. User[] userList = new User[]{};
  10. User u = new User();
  11.  
  12. u.FirstName = 'Alex';
  13. u.LastName = 'Sherwood';
  14. u.Email = 'test@wexeurope.com';
  15. u.Username = 'astest@wexeurope.com';
  16. u.Alias = 'astest';
  17. u.ProfileId = p1.Id;
  18. u.TimeZoneSidKey = 'America/Denver';
  19. u.LocaleSidKey = 'en_US';
  20. u.EmailEncodingKey = 'UTF-8';
  21. u.LanguageLocaleKey = 'en_US';
  22. userList.add(u);
  23.  
  24. system.debug('u contains ' + u);
  25.  
  26. insert userList;
  27.  
  28. System.runas(u){
  29.  
  30. WEID__c[] csList = new WEID__c[]{};
  31. WEID__c cs = New WEID__c();
  32. cs.Name = 'CP Virtual Prepaid MC';
  33. cs.WEOppId__c = '012700000005qif';
  34.  
  35. csList.add(cs);
  36.  
  37. insert csList;
  38. system.debug('csList contains ' + csList);
  39.  
  40. //create Target records
  41. Target__c[] targetList = new Target__c[]{};
  42. Target__c t = new Target__c();
  43.  
  44. t.Name = 'Jun Test';
  45. t.OwnerId = u.Id;
  46. t.Salesperson__c = u.Id;
  47. t.Team__c = 'Virtual Sales EU';
  48. t.Year_End_Date__c = Date.newInstance(2015,12,31);
  49. t.Target__c = 100000;
  50. t.Month_End_Date__c = Date.newInstance(2015,06,30);
  51. targetList.add(t);
  52.  
  53. Target__c t1 = new Target__c();
  54. t1.Name = 'Jul Test';
  55. t1.OwnerId = u.Id;
  56. t1.Salesperson__c = u.Id;
  57. t1.Team__c = 'Virtual Sales EU';
  58. t1.Year_End_Date__c = Date.newInstance(2015,12,31);
  59. t1.Target__c = 100000;
  60. t1.Month_End_Date__c = Date.newInstance(2015,07,30);
  61. targetList.add(t1);
  62.  
  63. Target__c t2 = new Target__c();
  64. t2.Name = 'Jul 16 Test';
  65. t2.OwnerId = u.Id;
  66. t2.Salesperson__c = u.Id;
  67. t2.Team__c = 'Virtual Sales EU';
  68. t2.Year_End_Date__c = Date.newInstance(2016,12,31);
  69. t2.Target__c = 100000;
  70. t2.Month_End_Date__c = Date.newInstance(2016,07,30);
  71. targetList.add(t2);
  72.  
  73. insert targetList;
  74.  
  75. }
  76. }
  77.  
  78. static testMethod void testOppsPt1(){
  79.  
  80. List<Opportunity> immOpportunitys = new List<Opportunity>();
  81. for (Integer i = 0; i < 1; i++) {
  82.  
  83. Opportunity o = new Opportunity();
  84. o.name = 'Test Opp' + i;
  85. o.RecordTypeId = '012700000005qif';
  86.  
  87. /*ERROR >*/ o.OwnerId = u.Id;
  88. o.Ramp_Profile__c = 'Immediate';
  89. o.StageName = '1) Suspect';
  90. o.CloseDate = date.newInstance(2015,06,15);
  91. o.Monthly_Txn_Revenue_POS__c = 0;
  92. o.Annual_transaction_volume__c = 1000;
  93. o.Credit_Limit__c = 100.00;
  94. o.Date_Credit_Limit_Approved__c = date.newInstance(1901, 01, 01);
  95. o.Payment_Terms_Days__c = 5;
  96. o.Billing_Cycle__c = 'Daily';
  97. o.Annual_Settlement_Value__c = 100.00;
  98. o.Average_transaction_Value_POS__c = 1.00;
  99.  
  100. immOpportunitys.add(o);
  101. }
  102. insert immOpportunitys;
  103.  
  104. }
  105. }
  106.  
  107. static testMethod void testOppsPt1(){
  108. User u = [select Id from User where Username = 'astest@wexeurope.com'];
  109. List<Opportunity> immOpportunitys = new List<Opportunity>();
  110. for (Integer i = 0; i < 1; i++) {
  111. ...
  112. }
  113.  
  114. @isTest
  115. public class WE_OppUpdatesTest {
  116.  
  117. @testSetup
  118. static void dataSetup() {
  119. ...
  120. insert user;
  121. }
  122.  
  123. static void additionalDataSetup() {
  124. User u = [SELECT Id FROM User WHERE Name = 'yourname' LIMIT 1];
  125. System.runAs(u) {
  126. ... insert all additional records
  127. }
  128. }
  129.  
  130. static testMethod void test_something() {
  131. additionalDataSetup();
  132. ...
  133. }
  134.  
  135. static testMethod void test_somethingElse() {
  136. additionalDataSetup();
  137. ...
  138. }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement