Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.01 KB | None | 0 0
  1. delete [select id from VOC__c];
  2.  
  3. Integer surveysCount = 500;
  4.  
  5. List<String> testUsers = new List<String> {
  6.     '0057E000004dZGxQAM',
  7.     '0057E000004dZGyQAM',
  8.     '0057E000004dZGzQAM',
  9.     UserInfo.getUserId()
  10. };
  11.  
  12. List<String> businessUnits = new List<String> {
  13.     'Commerce',
  14.     'Corporate',
  15.     'App and Device Support'
  16. };
  17.  
  18. List<String> contactChannels = new List<String> {
  19.     'Chat - Inbound',
  20.     'Email - Inbound',
  21.     'Messaging - Inbound',
  22.     'Voice - Inbound'
  23. };
  24.  
  25. List<VOC__c> surveys = new List<VOC__c>();
  26.  
  27. List<DateTime> surveyDates = new List<DateTime> {
  28.      Datetime.newInstance(2018, 5, 5),
  29.      Datetime.newInstance(2018, 4, 5),
  30.      Datetime.newInstance(2018, 3, 5),
  31.      Datetime.newInstance(2018, 2, 5),
  32.      Datetime.newInstance(2018, 1, 5),
  33.      Datetime.newInstance(2017, 12, 5),
  34.      Datetime.newInstance(2017, 11, 5)
  35. };
  36.  
  37. for (Integer j = 0; j < testUsers.size(); j++) {
  38.    
  39.     for (Integer i = 0; i < surveysCount; i++) {
  40.  
  41.         Integer dateIndex = Math.mod(i, surveyDates.size());
  42.         Integer buIndex = Math.mod(i, businessUnits.size());
  43.         Integer contactChannelIndex = Math.mod(i, contactChannels.size());
  44.  
  45.         Boolean isDissatisfied = Math.random() <= 0.10;
  46.         Boolean isFCR = Math.random() <= 0.5;
  47.         Boolean isTopTwo = !isDissatisfied;
  48.         Boolean isSolved = Math.random() >= 0.3;
  49.         Integer randInt = (Integer) (Math.random() * 100);
  50.         Integer npsScore = Math.mod(randInt, 10);
  51.        
  52.         VOC__c newSurvey = new VOC__c(
  53.             Athlete__c = testUsers.get(j),
  54.             Case__c = '5007E000007FTzkQAG',
  55.             Consumer__c = '0017E00000oVWdvQAG',
  56.             Survey_Date__c = surveyDates.get(dateIndex),
  57.             Is_Dissat__c = isDissatisfied,
  58.             Overall_Is_Top_2__c = !isDissatisfied,
  59.             NPS__c = npsScore,
  60.             Is_FCR__c = isFCR,
  61.             Athlete_Is_Top_2__c = isTopTwo,
  62.             Is_Solved__c = isSolved,
  63.             Contact_Channel__c = contactChannels.get(contactChannelIndex),
  64.             BU__c = businessUnits.get(buIndex)
  65.         );
  66.         surveys.add(newSurvey);
  67.     }
  68. }
  69.  
  70. insert surveys;
  71.  
  72.  
  73.  
  74.  
  75.  
  76. Integer usersNo = 3;
  77.  
  78. List<User> users = new List<User>();
  79.  
  80. Id managerId = UserInfo.getUserId();
  81.  
  82. for (Integer i = 0; i < usersNo; i++) {
  83.  
  84.     User u = new User(
  85.         Username          = 'bruce.wayne@gotham.com.nike' + String.valueOf(i),
  86.         FirstName         = 'FirstName' + String.valueOf(i),
  87.         LastName          = 'LastName' + String.valueOf(i),
  88.         Email             =  String.valueOf(i) + 'bruce.wayne@gotham.com',
  89.         Alias             = 'Batman' + String.valueOf(i),
  90.         CommunityNickname = 'Batman' + String.valueOf(i),
  91.         TimeZoneSidKey    = 'America/Los_Angeles',
  92.         LocaleSidKey      = 'en_US',
  93.         EmailEncodingKey  = 'ISO-8859-1',
  94.         LanguageLocaleKey = 'en_US',
  95.         ManagerId         = managerId,
  96.         ProfileId         = '00e7E000000IurjQAC'
  97.     );
  98.     users.add(u);
  99. }
  100.  
  101. insert users;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement