Sunday 27 November 2016

WSDL

Global class Workitemupdates{

global class workitemdata
    {//Input from portal to create/update workitem information in sfdc
            webservice String LegalEntityid;
            webservice String oppstage;
            webservice String accstatus;
            webservice String wrkitmstatus;
            webservice String wrkitmtype;
            webservice String Reasoncode;
            webservice String wrkitemid;      
    }
global class returnWorkitemresponse
    { // response from SFDC to portal with created/updated record details.                          
            webservice String legalEntityId;
            webservice String Wrkitmid;
            webservice String Status;      
    }
webservice static returnWorkitemresponse createupdateworkitems(workitemdata leadlst)
            { // method to load lead data/convert leads and return response
                List<returnWorkitemresponse> response = new List<returnWorkitemresponse>();
               
                Account  Accdetails=[select id,name,AccountNumber,Account_Status__c from Account where AccountNumber=leadlst.LegalEntityid];
                Opportunity Oppdetails=[Select id,Name,Probability,StageName,AccountId from Opportunity where Account.AccountNumber==leadlst.LegalEntityid ];
QC_Checklist__c wrkitm=[Select Opportunity_Merchant_Name__c,Type__c,Contract_Status__c,Reject_Reason__c,Boarding_Source__c from QC_Checklist__c where relationship.opportunityid=Oppdetails.id];
                if(leadlst.wrkitemid='null'){
                    //workitem creation
                    QC_Checklist__c workitem1 = new QC_Checklist__c();
                                workitem1.Opportunity_Merchant_Name__c=leadlst.LegalEntityid;
                                workitem1.Type__c=leadlst.wrkitmtype;
                                workitem1.Contract_Status__c=leadlst.wrkitmstatus;
                                workitem1.Reject_Reason__c=;//doubt
                                workitem1.Boarding_Source__c=leadlst.Reasoncode;
                                insert workitem1;
   
                    }else if(Accdetails.Account_Status__c = 'Application')
                         {
                           //  QC_Checklist__c wrkitm=[Select Opportunity_Merchant_Name__c,Type__c,Contract_Status__c,Reject_Reason__c,Boarding_Source__c from QC_Checklist__c where relationship.opportunityid=Oppdetails.id];
                        //update workitem details
if(wrkitm.Contract_Status__c='complete'){
       wrkitm.Opportunity_Merchant_Name__c=leadlst.LegalEntityid;
                                wrkitm.Type__c=leadlst.wrkitmtype;
                                wrkitm.Contract_Status__c=leadlst.wrkitmstatus;
                                wrkitm.Reject_Reason__c=;//doubt
                                update wrkitm;
Oppdetails.StageName='Closed Won';
update Oppdetails;
Accdetails.Account_Status__c='Active';

}else if(wrkitm.Contract_Status__c='Referal'){
wrkitm.Contract_Status__c='Referal';
update wrkitm;
//noified to  CR ops team
}

                         }else if(Accdetails.Account_Status__c = 'Active')
                         {
          case c1=new case();
                                    c1.Account=Accdetails.id;
                                    c1.Status=leadlst.wrkitmstatus;
                                    c1.Type=leadlst.wrkitmtype;
                                    insert c1;

                       
                         }else if(Accdetails.Account_Status__c = 'Service')
                         {
 case c1=new case();
                                    c1.Account=Accdetails.id;
                                    c1.Status=leadlst.wrkitmstatus;
                                    c1.Type=leadlst.wrkitmtype;
                                    insert c1;
                       
                         }
               
               
                   
               
                return returnWorkitemresponse;
            }

}

Monday 21 November 2016

@isTest

public class TSBankContactCreate_Test2{


 static testMethod void myUnitTest1() {
    




String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'Contact' and Name = 'Partner Contact'].Id;

 
//Insert Bank__c record
Bank__c bnk = new Bank__c();
bnk.Name = 'IDBI';
insert bnk;
ApexPages.currentPage().getParameters().put('Id',bnk.id);
User uname=[Select Id,Name,profile.Name from User Where profile.Name ='SYSADMIN_CAJ2' AND isActive=true limit 1];
Contact newContact = new Contact(
                  LastName = 'Test',
                  RecordTypeId = strRecordTypeId,
                  Bank__c=bnk.id,
                  Invisible_Bank__c=bnk.id
                 );
                insert newContact;
                   // load the extension
       // TSBankContactCreateExtention oCEE = new TSBankContactCreateExtention (new ApexPages.StandardController(contact));
    List<Contact> accountList = [SELECT Id FROM Contact where Id = : newContact.Id];            
//ApexPages.StandardController sc = new ApexPages.StandardController(accountList);
ApexPages.StandardSetController sc = new ApexPages.StandardSetController(accountList);
 TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);

System.runAs(uname) 
{
Test.StartTest();   
TSBCon.autoRun();
Test.StopTest();
}
}
/*
 static testMethod void myUnitTest2() {
 //ApexPages.StandardController sc = new ApexPages.StandardController(/apex/TSBankContactCreate);
 //TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);
    
String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'Contact' and Name = 'Partner Contact'].Id;

 
//Insert Bank__c record
Bank__c bnk = new Bank__c();
bnk.Name = 'IDBI';
insert bnk;

//Insert Branch__c record
Branch__c brnch = new Branch__c();
brnch.Name = 'AP';
brnch.Bank__c=bnk.id;
insert brnch;

ApexPages.currentPage().getParameters().put('Id',brnch.id);
User uname=[Select Id,Name,profile.Name from User Where profile.Name ='SYSADMIN_CAJ2' AND isActive=true limit 1];

Contact newContact = new Contact(
                  LastName = 'Test',
                  RecordTypeId = strRecordTypeId,
                  Bank_Branch__c=brnch.id,
                  Bank__c=brnch.Bank__c
                 );
                insert newContact;
                
ApexPages.StandardController sc = new ApexPages.StandardController(newContact);
 TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);

System.runAs(uname) {
Test.StartTest();   
TSBCon.autoRun();
Test.StopTest();

}
}

 static testMethod void myUnitTest3() {
    
//ApexPages.StandardController sc = new ApexPages.StandardController(/apex/TSBankContactCreate);
      //  TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);

String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'Contact' and Name = 'Partner Contact'].Id;

//Insert Bank__c record
Bank__c bnk = new Bank__c();
bnk.Name = 'IDBI';
insert bnk; 
//Insert Referral_Partner_Boarding__c record
Referral_Partner_Boarding__c Rpb = new Referral_Partner_Boarding__c();
Rpb.Name = 'RefferalName';
Rpb.Converted_Bank__c=bnk.id;
insert Rpb;

ApexPages.currentPage().getParameters().put('Id',Rpb.id);
User uname=[Select Id,Name,profile.Name from User Where profile.Name ='SYSADMIN_CAJ2' AND isActive=true limit 1];

Contact newContact = new Contact(
                  LastName = 'Test',
                  RecordTypeId = strRecordTypeId,
                  Bank__c=Rpb.Converted_Bank__c,
                   Referral_Partner_Boarding__c=Rpb.id
                 );
                insert newContact;
ApexPages.StandardController sc = new ApexPages.StandardController(newContact);
 TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);

System.runAs(uname) {
Test.StartTest();   
TSBCon.autoRun();
Test.StopTest();

}

}*/

}

teeeeee

@isTest

public class TSBankContactCreate_Test2{

static testMethod void myUnitTest() {
       //RecordType rt = [SELECT Id,Name FROM RecordType r WHERE r.Name='Partner Contact' LIMIT 1];
      String RId='';
      //Insert Bank__c record
    //Bank__c bnk = new Bank__c();
    //bnk.Name = 'IDBI';
   // insert bnk; 
    //String currentId=bnk.id;
      String currentId='a0770000004BDUH';
      PageReference pageRef = null;
      //List<Bank__c> bank = new List< Bank__c>();
      for(RecordType r : [Select Id From RecordType  where Name ='Partner Contact'])
          {
            RId=r.Id;
          }
        /*  for (Bank__c bankfind : [Select Id from Bank__c Where Id = :currentId limit 1])
             {
                bank.add(bankfind);
             }
             */
       Contact c = new Contact(
                LastName = 'Enter a valid last name',
                RecordTypeId = RId,
                Bank__c=currentId
               // Bank__c=currentId
              //  Invisible_Bank__c=currentId
                 );
               insert c;
               pageRef = new PageReference('/' + c.Id+'/e?retURL=%2F'+ currentId);
               List<Contact> accountList = [SELECT Id FROM Contact where Id = : c.Id];
               ApexPages.StandardSetController sc = new ApexPages.StandardSetController(accountList);
             //  ApexPages.StandardSetController sc = new ApexPages.StandardSetController(c);
      TSBankContactCreateExtention ts = new TSBankContactCreateExtention(sc);
       ts.autoRun();

             // System.runAs(newContact) {
// The following code runs as user 'u'
//System.debug('Current User: ' + newContact.LastName);
//System.debug('Current Profile: ' + RId);// }
  }

 /*
static testMethod void myUnitTest() {
       //RecordType rt = [SELECT Id,Name FROM RecordType r WHERE r.Name='Partner Contact' LIMIT 1];
      String RId='';
      //String RId= [Select Id From RecordType where Name ='Partner Contact'].Id;

      //Insert Bank__c record
    Bank__c bnk = new Bank__c();
    bnk.Name = 'IDBI';
    insert bnk; 
     //String currentId=bnk.id;
      PageReference pageRef = null;
      List<Bank__c> bank = new List< Bank__c>();
      for(RecordType r : [Select Id From RecordType  where Name =: 'Partner Contact'])
          {
           RId=r.Id;
          }
        
       Contact c = new Contact(
                LastName = 'Enter a valid last name',
                RecordTypeId = RId,
                Bank__c=bnk.id
               // Bank__c=currentId
              //  Invisible_Bank__c=currentId
                 );
               insert c;
               pageRef = new PageReference('/' + c.Id+'/e?retURL=%2F'+ bnk.id);
               List<Contact> accountList = [SELECT Id FROM Contact where Id = : c.Id];
               ApexPages.StandardSetController sc = new ApexPages.StandardSetController(accountList);
             //  ApexPages.StandardSetController sc = new ApexPages.StandardSetController(c);
      TSBankContactCreateExtention ts = new TSBankContactCreateExtention(sc);
       ts.autoRun();

             // System.runAs(newContact) {
// The following code runs as user 'u'
//System.debug('Current User: ' + newContact.LastName);
//System.debug('Current Profile: ' + RId);// }
  }





 static testMethod void myUnitTest1() {
    
PageReference pageRef = null;
//ApexPages.StandardController sc = new ApexPages.StandardController(/apex/TSBankContactCreate);
 //TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);


String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'Contact' and Name = 'Partner Contact'].Id;

 
//Insert Bank__c record
Bank__c bnk = new Bank__c();
bnk.Name = 'IDBI22';
insert bnk;

//ApexPages.currentPage().getParameters().put('Id',bnk.id);
User uname=[Select Id,Name,profile.Name from User Where profile.Name ='SYSADMIN_CAJ2' AND isActive=true limit 1];
Contact newContact = new Contact(
                  LastName = 'Test',
                  RecordTypeId = strRecordTypeId,
                  Bank__c=bnk.id,
                  Invisible_Bank__c=bnk.id
                 );
                insert newContact;

                

System.runAs(uname) 
{

Test.StartTest();   
//ApexPages.StandardController sc = new ApexPages.StandardController('/' + currentId+'/e?retURL=%2F'+ bkid);
 //TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);

    pageRef = new PageReference('/' + newContact.id+'/e?retURL=%2F'+ bnk.id);
               List<Contact> accountList = [SELECT Id FROM Contact where Id = : newContact.id];
               ApexPages.StandardSetController sc = new ApexPages.StandardSetController(accountList);
             //  ApexPages.StandardSetController sc = new ApexPages.StandardSetController(c);
      TSBankContactCreateExtention ts = new TSBankContactCreateExtention(sc);
ts.autoRun();
//TSBCon.autoRun();
Test.StopTest();
}
}


static testMethod void myUnitTest2() {
 //ApexPages.StandardController sc = new ApexPages.StandardController(/apex/TSBankContactCreate);
 //TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);
    
String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'Contact' and Name = 'Partner Contact'].Id;

 
//Insert Bank__c record
Bank__c bnk = new Bank__c();
bnk.Name = 'IDBI';
insert bnk;

//Insert Branch__c record
Branch__c brnch = new Branch__c();
brnch.Name = 'AP';
brnch.Bank__c=bnk.id;
insert brnch;

ApexPages.currentPage().getParameters().put('Id',brnch.id);
User uname=[Select Id,Name,profile.Name from User Where profile.Name ='SYSADMIN_CAJ2' AND isActive=true limit 1];

Contact newContact = new Contact(
                  LastName = 'Test',
                  RecordTypeId = strRecordTypeId,
                  Bank_Branch__c=brnch.id,
                  Bank__c=brnch.Bank__c
                 );
                insert newContact;
                
ApexPages.StandardController sc = new ApexPages.StandardController(newContact.id);
 TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);

System.runAs(uname) {
Test.StartTest();   
TSBCon.autoRun();
Test.StopTest();

}
}

 static testMethod void myUnitTest3() {
    
//ApexPages.StandardController sc = new ApexPages.StandardController(/apex/TSBankContactCreate);
      //  TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);

String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'Contact' and Name = 'Partner Contact'].Id;

//Insert Bank__c record
Bank__c bnk = new Bank__c();
bnk.Name = 'IDBI';
insert bnk; 
//Insert Referral_Partner_Boarding__c record
Referral_Partner_Boarding__c Rpb = new Referral_Partner_Boarding__c();
Rpb.Name = 'RefferalName';
Rpb.Converted_Bank__c=bnk.id;
insert Rpb;

ApexPages.currentPage().getParameters().put('Id',Rpb.id);
User uname=[Select Id,Name,profile.Name from User Where profile.Name ='SYSADMIN_CAJ2' AND isActive=true limit 1];

Contact newContact = new Contact(
                  LastName = 'Test',
                  RecordTypeId = strRecordTypeId,
                  Bank__c=Rpb.Converted_Bank__c,
                   Referral_Partner_Boarding__c=Rpb.id
                 );
                insert newContact;
ApexPages.StandardController sc = new ApexPages.StandardController(newContact.id);
 TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc);

System.runAs(uname) {
Test.StartTest();   
TSBCon.autoRun();
Test.StopTest();

}

}*/

}



+++++++++++++++++++++++++++++++++++++++++


@isTest public class TSBankContactCreate_Test2{ static testMethod void myUnitTest1() { ApexPages.StandardController sc = new ApexPages.StandardController(/apex/TSBankContactCreate); TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc); String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'Contact' and Name = 'Partner Contact'].Id; //Insert Bank__c record Bank__c bnk = new Bank__c(); bnk.Name = 'IDBI'; insert bnk; ApexPages.currentPage().getParameters().put('Id',bnk.id); User uname=[Select Id,Name,profile.Name from User Where profile.Name ='SYSADMIN_CAJ2' AND isActive=true limit 1]; Contact newContact = new Contact( LastName = 'Test', RecordTypeId = strRecordTypeId, Bank__c=bnk.id, Invisible_Bank__c=bnk.id ); insert newContact; ApexPages.StandardController sc = new ApexPages.StandardController(newContact); TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc); System.runAs(uname) { Test.StartTest(); TSBCon.autoRun(); Test.StopTest(); } } static testMethod void myUnitTest2() { //ApexPages.StandardController sc = new ApexPages.StandardController(/apex/TSBankContactCreate); //TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc); String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'Contact' and Name = 'Partner Contact'].Id; //Insert Bank__c record Bank__c bnk = new Bank__c(); bnk.Name = 'IDBI'; insert bnk; //Insert Branch__c record Branch__c brnch = new Branch__c(); brnch.Name = 'AP'; brnch.Bank__c=bnk.id; insert brnch; ApexPages.currentPage().getParameters().put('Id',brnch.id); User uname=[Select Id,Name,profile.Name from User Where profile.Name ='SYSADMIN_CAJ2' AND isActive=true limit 1]; Contact newContact = new Contact( LastName = 'Test', RecordTypeId = strRecordTypeId, Bank_Branch__c=brnch.id, Bank__c=brnch.Bank__c ); insert newContact; ApexPages.StandardController sc = new ApexPages.StandardController(newContact); TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc); System.runAs(uname) { Test.StartTest(); TSBCon.autoRun(); Test.StopTest(); } } static testMethod void myUnitTest3() { //ApexPages.StandardController sc = new ApexPages.StandardController(/apex/TSBankContactCreate); // TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc); String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'Contact' and Name = 'Partner Contact'].Id; //Insert Bank__c record Bank__c bnk = new Bank__c(); bnk.Name = 'IDBI'; insert bnk; //Insert Referral_Partner_Boarding__c record Referral_Partner_Boarding__c Rpb = new Referral_Partner_Boarding__c(); Rpb.Name = 'RefferalName'; Rpb.Converted_Bank__c=bnk.id; insert Rpb; ApexPages.currentPage().getParameters().put('Id',Rpb.id); User uname=[Select Id,Name,profile.Name from User Where profile.Name ='SYSADMIN_CAJ2' AND isActive=true limit 1]; Contact newContact = new Contact( LastName = 'Test', RecordTypeId = strRecordTypeId, Bank__c=Rpb.Converted_Bank__c, Referral_Partner_Boarding__c=Rpb.id ); insert newContact; ApexPages.StandardController sc = new ApexPages.StandardController(newContact); TSBankContactCreateExtention TSBCon = new TSBankContactCreateExtention(sc); System.runAs(uname) { Test.StartTest(); TSBCon.autoRun(); Test.StopTest(); } } }