can anyone please help with how to resolve this error?
I am getting this error Constructor not defined: [GA_AP_CreatePartnerUsers].<Constructor>()
at GA_AP_CreatePartnerUsers CreatePartnerUsers = new GA_AP_CreatePartnerUsers();
global class GA_AP_CreatePartnerUsers implements Database.Batchable{
global Set<Id> listOfContacts = new Set<Id>();
global String query = '';
global GA_AP_CreatePartnerUsers(Set<Id> contactsList){
System.debug('Contacts List : ' +contactsList);
listOfContacts= contactsList;
query = 'select id, Email,ARV_Agent_Portal_User_Id__c, phone, FirstName, LastName, AccountId,Account.Name, MailingStateCode, Agent_Code__c,vlocity_ins__Type__c from contact where id in :listOfContacts AND ARV_Agent_Portal_User_Id__c != Null AND AccountId != Null';
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<sObject> scope){
Map<Id, Account> accMap = new Map<Id, Account>();
Set<Id> accSet = new Set<Id>();
Map<String, User> userConMap = new Map<String, User>();
Map<String, Contact> conMap = new Map<String, Contact>();
List<User> usersToUpsert = new List<User>();
system.debug('scope:'+scope);
for(sobject s : scope){
Contact con = (Contact)s;
conMap.put(con.Id, con);
accSet.add(con.AccountId);
}
System.debug('***ConMap :***' +conMap);
System.debug('***accSet*** ' +accSet);
for(Account acc : [SELECT Id, Name, GA_Agency_Code__c, IsPartner FROM Account WHERE Id IN :accSet]){
System.debug('***acc*** ' +acc);
if(acc.IsPartner)
accMap.put(acc.Id, acc);
}
System.debug('***accMap***' +accMap);
for(User usr : [select id, contactid,FederationIdentifier from User where contactid in : conMap.keySet() and profile.Name = 'BCBSM FSA Login']){
userConMap.put(usr.contactId, usr);
}
System.debug('***userConMap***' +userConMap);
Organization thisOrg = [SELECT InstanceName,IsSandbox,Name,NamespacePrefix,OrganizationType FROM Organization];
Profile BCBSMFSAProfile = [SELECT Id FROM Profile WHERE Name LIKE '%BCBSM FSA Login%' Limit 1];
for(String conId : conMap.keySet()){
Contact con = conMap.get(conId);
User usr = userConMap.get(conId);
System.debug('***con***' +con);
System.debug('***ConMapSize***'+conMap.size());
System.debug('***usr**:'+usr);
if(con != Null && (accMap.containsKey(con.AccountId) && accMap.get(con.AccountId) != null && accMap.get(con.AccountId).GA_Agency_Code__c != null) && string.isNotBlank(con.Email) && String.isNotBlank(con.ARV_Agent_Portal_User_Id__c))
{
System.debug('***Debug Statement***');
if(usr != null){
System.debug('*UserIf*');
User u = new User(Id = usr.Id);
u.FederationIdentifier = con.Email;
u.Email=con.Email;
u.CommunityNickname = con.FirstName +' '+ con.LastName +' '+ con.Agent_Code__c;
/*Nickname is updated by concatenating the full name with Agent */
usersToUpsert.add(u);
}
else{
System.debug('***UserElse***');
String buildUserNameExt = '';
If (thisOrg.isSandbox){
buildUserNameExt = '.'+ thisOrg.InstanceName;
}
User PartnerUser = new User(FirstName = con.FirstName,
Username = con.FirstName.deleteWhitespace()+'.'+con.LastName.deleteWhitespace()+'-'+con.Agent_Code__c+'@bcbsm.agent'+buildUserNameExt,
ContactId = con.Id,
ProfileId = BCBSMFSAProfile.Id,
Alias =con.FirstName.substring(0,1) + string.valueof(con.Id).substring(12,18),
Email = con.Email,
EmailEncodingKey = 'UTF-8',
LastName = con.LastName,
/*Nickname is updated from Agent Id to Contact Full Name */
CommunityNickname = con.FirstName +' '+ con.LastName +' '+ con.Agent_Code__c,
TimeZoneSidKey = 'America/New_York',
LocaleSidKey = 'en_US',
LanguageLocaleKey = 'en_US',
StateCode = con.MailingStateCode,
FederationIdentifier = con.email,
isActive=true);
System.debug('PartnerUser Object&&&&&&&:'+PartnerUser );
usersToUpsert.add(PartnerUser);
}
}
}
System.debug('***usersToUpsert***' +usersToUpsert);
Database.upsert(usersToUpsert);
}
global void finish(Database.BatchableContext BC){
}
}
Test class:
@isTest
private class GA_AP_CreatePartnerUsers_Test {
private static testMethod void insertPartnerUser(){
{
UserRole userrole = [Select Id, DeveloperName From UserRole Where DeveloperName =
'System_Administrator' Limit 1];
user usr = GA_OBJ_TD01_TestDataCreation.UsrRec('System
Administrator','[email protected]','System Administrator');
usr.UserRoleId = userrole.id;
database.insert(usr);
system.runAs(usr){
//static testMethod void insertPartnerUser(){
List<Account> listOfaccs = new List<Account>();
List<Contact> lisOfcntcts = new List<Contact> ();
//Inserting an account & making it as partner
Account AORSRacc = GA_OBJ_TD01_TestDataCreation.AccRec();
AORSRacc.RecordTypeId=Schema.SObjectType.Account.getRecordTypeInfosByName().get('Account - Agency').getRecordTypeId();
AORSRacc.GA_Agency_Code__c='89899';
database.insert(AORSRacc);
Account AORSRacc1 = GA_OBJ_TD01_TestDataCreation.AccRec();
AORSRacc1.RecordTypeId=Schema.SObjectType.Account.getRecordTypeInfosByName().get('Account - Agency').getRecordTypeId();
AORSRacc1.GA_Agency_Code__c='89800';
database.insert(AORSRacc1);
listOfaccs.add(AORSRacc);
listOfaccs.add(AORSRacc1);
Contact conta = GA_OBJ_TD01_TestDataCreation.cntactRec(AORSRacc1.id);
conta.recordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByName().get('Account - Agency').getRecordTypeId();
conta.vlocity_ins__Type__c='Agent';
conta.ARV_Agent_Portal_User_Id__c='15768';
conta.Active__c = True;
lisOfcntcts.add(conta);
Contact conta1 = GA_OBJ_TD01_TestDataCreation.cntactRec(AORSRacc.id);
conta1.recordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByName().get('Contact -
Delegate').getRecordTypeId();
conta1.vlocity_ins__Type__c='Agent';
conta1.Active__c = True;
conta1.ARV_Agent_Portal_User_Id__c='15748';
conta1.email= '[email protected]';
lisOfcntcts.add(conta1);
database.insert(lisOfcntcts);
list<user> usrLst=new list<user>();
user hisusr = GA_OBJ_TD01_TestDataCreation.UsrRec('BCBSMTest Partner
User','[email protected]','BCBSM Both');
hisusr.ContactId = conta1.id;
hisusr.IsActive = True;
usrLst.add(hisusr);
insert usrLst;
GA_AP_CreatePartnerUsers CreatePartnerUsers = new GA_AP_CreatePartnerUsers();
Test.startTest();
ID HistoricalAccountCaseBOBBatchid = Database.executeBatch(CreatePartnerUsers);
Test.stopTest();
}
}
}
}