-
ChatterFeed
-
0Best Answers
-
2Likes Received
-
0Likes Given
-
106Questions
-
73Replies
Test class Coverage issue need to cover 85%
Team i need to cover 85% till now its only 39%.... Bold font is still need to cover.
@isTest global class OSM_SW_hk_EffectiveAccount_Test { static testMethod void validateTest(){ TestProductSetupReq testReq = new TestProductSetupReq(); testReq.permissionSetName = 'OSM_Support_Admin'; testReq.accountGroupName = 'TestingAccountGroup'; testReq.accountName = 'TestingAccount'; testReq.compositeProductName = 'Connected Diagnostics'; testReq.compositeProductSKU = '1234567-BUS'; testReq.compositeProductGroupName = 'DA'; testReq.compositeProductProductType = 'Aggregated'; testReq.componentProductName = 'CD Base-BUS'; testReq.componentProductStatus = 'Released'; testReq.componentProductSKU = '1301298-BUS'; testReq.componentProductGroupName = 'DA'; testReq.componentProductPackageName = 'Base'; testReq.priceListName = 'TestPriceList'; testReq.specName = 'TestName'; TestCompletedTransactionSetUpRes transecRes = new TestCompletedTransactionSetUpRes(); transecRes = OSM_TestDataCreationUtility.createProductSetUp(testReq); Id portal_PROFILE_ID = [SELECT Id FROM Profile WHERE Name = 'IAM_Site_Admin_Community' Limit 1 ].Id; //Id roleId=[select id,name from UserRole where name='CumminsFleetsCustomerUser' limit 1].id; UserRole portalRole = [Select Id From UserRole Where PortalType = 'None' Limit 1]; system.debug('portalRole is ' + portalRole); Profile profile1 = [Select Id from Profile where name = 'System Administrator']; User portalAccountOwner2 = new User( UserRoleId = portalRole.Id, ProfileId = profile1.Id, Username ='test24446@test.com', Alias = 'batman', Email='bruce.wayne@wayneenterprises.com', EmailEncodingKey='UTF-8', Firstname='Bruce', Lastname='Wayne', LanguageLocaleKey='en_US', LocaleSidKey='en_US', TimeZoneSidKey='America/Chicago', OSM_Storefront_User_Type__c ='Distributor Admin' ); Database.insert(portalAccountOwner2); Account portalAccount2 = new Account( Name = 'TestAccount2', Type= 'Distributor Branch Account', OwnerId = portalAccountOwner2.Id, OSM_Preferred_Billing_Frequency_Lock__c=false, BMS_Customer_ID__c='1234', OSM_Preferred_Payment_Method__c='po', OSM_Preferred_Payment_IsBolt_PO__c=false ); System.runAs(portalAccountOwner2){ Database.insert(portalAccount2); } //Create contact Contact contact1 = new Contact( FirstName = 'Test', Lastname = 'McTesty', IAM_Contact_Status__c='Pending', Username__c = 'testUserName654@gmail.com', AccountId = portalAccount2.Id, Email ='test@test.com' ); System.runAs(portalAccountOwner2){ Database.insert(contact1); } System.runAs(transecRes.objSetupDate.loggedInUser) { Attachment attachment = new Attachment(); attachment.Body = Blob.valueOf('test data'); attachment.Name = String.valueOf('FSDInvoice.txt'); attachment.ParentId = transecRes.invoice.Id; insert attachment; system.debug('==Attachment inserted=='); } User testUser = new User(); testUser.FirstName = 'Testttt'; testUser.LastName = 'lasttt'; testUser.UserName = 'test2@test.com'; testUser.Email = 'bruce.wayne@wayneenterprises.com'; testUser.Alias = 'batman'; testUser.ContactId = contact1.Id; testUser.CommunityNickname = 'test12345h'; testUser.ProfileId =portal_PROFILE_ID; testUser.TimeZoneSidKey = 'America/Los_Angeles'; testUser.isActive = true; testUser.LocaleSidKey = 'en_US'; testUser.LanguageLocaleKey = 'en_US'; testUser.EmailEncodingKey = 'ISO-8859-1'; //testUser.UserRoleId = portalRole.Id; testUser.OSM_Storefront_User_Type__c ='Distributor Admin'; System.runAs(portalAccountOwner2){ insert testUser; } // Creating address System.runAs(portalAccountOwner2) { Account account = transecRes.objSetupDate.account; account.Bolt_Customer_Account_Status__c = 'Active'; update account; Contact contact2 = new Contact( FirstName = 'Test12', Lastname = 'McTesty9356', IAM_Contact_Status__c='Pending', Username__c = 'testUserName6789@gmail.com', AccountId = account.Id, Email ='test129@test.com', IAM_Contact_Owner__c =portalAccountOwner2.id ); insert contact2; effectiveAccount_enable_ProfileUserType__c effAccPro = new effectiveAccount_enable_ProfileUserType__c(); effAccPro.Name ='Distributor Admin'; effAccPro.Enable_Effective_Account_Selection__c=true; insert effAccPro; effectiveAccount_enable_ProfileUserType__c effAccPro1 = new effectiveAccount_enable_ProfileUserType__c(); effAccPro1.Name ='Regular'; effAccPro1.Enable_Effective_Account_Selection__c=true; insert effAccPro1; effectiveAccount_enable_ProfileUserType__c effAccPro2 = new effectiveAccount_enable_ProfileUserType__c(); effAccPro2.Name ='SSOEM Admin'; effAccPro2.Enable_Effective_Account_Selection__c=true; insert effAccPro2; Map < String, Object > inputMap = new Map < String, Object > (); ccrz.cc_bean_CartSummary cartSum = new ccrz.cc_bean_CartSummary(transecRes.cart); inputMap.put('version',7); inputMap.put('storefront','SoftwareStore'); inputMap.put('ownerId',transecRes.objSetupDate.objUserID); inputMap.put('cartId',transecRes.cart.Id); inputMap.put('sizing','{cart={sz_assc=false, sz_data=sz_s, sz_skiptrz=true}}'); inputMap.put('CartBean',cartSum ); inputMap.put(ccrz.cc_hk_EffectiveAccount.PARAM_ACCOUNT_ID,transecRes.order.ccrz__Account__c); Test.startTest(); OSM_SW_cc_hk_Order objCls = new OSM_SW_cc_hk_Order(); Map < String, Object > returnMap = objCls.place(inputMap); OSM_SW_cc_hk_Order.processRefundForFailedOSMOrderPlacedProcess(); inputMap = new Map < String, Object > (); try { OSM_SW_hk_EffectiveAccount Obj = new OSM_SW_hk_EffectiveAccount(); //invoiceCls.invMap=ab; system.debug('Inside Test method'); returnMap = Obj.fetchAccounts(inputMap); obj.fetchAccounts(null); OSM_SW_AccountDao.getDistributorAccountsHierarchy(transecRes.objSetupDate.account.id); OSM_SW_AccountDao.getAccountsHierarchy(transecRes.objSetupDate.account.id); // List<ID> actid =new List<ID>(); // actid.add(transecRes.objSetupDate.account.id); //OSM_SW_AccountDao.getAListOfAccount(setId); // OSM_SW_AccountDao.getDistributorAdminAccountRelateData(transecRes.objSetupDate.account.id); OSM_SW_AccountDao.getDistributorAdminAccountRelateData(portalAccount2.id); } catch (Exception ex) {} Test.stopTest(); } } } ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Main Apex Class global with sharing class OSM_SW_hk_EffectiveAccount extends ccrz.cc_hk_EffectiveAccount { global virtual override Map<String,Object> fetchAccounts(Map<String,Object> inputData) { String accountID = (String) inputData.get(PARAM_ACCOUNT_ID); ccrz.ccLog.log('FIL_FGP_hk_EffectiveAccount: EN: fetchAccounts inputData--->' + inputData); ccrz.cclog.log('FIL_FGP_hk_EffectiveAccount ccrz.cc_CallContext.currUserId: EN: '); // Jan 29, updated by Yubo for SSOEM update, we will start to use try { String distributorProfilename = Label.DistributorAdminProfileName; ccrz.ccLog.log('OSM_SW_hk_EffectiveAccount: EN: filterAccounts distributorProfilename' + distributorProfilename); Id profileId = UserInfo.getProfileId(); Id userId = ccrz.cc_CallContext.currUserId; Boolean effectiveSelectEnabled = false; String profileName =[Select Id, Name from Profile where Id=:profileId].Name; ccrz.ccLog.log('OSM_SW_hk_EffectiveAccount: EN: filterAccounts profileName' + profileName); List<User> currUser = [SELECT Id, OSM_Storefront_User_Type__c FROM User WHERE id=:userId]; String userType = ''; if(!currUser.isEmpty()){ if(!String.isBlank(currUser[0].OSM_Storefront_User_Type__c)){ effectiveAccount_enable_ProfileUserType__c featureSwitch = effectiveAccount_enable_ProfileUserType__c.getInstance(String.valueOf(currUser[0].OSM_Storefront_User_Type__c)); effectiveSelectEnabled = featureSwitch.Enable_Effective_Account_Selection__c; userType = featureSwitch.Name; } } ccrz.ccLog.log(LoggingLevel.DEBUG,'effectiveSelectEnabled ' + effectiveSelectEnabled + ' ::'+userType); ccrz.ccLog.log('OSM_SW_hk_EffectiveAccount: EN: filterAccounts accountID' + accountID); if(Test.isRunningTest()){ effectiveSelectEnabled=true; } if(effectiveSelectEnabled){ List<Account> accountList; //if(profileName == distributorProfilename){ ccrz.ccLog.log('OSM_SW_hk_EffectiveAccount: EN: accContactSelected ' + Cache.Session.contains('accContactSelected')); if(accountID != ccrz.cc_CallContext.effAccountId && !Cache.Session.contains('accContactSelected')){ ccrz.ccLog.log('OSM_SW_hk_EffectiveAccount: EN: accContactSelected 1'); ccrz.cc_CallContext.effAccountId = accountID; } if(userType == 'Distributor Admin'|| Test.isRunningTest()){ Account currAcc = OSM_SW_AccountDao.getDistributorAdminAccountRelateData(accountID); if(currAcc.Type == 'Distributor Branch Account'){ accountList = OSM_SW_AccountDao.getDistributorAccountsHierarchy(currAcc.Parent.ParentId); }else{ accountList = OSM_SW_AccountDao.getDistributorAccountsHierarchy(currAcc.ParentId); } ccrz.ccLog.log('OSM_SW_hk_EffectiveAccount: EN: filterAccounts accountList 1' + accountList); } else{ accountList = OSM_SW_AccountDao.getAccountsHierarchy(accountID); ccrz.ccLog.log('OSM_SW_hk_EffectiveAccount: EN: filterAccounts accountList 2' + accountList); } List<ccrz.cc_bean_EffectiveAccount> effAcctBeans = new List<ccrz.cc_bean_EffectiveAccount>(); map<string,account> accountmap = new map<string,account>(); list<account> sortedaccounts =new list<account>(); for(Account acc:accountList)accountmap.put(acc.name,acc); list<string> sortvalues = new list<string>(accountmap.keyset()); sortvalues.sort(); for(string str :sortvalues){ if(accountmap.containskey(str)){ sortedaccounts.add(accountmap.get(str)); } } Set<Id> accountSet = new Set<Id>(); for (Account acct: sortedaccounts) { accountSet.add(acct.Id); ccrz.cc_bean_EffectiveAccount acctBean = new ccrz.cc_bean_EffectiveAccount(acct); // change to acctBean extrinsic Map<String, String> acctBean.accountType=acct.accountNumber;////Rupesh Added Map<String, String> externalData = new Map<String,String>(); externalData.put('LocationCode', acct.IAM_Service_Provider_Code__c); //externalData.put('DistributorType', acct.Type); externalData.put('DistributorType', 'Distributor Branch Account'); if(accountID == acct.Id){ externalData.put('DistributorType','Distributor Account'); } acctBean.extrinsic = externalData; effAcctBeans.add(acctBean); // ccrz.ccLog.log('ACNO: OSM_SW_hk_EffectiveAccount: EN: filterAccounts acctBean ' + acct.name); // ccrz.ccLog.log('OSM_SW_hk_EffectiveAccount: EN: filterAccounts acctBean' + acctBean); } ccrz.ccLog.log('OSM_SW_hk_EffectiveAccount: EN: filterAccounts accountList size' + accountList.size()); ccrz.ccLog.log('OSM_SW_hk_EffectiveAccount: EN: filterAccounts effAcctBeans size' + effAcctBeans.size()); inputData.put(PARAM_EFFACCOUNT_LIST, effAcctBeans); return inputData; } else{ // if(accountList.isEmpty()){ ccrz.ccLog.log('ACNO: OSM_SW_hk_EffectiveAccount: EN: filterAccounts acctBean Land in else statement'); Map<String,Object> ori_returnMap = super.fetchAccounts(inputData); Set<String> accKey = ori_returnMap.keySet(); List<ccrz.cc_bean_EffectiveAccount> effectAccts = new List<ccrz.cc_bean_EffectiveAccount>(); Set<String> accIds = new Set<String>(); accIds.add(String.valueOf(inputData.get('AccountID'))); List<Account> effacctList = OSM_SW_AccountDao.getAListOfAccount(accIds); for(Account effacct :effacctList){ ccrz.cc_bean_EffectiveAccount newacctBean = new ccrz.cc_bean_EffectiveAccount(effacct); effectAccts.add(newacctBean); } ccrz.ccLog.log('ACNO: OSM_SW_hk_EffectiveAccount: EN: filterAccounts acctBean effectAccts size'+effectAccts.size()); ori_returnMap.put('EffectiveAccounts',effectAccts); return ori_returnMap; // } } }catch (Exception ex) { ccrz.ccLog.log('FIL_FGP_hk_EffectiveAccount: ERR: filterAccounts Message--->' + ex.getMessage()); ccrz.ccLog.log('FIL_FGP_hk_EffectiveAccount: ERR: filterAccounts Line Number--->' + ex.getLineNumber()); ccrz.ccLog.log('FIL_FGP_hk_EffectiveAccount: ERR: filterAccounts Cause--->' + ex.getCause()); } ccrz.ccLog.log('FIL_FGP_hk_EffectiveAccount: effectiveAccount' + ccrz.cc_CallContext.currAccountId+' <==>' +ccrz.cc_CallContext.effAccountId); return inputData; } }
- rupesh ranjan
- June 27, 2020
- Like
- 0
Any one suggest for Test class for below constructor of main class
public class OSM_SW_TaxExemptionContactCtrl { private account primaryaccount ; public OSM_SW_TaxExemptionContactCtrl(){ Id recid = apexpages.currentpage().getparameters().get('accountid'); if(recid!=null){ primaryaccount = [select id,Customer_BMS_number__c,BOLT_Account_Number__c,IAM_Service_Provider_Code__c,BMS_Customer_ID__c,BMS_Customer_ID_Junction__c from account where id=:recid limit 1]; if(primaryaccount.Customer_BMS_number__c!=null){ CustomerNumber= primaryaccount.Customer_BMS_number__c; }else if(primaryaccount.BOLT_Account_Number__c!=null){ CustomerNumber= primaryaccount.BOLT_Account_Number__c; }else { CustomerNumber= primaryaccount.IAM_Service_Provider_Code__c; } } String myGeneratedFileName = 'Tax Exemption ContactForm.pdf'; Apexpages.currentPage().getHeaders().put('content-disposition', 'attachment; filename='+myGeneratedFilename); Apexpages.currentPage().getHeaders().put('content-disposition', 'inline; filename='+myGeneratedFilename); } ]
- rupesh ranjan
- April 24, 2020
- Like
- 0
How to retrive data REST API(GET) and bind through Jquery in Page block table
How to retrive data REST API(GET) and bind through Jquery in Page block table?
- rupesh ranjan
- March 28, 2016
- Like
- 0
I need to bind data with Jquery
I don't have any idea about Jquery how to use and I need to bind data with Jquery Pls someone help its urgent
<apex:page Controller="DemomailReporttab" sidebar="false" showheader="false" readOnly="true"> <apex:form > <apex:pageblock > <c:PageBlockTableEnhancerADV targetPbTableIds="pbt" pageSizeOptions="5,10,15,30" defaultPageSize="15" enableExport="false"/> <apex:pageBlockTable value="{!performcallout}" var="wrap" width="100%" id="pbt" styleClass="tablesorter" headerClass="header"> <apex:column headerValue="Source" value="{!wrap.TrafficSource}"/> <apex:column headerValue="Unique Viewers" value="{!wrap.UniqueViewer}"/> <apex:column headerValue="Average Duration" value="{!wrap.AvgDuration}"/> <apex:column headerValue="Total Duration" value="{!wrap.TotalDuration}"/> <apex:column headerValue="Total Views"> <apex:commandLink value="{!wrap.TotalViews}" /> </apex:column> </apex:pageBlockTable> </apex:pageblock> </apex:form> </apex:page>
public class DemomailReporttab{ public DemomailReporttab(ApexPages.StandardController controller) { } public DemomailReporttab() {} public String startdate{get; set;} public String enddate{get; set;} public String Acode= Userinfo.getuserid(); public String Oid = UserInfo.getOrganizationId(); public string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; Blob cryptoKey= EncodingUtil.base64Decode(c); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); public String b64Data4 = EncodingUtil.base64Encode(encryptedData4); public String b64Data5 = EncodingUtil.base64Encode(encryptedData5); public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); public Transient List<DemoMailDetailReport> DemomailReportValue{get;set;} public List<DemoMailDetailReport> getperformcallout(){ DemomailReportValue = new List<DemoMailDetailReport>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); string url = 'https://www.demomail.net/sf/api/DashBoard?AUCode='+aucode+'&SOrgID='+ocode; req.setEndpoint(url); req.setMethod('GET'); res = http.send(req); if(res.getstatusCode() == 200 && res.getbody() != null) { String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r',''); DemomailReportValue =(List<DemoMailDetailReport>)System.JSON.deserialize(replaceIllegal,List<DemoMailDetailReport>.class); } return DemomailReportValue; } }
- rupesh ranjan
- March 25, 2016
- Like
- 0
How to set authentication for other SMTP in this mail code
How to set authentication for other SMTP in this mail code
public pageReference send(){ Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); List<String> ccAddresses =new List<String>(); if (AddRecep != '' && AddRecep != null) { ccAddresses = AddRecep.split(';'); email.setTargetObjectId(conId); email.setCcAddresses(ccAddresses); email.setSubject(subject); email.setHtmlBody(body); for(OrgWideEmailAddress owa : [select id, Address, DisplayName from OrgWideEmailAddress]) { if(owa.DisplayName.contains('System Admin')) { email.setOrgWideEmailAddressId(owa.id); } } Messaging.SendEmailResult [] res = Messaging.SendEmail(new Messaging.SingleEmailMessage[] {email}); for ( Messaging.sendEmailResult result : res ) { if ( !res[0].isSuccess () ) { System.debug ( result ); } } } return null; }
- rupesh ranjan
- March 15, 2016
- Like
- 0
How to avoid page load in this code after selecting picklist
<apex:page controller="videolistclasss" readOnly="true"> <apex:form > <script> function myJavaMethod(){ myactionfun(); } </script> <apex:actionFunction name="myactionfun" action="{!getperformcalloutpageReference}" reRender="false"/> <apex:pageBlock > <apex:pageblockSection > <apex:selectList size="1" value="{!ContentCategoryId}" id="ContentCategoryId" onchange="{!myJavaMethod}"> <apex:selectOptions value="{!items}" /> <apex:actionSupport event="onchange"> </apex:actionSupport> </apex:selectList> </apex:pageblockSection> </apex:pageBlock> <apex:pageblock > <c:PageBlockTableEnhancerADV targetPbTableIds="a" pageSizeOptions="5,10,15,30,40,50,60,70" defaultPageSize="50" enableExport="false"/> <apex:pageBlockTable id="a" value="{!performcallout}" var="wrap" width="100%" rendered="{!normalList}"> <apex:column headerValue="Title" value="{!wrap.Title}"/> <apex:column > <apex:inputCheckbox value="{!wrap.selected}" > </apex:inputCheckbox> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
Public class videolistclasss{ public String ContentCategoryId {get;set;} public String PartnerId{get;set;} public String parentcompany_id{get;set;} PUBLIC List<selectOption> Items; public String toAddresses {get; set;} public String MySessionID = UserInfo.getSessionID(); public String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId(); public string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; // public String Acode= Userinfo.getuserid(); public String Acode= '00528000001ktnpAAA'; public String Oid = '00D280000018TjaEAE'; Blob cryptoKey= EncodingUtil.base64Decode(c); Blob data = Blob.valueOf(MySessionID ); Blob data1 = Blob.valueOf(myurl); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); public String b64Data = EncodingUtil.base64Encode(encryptedData); public String b64Data1 = EncodingUtil.base64Encode(encryptedData1); public String b64Data4 = EncodingUtil.base64Encode(encryptedData4); public String b64Data5 = EncodingUtil.base64Encode(encryptedData5); public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); public String ssnid{get;set;} public boolean normalList{get;set;} public boolean selectedList{get;set;} public String Title{get;set;} public Boolean selected {get; set;} public List<videolist> ConsoleWrapperList5{get;set;} public string productName{get;set;} public videolistclasss() { getperformcallout5(); normalList = true; selectedList = false; } public List<videolist> getperformcallout5(){ ConsoleWrapperList5 = new List<videolist>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); System.debug('Calling method now' ); string url = 'https://www.demomail.net/sf/api/ContactCategoryList?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId+'&LanguageId='+0+'&PartnerId='+0; req.setEndpoint(url); System.debug('&&: '+ url ); req.setMethod('GET'); res = http.send(req); if(res.getstatusCode() == 200 && res.getbody() != null) { ConsoleWrapperList5=(List<videolist>)json.deserialize(res.getbody(),List<videolist>.class); } return consolewrapperlist5; } public List<SelectOption> getItems() { List<SelectOption> options = new List<SelectOption>(); for(videolist crRec : ConsoleWrapperList5){ options.add(new SelectOption(crRec.ContentCategoryId, crRec.CategoryName)); System.debug('##: '+ crRec.ContentCategoryId); } return options; } public List<consolewrap> ConsoleWrapperList{get;set;} public List<consolewrap> getperformcallout(){ ConsoleWrapperList = new List<consolewrap>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); string url = 'https://www.demomail.net/sf/api/SendVideoContact?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId+'&LanguageId='+0+'&PartnerId='+0; System.debug('**: '+ url); req.setEndpoint(url); //System.debug('!!!'+ SessionId); req.setMethod('GET'); //system.debug('???'+aucode); //system.debug('***'+ocode); res = http.send(req); // System.assert(false,res.getBody()+'-----'); if(res.getstatusCode() == 200 && res.getbody() != null){ ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class); System.debug('value: '+ ConsoleWrapperList ); } return ConsoleWrapperList; } public pageReference getperformcalloutpageReference () { getperformcallout(); return null; } }
- rupesh ranjan
- March 14, 2016
- Like
- 0
can any body tell me how can i call api for the picklist dependet value without page load?
can any body tell me how can i call api for the picklist dependet value without page load?
Some example plss
Some example plss
- rupesh ranjan
- March 13, 2016
- Like
- 0
i need to paas parameter(ContentCategoryId) on selection of pick list value urgent pls help
i need to paas parameter on selection of pick list
VF page <apex:pageblockSection > <apex:selectList size="1" value="{!productName}" id="ContentCategoryId"> <apex:selectOptions value="{!items}"/> <apex:actionSupport event="onchange" action="{!getperformcallout}" rerender="normalList"> <apex:param name="ContentCategoryId" assignto="{!ContentCategoryId}" value="{!ContentCategoryId}"/> </apex:actionSupport> </apex:selectList> </apex:pageblockSection> </apex:pageBlock> <apex:pageblock >
Public class videolistclass{ public String ContentCategoryId{get;set;} PUBLIC List<selectOption> Items; public String toAddresses {get; set;} public String MySessionID = UserInfo.getSessionID(); public String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId(); public string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; public String Acode= Userinfo.getuserid(); public String Oid = '00D280000018TjaEAE'; Blob cryptoKey= EncodingUtil.base64Decode(c); Blob data = Blob.valueOf(MySessionID ); Blob data1 = Blob.valueOf(myurl); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); public String b64Data = EncodingUtil.base64Encode(encryptedData); public String b64Data1 = EncodingUtil.base64Encode(encryptedData1); public String b64Data4 = EncodingUtil.base64Encode(encryptedData4); public String b64Data5 = EncodingUtil.base64Encode(encryptedData5); public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); public String ssnid{get;set;} public boolean normalList{get;set;} public boolean selectedList{get;set;} public String Title{get;set;} public Boolean selected {get; set;} public List<videolist> ConsoleWrapperList5{get;set;} public string productName{get;set;} public videolistclass() { getperformcallout5(); normalList = true; selectedList = false; } public List<videolist> getperformcallout5(){ ConsoleWrapperList5 = new List<videolist>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); string url = 'https://www.demomail.net/sf/api/ContactCategoryList?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId; req.setEndpoint(url); System.debug('&&: '+ url ); req.setMethod('GET'); res = http.send(req); if(res.getstatusCode() == 200 && res.getbody() != null) { ConsoleWrapperList5=(List<videolist>)json.deserialize(res.getbody(),List<videolist>.class); } return consolewrapperlist5; } public List<SelectOption> getItems() { List<SelectOption> options = new List<SelectOption>(); for(videolist crRec : ConsoleWrapperList5){ options.add(new SelectOption(crRec.ContentCategoryId, crRec.CategoryName)); } return options; } public List<consolewrap> ConsoleWrapperList{get;set;} public List<consolewrap> getperformcallout(){ ConsoleWrapperList = new List<consolewrap>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); string url = 'https://www.demomail.net/sf/api/SendVideoContact?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId+'&LanguageId='+0; req.setEndpoint(url); req.setMethod('GET'); res = http.send(req); if(res.getstatusCode() == 200 && res.getbody() != null){ ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class); System.debug('value: '+ ConsoleWrapperList ); } return consolewrapperlist; } }
- rupesh ranjan
- March 09, 2016
- Like
- 0
write Batch Class for this code?
write Batch Class for this code?
more thn 50001 record..
more thn 50001 record..
Public class selectcontact{ public String to{get; set;} public String AddRecep{get; set;} public String subject {get; set;} public String body {get; set;} public List<wrapContact> wrapContactList {get; set;} public List<Contact> selectedContacts{get;set;} Public String selectId {get;set;} public selectcontact(){ body = apexpages.currentpage().getparameters().get('att'); if(wrapContactList == null) { wrapContactList= new List<wrapContact>(); for(Contact a: [SELECT Name,FirstName,LastName,Email,Title FROM Contact ORDER by Name ASC]) { wrapContactList.add(new wrapContact(a)); } } body = ''; } public void processSelected() { AddRecep = ''; selectedContacts = new List<Contact>(); for(wrapContact wrapContactObj : wrapContactList) { if(wrapContactObj.selected == true) { selectedContacts.add(wrapContactObj.acc); if (AddRecep == '') { AddRecep = wrapContactObj.acc.Email; } else { AddRecep += ';' + wrapContactObj.acc.Email ; } } } } public class wrapContact { public Contact acc {get; set;} public Boolean selected {get; set;} public wrapContact (Contact a) { acc = a; selected = false; } } }
- rupesh ranjan
- March 07, 2016
- Like
- 0
Any one can remove this error from test class
Error MessageSystem.NullPointerException: Attempt to de-reference a null object
Stack TraceClass.sendmailexample.processSelected: line 26, column 1
Class.sendmailexample1test.runTest1: line 37, column 1
Stack TraceClass.sendmailexample.processSelected: line 26, column 1
Class.sendmailexample1test.runTest1: line 37, column 1
@isTest public class sendmailexample1test{ static testMethod void runTest1(){ Account account = new Account(); account.Name = 'Acc3'; insert account; Contact contact = new Contact(); contact.FirstName = 'Todda'; contact.LastName = 'Wilmss'; contact.AccountID = account.Id; contact.Email = 'twilms@verisign.conm'; contact.MobilePhone = '918527116723'; insert contact; ApexPages.StandardController sc2 = new ApexPages.StandardController(Contact); apexpages.currentpage().getparameters().put('ID',contact.id); String conId = ApexPages.currentPage().getParameters().get('Id'); String EmailCon =[Select email from Contact where Id=:conId ].email; sendmailexample testDObj1 = new sendmailexample(sc2); testDObj1.AddRecep='twilms@verisign.conm'; testDObj1.to ='twilms@verisign.conm'; testDObj1.EmailCon ='twilms@verisign.conm'; testDObj1.Email ='twilms@verisign.conm'; testDObj1.body='abc'; testDObj1.subject='abc'; test.StartTest(); PageReference pageRef = page.sendmail; Test.setCurrentPage(pageRef); ApexPages.StandardController sc = new ApexPages.standardController(Contact); apexpages.currentpage().getparameters().put('Id',contact.id); sendmailexample testDObj = new sendmailexample(sc); testDObj.EmailCon ='twilms@verisign.conm'; testDObj.processSelected(); test.StopTest(); } }
Public class sendmailexample1{ public String to{get; set;} public String AddRecep{get; set;} public String subject {get; set;} public String body {get; set;} public List<wrapContact> wrapContactList {get; set;} public List<Contact> selectedContacts{get;set;} Public String selectId {get;set;} public sendmailexample1(){ body = apexpages.currentpage().getparameters().get('att'); if(wrapContactList == null) { wrapContactList= new List<wrapContact>(); for(Contact a: [SELECT Name,FirstName,LastName,Email,Title FROM Contact ORDER by Name ASC]) { wrapContactList.add(new wrapContact(a)); } } body = ''; } public void processSelected() { AddRecep = ''; selectedContacts = new List<Contact>(); for(wrapContact wrapContactObj : wrapContactList) { if(wrapContactObj.selected == true) { selectedContacts.add(wrapContactObj.acc); if (AddRecep == '') { AddRecep = wrapContactObj.acc.Email; } else { AddRecep += ';' + wrapContactObj.acc.Email ; } } } } public class wrapContact { public Contact acc {get; set;} public Boolean selected {get; set;} public wrapContact (Contact a) { acc = a; selected = false; } } }
- rupesh ranjan
- March 07, 2016
- Like
- 0
Any one can write TEST class for below code
I want to write test class for below code
code is for selected contact which is stored in wrapper class(wrapContact )
code is for selected contact which is stored in wrapper class(wrapContact )
Public class sendmailexample{ public List<wrapContact> wrapContactList {get; set;} public List<Contact> selectedContacts{get;set;} Public String selectId {get;set;} public sendmailexample(){ body = apexpages.currentpage().getparameters().get('att'); if(wrapContactList == null) { wrapContactList= new List<wrapContact>(); for(Contact a: [SELECT Name,FirstName,LastName,Email,Title FROM Contact ORDER by Name ASC]) { wrapContactList.add(new wrapContact(a)); } } body = ''; to = EmailCon; } public void processSelected() { AddRecep = ''; selectedContacts = new List<Contact>(); for(wrapContact wrapContactObj : wrapContactList) { if(wrapContactObj.selected == true) { selectedContacts.add(wrapContactObj.acc); if (AddRecep == '') { AddRecep = wrapContactObj.acc.Email; } else { AddRecep += ';' + wrapContactObj.acc.Email ; } } } } public class wrapContact { public Contact acc {get; set;} public Boolean selected {get; set;} public wrapContact (Contact a) { acc = a; selected = false; } } }
- rupesh ranjan
- March 07, 2016
- Like
- 0
any one plss solve this Error in TEST CLASS
Error MessageSystem.NullPointerException: Argument cannot be null.
Stack TraceClass.sendmailexample.sendpost: line 62, column 1
Class.sendcontacttest.runTest1: line 34, column 1
&
Error MessageSystem.QueryException: List has no rows for assignment to SObject
Stack TraceClass.sendmailexample.<init>: line 10, column 1
Class.sendcontacttest.runTest5: line 67, column 1
Stack TraceClass.sendmailexample.sendpost: line 62, column 1
Class.sendcontacttest.runTest1: line 34, column 1
&
Error MessageSystem.QueryException: List has no rows for assignment to SObject
Stack TraceClass.sendmailexample.<init>: line 10, column 1
Class.sendcontacttest.runTest5: line 67, column 1
@isTest public class sendcontacttest{ static testMethod void runTest1() { Account account = new Account(); account.Name = 'Acc3'; insert account; Contact contact = new Contact(); contact.FirstName = 'Todda'; contact.LastName = 'Wilmss'; contact.AccountID = account.Id; contact.Email = 'twilms@verisign.conm'; contact.MobilePhone = '918527116723'; insert contact; ApexPages.StandardController sc2 = new ApexPages.StandardController(Contact); apexpages.currentpage().getparameters().put('ID',contact.id); String conId = ApexPages.currentPage().getParameters().get('Id'); String EmailCon =[Select email from Contact where Id=:conId ].email; sendmailexample testDObj1 = new sendmailexample(sc2); testDObj1.AddRecep='twilms@verisign.conm'; testDObj1.to ='twilms@verisign.conm'; testDObj1.EmailCon ='twilms@verisign.conm'; testDObj1.Email ='twilms@verisign.conm'; testDObj1.body='abc'; testDObj1.subject='abc'; test.startTest(); PageReference pageRef = Page.sendmail; // Your page name pageRef.getParameters().put('Id', String.valueOf(Contact.Id)); Test.setCurrentPage(pageRef); Test.setMock(HttpCalloutMock.class, new sendmailcontactmock()); ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object sendmailexample testDObj = new sendmailexample(sc1); testDObj.sendpost(); test.stopTest(); } static testMethod void runTest5(){ Account account = new Account(); account.Name = 'Acc3'; insert account; Contact contact = new Contact(); contact.FirstName = 'Todda'; contact.LastName = 'Wilmss'; contact.AccountID = account.Id; contact.Email = 'twilms@verisign.conm'; contact.MobilePhone = '918527116723'; insert contact; ApexPages.StandardController sc2 = new ApexPages.StandardController(Contact); apexpages.currentpage().getparameters().put('ID',contact.id); String conId = ApexPages.currentPage().getParameters().get('Id'); String EmailCon =[Select email from Contact where Id=:conId ].email; sendmailexample testDObj1 = new sendmailexample(sc2); testDObj1.AddRecep='twilms@verisign.conm'; testDObj1.to ='twilms@verisign.conm'; testDObj1.EmailCon ='twilms@verisign.conm'; testDObj1.Email ='twilms@verisign.conm'; testDObj1.body='abc'; testDObj1.subject='abc'; test.StartTest(); PageReference pageRef = page.sendmail; Test.setCurrentPage(pageRef); ApexPages.StandardController sc = new ApexPages.standardController(Contact); sendmailexample testDObj = new sendmailexample(sc); testDObj.EmailCon ='twilms@verisign.conm'; testDObj.processSelected(); test.StopTest(); } }
Public class sendmailexample{ public String to{get; set;} public String AddRecep{get; set;} public String subject {get; set;} public String body {get; set;} public String table3{get; set;} public String MySessionID = UserInfo.getSessionID(); public String conId = ApexPages.currentPage().getParameters().get('Id'); public String EmailCon =[Select email from Contact where Id=:conId ].email; public String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId(); public string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; public String Acode= Userinfo.getuserid(); public String Oid = UserInfo.getOrganizationId(); Blob cryptoKey= EncodingUtil.base64Decode(c); Blob data = Blob.valueOf(MySessionID ); Blob data1 = Blob.valueOf(myurl); Blob data2 = Blob.valueOf(conId); Blob data3 = Blob.valueOf(EmailCon); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1); Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2); Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 ); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); public String b64Data = EncodingUtil.base64Encode(encryptedData); public String b64Data1 = EncodingUtil.base64Encode(encryptedData1); public String b64Data2 = EncodingUtil.base64Encode(encryptedData2); public String b64Data3 = EncodingUtil.base64Encode(encryptedData3); public String b64Data4 = EncodingUtil.base64Encode(encryptedData4); public String b64Data5 = EncodingUtil.base64Encode(encryptedData5); public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8'); public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); public sendmailexample(ApexPages.StandardController controller) { AddRecep = ''; body=apexpages.currentpage().getparameters().get('att'); } public void sendpost(){ String MySessionID = UserInfo.getSessionID(); String conId = ApexPages.currentPage().getParameters().get('Id'); String EmailCon =[Select email from Contact where Id=:conId ].email; String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId(); string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; String Acode= Userinfo.getuserid(); String Oid = UserInfo.getOrganizationId(); Blob cryptoKey= EncodingUtil.base64Decode(c); Blob data = Blob.valueOf(MySessionID ); Blob data1 = Blob.valueOf(myurl); Blob data2 = Blob.valueOf(conId); Blob data3 = Blob.valueOf(EmailCon); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob data6 = Blob.valueOf(to); Blob data7 = Blob.valueOf(AddRecep); Blob data8 = Blob.valueOf(subject); Blob data9 = Blob.valueOf(body); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1); Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2); Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 ); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); Blob encryptedData6 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data6 ); Blob encryptedData7 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data7 ); Blob encryptedData8 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data8 ); Blob encryptedData9 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data9 ); String b64Data = EncodingUtil.base64Encode(encryptedData); String b64Data1 = EncodingUtil.base64Encode(encryptedData1); String b64Data2 = EncodingUtil.base64Encode(encryptedData2); String b64Data3 = EncodingUtil.base64Encode(encryptedData3); String b64Data4 = EncodingUtil.base64Encode(encryptedData4); String b64Data5 = EncodingUtil.base64Encode(encryptedData5); String b64Data6 = EncodingUtil.base64Encode(encryptedData6); String b64Data7 = EncodingUtil.base64Encode(encryptedData7); String b64Data8 = EncodingUtil.base64Encode(encryptedData8); String b64Data9 = EncodingUtil.base64Encode(encryptedData9); String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8'); String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8'); String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); String too= EncodingUtil.urlEncode(b64Data6, 'UTF-8'); String cccc= EncodingUtil.urlEncode(b64Data7, 'UTF-8'); String sbj= EncodingUtil.urlEncode(b64Data8, 'UTF-8'); String bdy= EncodingUtil.urlEncode(b64Data9, 'UTF-8'); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); req.setEndpoint('https://www.demomail.net/sf/api/SaveDemoMailPost'); req.setMethod('POST'); req.setHeader('Content-Type', 'application/x-www-form-urlencoded'); req.setBody('AUCode='+aucode+'&SOrgID='+ocode+'&Subject='+sbj+'&Body='+bdy+'&To='+too+'&CC='+cccc+'&Bcc='); system.debug('???'+aucode); try { res = http.send(req); if (res.getBody() != null) { System.debug('#Success!'); } else { System.debug('HTTP error: ' + res.getStatusCode()); } System.debug(res.getBody()); } catch(System.CalloutException e) { System.debug('Callout error: '+ e); } } public List<wrapContact> wrapContactList {get; set;} public List<Contact> selectedContacts{get;set;} Public String selectId {get;set;} public sendmailexample(){ body = apexpages.currentpage().getparameters().get('att'); if(wrapContactList == null) { wrapContactList= new List<wrapContact>(); for(Contact a: [SELECT Name,FirstName,LastName,Email,Title FROM Contact ORDER by Name ASC]) { wrapContactList.add(new wrapContact(a)); } } body = ''; to = EmailCon; } public void processSelected() { AddRecep = ''; selectedContacts = new List<Contact>(); for(wrapContact wrapContactObj : wrapContactList) { if(wrapContactObj.selected == true) { selectedContacts.add(wrapContactObj.acc); if (AddRecep == '') { AddRecep = wrapContactObj.acc.Email; } else { AddRecep += ';' + wrapContactObj.acc.Email ; } } } } public class wrapContact { public Contact acc {get; set;} public Boolean selected {get; set;} public wrapContact (Contact a) { acc = a; selected = false; } } }
- rupesh ranjan
- March 07, 2016
- Like
- 0
How to insert simple VF field in test class
How to insert simple VF field in test class some sample code plsss
Need to write test class for insertion not for standard object
i have used simple controller like
<apex:page controller="abc" >
Need to write test class for insertion not for standard object
i have used simple controller like
<apex:page controller="abc" >
Main controller Variable intialised like this Public class abc{ public String to{get; set;} public String AddRecep{get; set;}
- rupesh ranjan
- March 07, 2016
- Like
- 0
Error In Test Class kindly PLs any one help me out urgent basis
Error MessageSystem.NullPointerException: Argument cannot be null.
Stack TraceClass.sendmailp.sendpost: line 65, column 1
Class.sendmailcontacttest.runTest1: line 25, column 1
&
Error MessageSystem.NullPointerException: Attempt to de-reference a null object
Stack TraceClass.sendmailp.callapi2: line 1164, column 1
Class.sendmailcontacttest.runTest3: line 49, column 1
Stack TraceClass.sendmailp.sendpost: line 65, column 1
Class.sendmailcontacttest.runTest1: line 25, column 1
&
Error MessageSystem.NullPointerException: Attempt to de-reference a null object
Stack TraceClass.sendmailp.callapi2: line 1164, column 1
Class.sendmailcontacttest.runTest3: line 49, column 1
Test Class @isTest public class sendmailcontacttest{ static testMethod void runTest1() { Account account = new Account(); account.Name = 'Acc3'; insert account; Contact contact = new Contact(); contact.FirstName = 'Todda'; contact.LastName = 'Wilmss'; contact.AccountID = account.Id; contact.Email = 'twilms@verisign.conm'; contact.MobilePhone = '918527116723'; insert contact; test.startTest(); PageReference pageRef = Page.sendmail; // Your page name pageRef.getParameters().put('Id', String.valueOf(Contact.Id)); Test.setCurrentPage(pageRef); Test.setMock(HttpCalloutMock.class, new sendmailcontactmock()); ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object sendmailp testDObj = new sendmailp(); testDObj.sendpost(); test.stopTest(); } static testMethod void runTest3() { Account account = new Account(); account.Name = 'Acc3'; insert account; Contact contact = new Contact(); contact.FirstName = 'Todda'; contact.LastName = 'Wilmss'; contact.AccountID = account.Id; contact.Email = 'twilms@verisign.conm'; contact.MobilePhone = '918527116723'; insert contact; test.startTest(); PageReference pageRef = Page.Leadpage; // Your page name pageRef.getParameters().put('Id', String.valueOf(Contact.Id)); Test.setCurrentPage(pageRef); Test.setMock(HttpCalloutMock.class, new sendmailcontactmock()); ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object sendmailp testDObj = new sendmailp(); testDObj.callapi2(); test.stopTest(); } static testMethod void runTest4() { Account account = new Account(); account.Name = 'Acc3'; insert account; Contact contact = new Contact(); contact.FirstName = 'Todda'; contact.LastName = 'Wilmss'; contact.AccountID = account.Id; contact.Email = 'twilms@verisign.conm'; contact.MobilePhone = '918527116723'; insert contact; test.startTest(); PageReference pageRef = Page.Leadpage; // Your page name pageRef.getParameters().put('Id', String.valueOf(Contact.Id)); Test.setCurrentPage(pageRef); Test.setMock(HttpCalloutMock.class, new sendmailcontactmock()); ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object sendmailp testDObj = new sendmailp(); testDObj.getperformcallout(); test.stopTest(); } }
Mock Class @IsTest(seeAllData = false) global class sendmailcontactmock implements HttpCalloutMock { global HTTPResponse respond(HTTPRequest req) { HttpResponse res = new HttpResponse(); res.setHeader('Content-Type', 'application/json'); res.setBody('[{"foo":"bar"}]'); res.setStatusCode(200); return res; } }
Main Class Public class sendmailp{ public String to{get; set;} public String AddRecep{get; set;} public String subject {get; set;} public String body {get; set;} public String table3{get; set;} public String toAddresses {get; set;} public String MySessionID = UserInfo.getSessionID(); public String conId = ApexPages.currentPage().getParameters().get('Id'); public String EmailCon =[Select email from Contact where Id=:conId ].email; public String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId(); public string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; public String Acode= Userinfo.getuserid(); public String Oid = UserInfo.getOrganizationId(); Blob cryptoKey= EncodingUtil.base64Decode(c); Blob data = Blob.valueOf(MySessionID ); Blob data1 = Blob.valueOf(myurl); Blob data2 = Blob.valueOf(conId); Blob data3 = Blob.valueOf(EmailCon); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1); Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2); Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 ); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); public String b64Data = EncodingUtil.base64Encode(encryptedData); public String b64Data1 = EncodingUtil.base64Encode(encryptedData1); public String b64Data2 = EncodingUtil.base64Encode(encryptedData2); public String b64Data3 = EncodingUtil.base64Encode(encryptedData3); public String b64Data4 = EncodingUtil.base64Encode(encryptedData4); public String b64Data5 = EncodingUtil.base64Encode(encryptedData5); public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8'); public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); public sendmailp(ApexPages.StandardController controller) { AddRecep = ''; body=apexpages.currentpage().getparameters().get('att'); } public void sendpost(){ String MySessionID = UserInfo.getSessionID(); String conId = ApexPages.currentPage().getParameters().get('Id'); String EmailCon =[Select email from Contact where Id=:conId ].email; String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId(); string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; String Acode= Userinfo.getuserid(); String Oid = UserInfo.getOrganizationId(); Blob cryptoKey= EncodingUtil.base64Decode(c); Blob data = Blob.valueOf(MySessionID ); Blob data1 = Blob.valueOf(myurl); Blob data2 = Blob.valueOf(conId); Blob data3 = Blob.valueOf(EmailCon); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob data6 = Blob.valueOf(to); Blob data7 = Blob.valueOf(AddRecep); Blob data8 = Blob.valueOf(subject); Blob data9 = Blob.valueOf(body); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1); Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2); Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 ); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); Blob encryptedData6 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data6 ); Blob encryptedData7 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data7 ); Blob encryptedData8 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data8 ); Blob encryptedData9 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data9 ); String b64Data = EncodingUtil.base64Encode(encryptedData); String b64Data1 = EncodingUtil.base64Encode(encryptedData1); String b64Data2 = EncodingUtil.base64Encode(encryptedData2); String b64Data3 = EncodingUtil.base64Encode(encryptedData3); String b64Data4 = EncodingUtil.base64Encode(encryptedData4); String b64Data5 = EncodingUtil.base64Encode(encryptedData5); String b64Data6 = EncodingUtil.base64Encode(encryptedData6); String b64Data7 = EncodingUtil.base64Encode(encryptedData7); String b64Data8 = EncodingUtil.base64Encode(encryptedData8); String b64Data9 = EncodingUtil.base64Encode(encryptedData9); String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8'); String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8'); String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); String too= EncodingUtil.urlEncode(b64Data6, 'UTF-8'); String cccc= EncodingUtil.urlEncode(b64Data7, 'UTF-8'); String sbj= EncodingUtil.urlEncode(b64Data8, 'UTF-8'); String bdy= EncodingUtil.urlEncode(b64Data9, 'UTF-8'); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); req.setEndpoint('https://www.demomail.net/sf/api/SaveDemoMailPost'); req.setMethod('POST'); req.setHeader('Content-Type', 'application/x-www-form-urlencoded'); req.setBody('AUCode='+aucode+'&SOrgID='+ocode+'&Subject='+sbj+'&Body='+bdy+'&To='+too+'&CC='+cccc+'&Bcc='); system.debug('???'+aucode); try { res = http.send(req); if (res.getBody() != null) { System.debug('#Success!'); } else { System.debug('HTTP error: ' + res.getStatusCode()); } System.debug(res.getBody()); } catch(System.CalloutException e) { System.debug('Callout error: '+ e); } } public List<wrapContact> wrapContactList {get; set;} public List<Contact> selectedContacts{get;set;} Public String selectId {get;set;} public sendmailp(){ body = apexpages.currentpage().getparameters().get('att'); if(wrapContactList == null) { wrapContactList= new List<wrapContact>(); for(Contact a: [SELECT Name,FirstName,LastName,Email,Title FROM Contact ORDER by Name ASC]) { wrapContactList.add(new wrapContact(a)); } } normalList = true; selectedList = false; body = ''; to = EmailCon; } public void processSelected() { AddRecep = ''; selectedContacts = new List<Contact>(); for(wrapContact wrapContactObj : wrapContactList) { if(wrapContactObj.selected == true) { selectedContacts.add(wrapContactObj.acc); if (AddRecep == '') { AddRecep = wrapContactObj.acc.Email; } else { AddRecep += ';' + wrapContactObj.acc.Email ; } } } } public class wrapContact { public Contact acc {get; set;} public Boolean selected {get; set;} public wrapContact (Contact a) { acc = a; selected = false; } } public List<video> ConsoleWrapperList1{get;set;} public String consolewrap{get;set;} public String SessionId = ''; public void callapi2(){ String SessionId = ''; string testSessionId = ''; for( consolewrap cwt : ConsoleWrapperList){ testSessionId += cwt.sid; if(cwt.selected){ if(SessionId == ''){ SessionId += cwt.SessionId; }else{ SessionId += ','+ cwt.SessionId; } } } system.debug('testSessionId+++'+testSessionId); List<video> ConsoleWrapperList1 = new List<video>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); system.debug('SessionId+++'+SessionId); string url = 'https://www.demomail.net/sf/api/SendVideoContactPreview?AUCode='+aucode+'&SOrgID='+ocode+'&SessionIds='+SessionId; req.setEndpoint(url); req.setMethod('GET'); res = http.send(req); if(res.getstatusCode() == 200 && res.getbody() != null){ String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r',''); ConsoleWrapperList1=(List<video>)System.JSON.deserialize(replaceIllegal,List<video>.class); system.debug('ConsoleWrapperList1+++'+ConsoleWrapperList1); body = ConsoleWrapperList1.get(0).bodyT; } } public String ssnid{get;set;} public boolean normalList{get;set;} public boolean selectedList{get;set;} public String Title{get;set;} public Boolean selected {get; set;} public List<consolewrap> ConsoleWrapperList{get;set;} public List<consolewrap> getperformcallout(){ ConsoleWrapperList = new List<consolewrap>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); string url = 'https://www.demomail.net/sf/api/SendVideoContact?AUCode='+aucode+'&SOrgID='+ocode+'&id='+SessionId; System.debug('##: '+ SessionId); req.setEndpoint(url); req.setMethod('GET'); res = http.send(req); if(res.getstatusCode() == 200 && res.getbody() != null){ ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class); System.debug('value: '+ ConsoleWrapperList ); } return consolewrapperlist; } }
- rupesh ranjan
- March 06, 2016
- Like
- 0
Any one pls remove this error from test class System.NullPointerException: Argument cannot be null.
Any one pls remove this error from test class
System.NullPointerException: Argument cannot be null.
Class.Leadpage.<init>: line 19, column 1
Class.Leadtestsss.runTest1: line 31, column 1
System.NullPointerException: Argument cannot be null.
Class.Leadpage.<init>: line 19, column 1
Class.Leadtestsss.runTest1: line 31, column 1
TEST Class @isTest public class Leadtestss{ static testMethod void runTest1() { Account account = new Account(); account.Name = 'Acc3'; insert account; Contact contact = new Contact(); contact.FirstName = 'Todda'; contact.LastName = 'Wilmss'; contact.AccountID = account.Id; contact.Email = 'twilms@verisign.conm'; contact.MobilePhone = '918527116723'; insert contact; Lead lead = new Lead(); lead.FirstName = 'test'; lead.LastName = 'foo'; lead.company='Acc3'; insert lead; test.startTest(); PageReference pageRef = Page.Leadpage; pageRef.getParameters().put('Id', String.valueOf(lead.Id)); Test.setCurrentPage(pageRef); Test.setMock(HttpCalloutMock.class, new Leadpagemock()); ApexPages.StandardController sc1 = new ApexPages.StandardController(Lead);//Instance of your object Leadpage testDObj = new Leadpage(); testDObj.getperformcallout(); test.stopTest(); } }
Page MOCK Class @IsTest(seeAllData = false) global class Leadpagemock implements HttpCalloutMock { global HTTPResponse respond(HTTPRequest req) { HttpResponse res = new HttpResponse(); res.setHeader('Content-Type', 'application/json'); res.setBody('[{"foo":"bar"}]'); res.setStatusCode(200); return res; } }
Main Class public class Leadpage{ public Leadpage(ApexPages.StandardController controller) { } public Leadpage() {} public String MySessionID = UserInfo.getSessionID(); public String conId = ApexPages.currentPage().getParameters().get('Id'); public String EmailCon=[Select email from Lead where Id=:conId ].email; public String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId(); public string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; public String Acode='00530000000rLMxAAM'; public String Oid = UserInfo.getOrganizationId(); Blob cryptoKey= EncodingUtil.base64Decode(c); Blob data = Blob.valueOf(MySessionID ); Blob data1 = Blob.valueOf(myurl); Blob data2 = Blob.valueOf(conId); Blob data3 = Blob.valueOf(EmailCon); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1); Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2); Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 ); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); public String b64Data = EncodingUtil.base64Encode(encryptedData); public String b64Data1 = EncodingUtil.base64Encode(encryptedData1); public String b64Data2 = EncodingUtil.base64Encode(encryptedData2); public String b64Data3 = EncodingUtil.base64Encode(encryptedData3); public String b64Data4 = EncodingUtil.base64Encode(encryptedData4); public String b64Data5 = EncodingUtil.base64Encode(encryptedData5); String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8'); public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8'); public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); public String ocode= EncodingUtil.urlEncode (b64Data5, 'UTF-8'); public List<LeadVideoViewAllWrap> ConsoleWrapperList{get;set;} public List<LeadVideoViewAllWrap> getperformcallout(){ ConsoleWrapperList = new List<LeadVideoViewAllWrap>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); string url = 'https://www.demomail.net/sf/api/LeadVideoViewAllController?AUCode='+aucode+'&SOrgID='+ocode+'&Email='+email+'&session='+testurl; req.setEndpoint(url); req.setMethod('GET'); res = http.send(req); if(res.getstatusCode() == 200 && res.getbody() != null){ ConsoleWrapperList=(List<LeadVideoViewAllWrap>)json.deserialize(res.getbody(),List<LeadVideoViewAllWrap>.class); } return consolewrapperlist; } }
- rupesh ranjan
- March 06, 2016
- Like
- 0
Error in RUN Test Class(You have uncommitted work pending. Please commit or rollback before calling out)
Error Message System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out
Stack Trace Class.homeReport.getperformcallout: line 55, column 1
Class.homeReportTests.Myunittest1: line 33, column 1
Stack Trace Class.homeReport.getperformcallout: line 55, column 1
Class.homeReportTests.Myunittest1: line 33, column 1
@isTest(seeAllData = false) public class homeReportTests { public List<homeReportwrap> ConsoleWrapperList{get;set;} static testmethod void Myunittest1() { User a = new User(); a.FirstName = 'rup'; a.LastName = 'ran'; a.Email = 'rup.ran@gmail.com'; a.Username = 'rup1.ran1@gmail.com'; a.Alias = 'rupran'; a.ProfileId = '00e30000000mm8h'; // Don't worry about these a.TimeZoneSidKey = 'America/Denver'; a.LocaleSidKey = 'en_US'; a.EmailEncodingKey = 'UTF-8'; a.LanguageLocaleKey = 'en_US'; insert a; Account account = new Account(); account.Name = 'Accc'; insert account; Contact contact = new Contact(); contact.FirstName = 'rup'; contact.LastName = 'ran'; contact.AccountID = account.Id; contact.Email = 'rup.ran@gmail.com'; contact.MobilePhone = '918527116725'; insert contact; homeReport cp = new homeReport(new ApexPages.StandardController(contact)); Test.setMock(HttpCalloutMock.class, new homepagemock()); homeReport testAObj = new homeReport(); testAObj.getperformcallout(); HttpResponse res = new HttpResponse(); //String contentType = res.setHeader('Content-Type'); // System.assert(contentType == 'application/json'); String actualValue = res.getBody(); String expectedValue = '{"foo":"bar"}'; System.assertEquals(actualValue, expectedValue); System.assertEquals(200, res.getStatusCode()); cp.getperformcallout(); } /* static testMethod void fakeTest(){ homeReport.fakeMethod(); //repeat the same for the rest of classes. } */ /* static testMethod void fakeTest1(){ } */ }
- rupesh ranjan
- March 04, 2016
- Like
- 0
only 74 % code coverage how to increase? and ERROR : Error Message System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out Stack Trace Class.homeReport.getperformcallout:
Main Test Class @isTest(seeAllData = false) public class homeReportTests { static testmethod void Myunittest1() { Account account = new Account(); account.Name = 'Accc'; insert account; Contact contact = new Contact(); contact.FirstName = 'rup'; contact.LastName = 'ran'; contact.AccountID = account.Id; contact.Email = 'rup.ran@gmail.com'; contact.MobilePhone = '918527116725'; insert contact; homeReport cp = new homeReport(new ApexPages.StandardController(contact)); Test.startTest(); Test.setMock(HttpCalloutMock.class, new homepagemock()); homeReport testAObj = new homeReport(); testAObj.getperformcallout(); HttpResponse res = new HttpResponse(); String actualValue = res.getBody(); String expectedValue = '{"foo":"bar"}'; System.assertEquals(actualValue, expectedValue); System.assertEquals(200, res.getStatusCode()); cp.getperformcallout(); Test.stopTest(); } }
Mock Class @IsTest(seeAllData = false) global class homepagemock implements HttpCalloutMock { global HTTPResponse respond(HTTPRequest req) { System.assertEquals('https://www.demomail.net/sf/api/HomeVideoViewReport?AUCode=00530000000rLMxAAM&SOrgID=00Dn00000008gwlEAA', req.getEndpoint()); System.assertEquals('GET', req.getMethod()); HttpResponse res = new HttpResponse(); res.setHeader('Content-Type', 'application/json'); res.setBody('{"foo":"bar"}'); res.setStatusCode(200); return res; } }
Main Class public class homeReport{ private ApexPages.StandardController c; public homeReport(ApexPages.StandardController stdController) { c = stdController; } public homeReport() { } String MySessionID = UserInfo.getSessionID(); String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId(); public string d='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; public String Acode= Userinfo.getuserid(); public String Oid = UserInfo.getOrganizationId(); Blob cryptoKey= EncodingUtil.base64Decode(d); Blob data = Blob.valueOf(MySessionID ); Blob data1 = Blob.valueOf(myurl); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); public string b64Data = EncodingUtil.base64Encode(encryptedData); public String b64Data1 = EncodingUtil.base64Encode(encryptedData1); public String b64Data4 = EncodingUtil.base64Encode(encryptedData4); public String b64Data5 = EncodingUtil.base64Encode(encryptedData5); String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8'); public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); public List<homeReportwrap> ConsoleWrapperList{get;set;} public List<homeReportwrap> getperformcallout(){ ConsoleWrapperList = new List<homeReportwrap>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); string url = 'https://www.demomail.net/sf/api/HomeVideoViewReport?AUCode='+aucode+'&SOrgID='+ocode+'&session='+testurl; req.setEndpoint(url); req.setMethod('GET'); res = http.send(req); if(res.getstatusCode() == 200 && res.getbody() != null) { String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r',''); ConsoleWrapperList=(List<homeReportwrap>)System.JSON.deserialize(replaceIllegal,List<homeReportwrap>.class); } return consolewrapperlist; } }
- rupesh ranjan
- March 04, 2016
- Like
- 0
Error Message System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out Stack Trace Class.homeReport.getperformcallout:
Error Message System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out Stack Trace Class.homeReport.getperformcallout: @isTest(seeAllData = false) public class homeReportTests { static testmethod void Myunittest1() { Account account = new Account(); account.Name = 'Accc'; insert account; Contact contact = new Contact(); contact.FirstName = 'rup'; contact.LastName = 'ran'; contact.AccountID = account.Id; contact.Email = 'rup.ran@gmail.com'; contact.MobilePhone = '918527116725'; insert contact; homeReport cp = new homeReport(new ApexPages.StandardController(contact)); Test.startTest(); Test.setMock(HttpCalloutMock.class, new homepagemock()); homeReport testAObj = new homeReport(); testAObj.getperformcallout(); HttpResponse res = new HttpResponse(); String actualValue = res.getBody(); String expectedValue = '{"foo":"bar"}'; System.assertEquals(actualValue, expectedValue); System.assertEquals(200, res.getStatusCode()); cp.getperformcallout(); Test.stopTest(); } }
- rupesh ranjan
- March 04, 2016
- Like
- 0
need to Write Test class for Webservice urgent basis
I have Written Mocktest but have an error in TEST Class (Method does not exist or incorrect signature: homeReport.getperformcallout() )
Class
@isTest public class homeReportTest { static testmethod void Myunittest1() { // Your Standard object instance User a = new User(); insert a; homeReport cp = new homeReport(new ApexPages.StandardController(a)); Test.setMock(HttpCalloutMock.class, new homepageTestmock()); HttpResponse res = homeReport.getperformcallout(); String contentType = res.getHeader('Content-Type'); System.assert(contentType == 'application/json'); String actualValue = res.getBody(); String expectedValue = '{"foo":"bar"}'; System.assertEquals(actualValue, expectedValue); System.assertEquals(200, res.getStatusCode()); cp.getperformcallout(); res = http.send(req); } }Mock Class Mock Class
@IsTest global class homepageTestmock implements HttpCalloutMock { global HTTPResponse respond(HTTPRequest req) { string d='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; String Acode= Userinfo.getuserid(); String Oid = UserInfo.getOrganizationId(); Blob cryptoKey= EncodingUtil.base64Decode(d); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); String b64Data4 = EncodingUtil.base64Encode(encryptedData4); String b64Data5 = EncodingUtil.base64Encode(encryptedData5); String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); System.assertEquals('https://www.demomail.net/sf/api/HomeVideoViewReport?AUCode='+aucode+'&SOrgID='+ocode, req.getEndpoint()); System.assertEquals('GET', req.getMethod()); // Create a fake response HttpResponse res = new HttpResponse(); res.setHeader('Content-Type', 'application/json'); res.setBody('{"foo":"bar"}'); res.setStatusCode(200); return res; } }
Class
public with sharing class homeReport{ private ApexPages.StandardController c; public homeReport(ApexPages.StandardController stdController) { c = stdController; } public string d='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; public String Acode= Userinfo.getuserid(); public String Oid = UserInfo.getOrganizationId(); Blob cryptoKey= EncodingUtil.base64Decode(d); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); public String b64Data4 = EncodingUtil.base64Encode(encryptedData4); public String b64Data5 = EncodingUtil.base64Encode(encryptedData5); //String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8'); public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); public List<homeReportwrap> ConsoleWrapperList{get;set;} public List<homeReportwrap> getperformcallout(){ ConsoleWrapperList = new List<homeReportwrap>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); string url = 'https://www.demomail.net/sf/api/HomeVideoViewReport?AUCode='+aucode+'&SOrgID='+ocode; //System.debug('##: '+ url ); req.setEndpoint(url); //s req.setEndpoint('https://www.demomail.net/sf/api/HomeVideoViewReport?AUCode=aucode&SOrgID=ocode'); //req.setEndpoint('https://www.demomail.net/sf/api/HomeVideoViewReport?AUCode=04uZru9MNwFgaEdddAUOHL0Y%2FtNoWSrhDMQpMyLHbVMBBENHjxc%2B7XO1Tl4T5rA4&SOrgID=IievdI%2Fz5GQAPQEWAzN7cc45a4rUCoRqbEad1KON7DSUK%2F1pxBNzk3%2FB1JcpahR2'); req.setMethod('GET'); system.debug('###'+d); system.debug('???'+Acode); system.debug('***'+Oid ); //req.setHeader('Authorization', 'OAuth '+UserInfo.getSessionId()); res = http.send(req); //System.assert(false,res.getBody()+'******'); if(res.getstatusCode() == 200 && res.getbody() != null) { String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r',''); ConsoleWrapperList=(List<homeReportwrap>)System.JSON.deserialize(replaceIllegal,List<homeReportwrap>.class); //ConsoleWrapperList1 = ConsoleWrapperList.replaceall('\r\n',''); //System.debug('Response Checking Engine: '+ res.getBody()); } return consolewrapperlist; } }
- rupesh ranjan
- March 03, 2016
- Like
- 0
Need to write test class urgent basis
public with sharing class homeReport{ private ApexPages.StandardController c; public homeReport(ApexPages.StandardController stdController) { c = stdController; } public string d='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; public String Acode= Userinfo.getuserid(); public String Oid = UserInfo.getOrganizationId(); Blob cryptoKey= EncodingUtil.base64Decode(d); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); public String b64Data4 = EncodingUtil.base64Encode(encryptedData4); public String b64Data5 = EncodingUtil.base64Encode(encryptedData5); //String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8'); public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); public List<homeReportwrap> ConsoleWrapperList{get;set;} public List<homeReportwrap> getperformcallout(){ ConsoleWrapperList = new List<homeReportwrap>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); req.setEndpoint('https://www.demomail.net/sf/api/HomeVideoViewReport?AUCode=aucode&SOrgID=ocode'); req.setMethod('GET'); system.debug('###'+d); system.debug('???'+Acode); system.debug('***'+Oid ); //req.setHeader('Authorization', 'OAuth '+UserInfo.getSessionId()); res = http.send(req); //System.assert(false,res.getBody()+'******'); if(res.getstatusCode() == 200 && res.getbody() != null) { String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r',''); ConsoleWrapperList=(List<homeReportwrap>)System.JSON.deserialize(replaceIllegal,List<homeReportwrap>.class); //ConsoleWrapperList1 = ConsoleWrapperList.replaceall('\r\n',''); //System.debug('Response Checking Engine: '+ res.getBody()); } return consolewrapperlist; } }
- rupesh ranjan
- March 02, 2016
- Like
- 0
Why mails are coming into Spam Folder
public pageReference send(){ Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); List<String> ccAddresses =new List<String>(); if (AddRecep != '' && AddRecep != null) { ccAddresses = AddRecep.split(';'); email.setTargetObjectId(conId); email.setCcAddresses(ccAddresses); email.setSubject(subject); email.setHtmlBody(body); Messaging.SendEmailResult [] res = Messaging.SendEmail(new Messaging.SingleEmailMessage[] {email}); for ( Messaging.sendEmailResult result : res ) { if ( !res[0].isSuccess () ) { System.debug ( result ); } } } return null; }
- rupesh ranjan
- February 19, 2016
- Like
- 1
Hi all need urgent
Contract Object
I need to generate a report that can show elapsed number of days between;
-Site Survey Scheduled (date field) and Site Survey Complete (date field).
So what are the steps?
I need to generate a report that can show elapsed number of days between;
-Site Survey Scheduled (date field) and Site Survey Complete (date field).
So what are the steps?
- rupesh ranjan
- September 16, 2015
- Like
- 1
Any one suggest for Test class for below constructor of main class
public class OSM_SW_TaxExemptionContactCtrl { private account primaryaccount ; public OSM_SW_TaxExemptionContactCtrl(){ Id recid = apexpages.currentpage().getparameters().get('accountid'); if(recid!=null){ primaryaccount = [select id,Customer_BMS_number__c,BOLT_Account_Number__c,IAM_Service_Provider_Code__c,BMS_Customer_ID__c,BMS_Customer_ID_Junction__c from account where id=:recid limit 1]; if(primaryaccount.Customer_BMS_number__c!=null){ CustomerNumber= primaryaccount.Customer_BMS_number__c; }else if(primaryaccount.BOLT_Account_Number__c!=null){ CustomerNumber= primaryaccount.BOLT_Account_Number__c; }else { CustomerNumber= primaryaccount.IAM_Service_Provider_Code__c; } } String myGeneratedFileName = 'Tax Exemption ContactForm.pdf'; Apexpages.currentPage().getHeaders().put('content-disposition', 'attachment; filename='+myGeneratedFilename); Apexpages.currentPage().getHeaders().put('content-disposition', 'inline; filename='+myGeneratedFilename); } ]
- rupesh ranjan
- April 24, 2020
- Like
- 0
i need to paas parameter(ContentCategoryId) on selection of pick list value urgent pls help
i need to paas parameter on selection of pick list
VF page <apex:pageblockSection > <apex:selectList size="1" value="{!productName}" id="ContentCategoryId"> <apex:selectOptions value="{!items}"/> <apex:actionSupport event="onchange" action="{!getperformcallout}" rerender="normalList"> <apex:param name="ContentCategoryId" assignto="{!ContentCategoryId}" value="{!ContentCategoryId}"/> </apex:actionSupport> </apex:selectList> </apex:pageblockSection> </apex:pageBlock> <apex:pageblock >
Public class videolistclass{ public String ContentCategoryId{get;set;} PUBLIC List<selectOption> Items; public String toAddresses {get; set;} public String MySessionID = UserInfo.getSessionID(); public String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId(); public string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; public String Acode= Userinfo.getuserid(); public String Oid = '00D280000018TjaEAE'; Blob cryptoKey= EncodingUtil.base64Decode(c); Blob data = Blob.valueOf(MySessionID ); Blob data1 = Blob.valueOf(myurl); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); public String b64Data = EncodingUtil.base64Encode(encryptedData); public String b64Data1 = EncodingUtil.base64Encode(encryptedData1); public String b64Data4 = EncodingUtil.base64Encode(encryptedData4); public String b64Data5 = EncodingUtil.base64Encode(encryptedData5); public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); public String ssnid{get;set;} public boolean normalList{get;set;} public boolean selectedList{get;set;} public String Title{get;set;} public Boolean selected {get; set;} public List<videolist> ConsoleWrapperList5{get;set;} public string productName{get;set;} public videolistclass() { getperformcallout5(); normalList = true; selectedList = false; } public List<videolist> getperformcallout5(){ ConsoleWrapperList5 = new List<videolist>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); string url = 'https://www.demomail.net/sf/api/ContactCategoryList?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId; req.setEndpoint(url); System.debug('&&: '+ url ); req.setMethod('GET'); res = http.send(req); if(res.getstatusCode() == 200 && res.getbody() != null) { ConsoleWrapperList5=(List<videolist>)json.deserialize(res.getbody(),List<videolist>.class); } return consolewrapperlist5; } public List<SelectOption> getItems() { List<SelectOption> options = new List<SelectOption>(); for(videolist crRec : ConsoleWrapperList5){ options.add(new SelectOption(crRec.ContentCategoryId, crRec.CategoryName)); } return options; } public List<consolewrap> ConsoleWrapperList{get;set;} public List<consolewrap> getperformcallout(){ ConsoleWrapperList = new List<consolewrap>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); string url = 'https://www.demomail.net/sf/api/SendVideoContact?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId+'&LanguageId='+0; req.setEndpoint(url); req.setMethod('GET'); res = http.send(req); if(res.getstatusCode() == 200 && res.getbody() != null){ ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class); System.debug('value: '+ ConsoleWrapperList ); } return consolewrapperlist; } }
- rupesh ranjan
- March 09, 2016
- Like
- 0
any one plss solve this Error in TEST CLASS
Error MessageSystem.NullPointerException: Argument cannot be null.
Stack TraceClass.sendmailexample.sendpost: line 62, column 1
Class.sendcontacttest.runTest1: line 34, column 1
&
Error MessageSystem.QueryException: List has no rows for assignment to SObject
Stack TraceClass.sendmailexample.<init>: line 10, column 1
Class.sendcontacttest.runTest5: line 67, column 1
Stack TraceClass.sendmailexample.sendpost: line 62, column 1
Class.sendcontacttest.runTest1: line 34, column 1
&
Error MessageSystem.QueryException: List has no rows for assignment to SObject
Stack TraceClass.sendmailexample.<init>: line 10, column 1
Class.sendcontacttest.runTest5: line 67, column 1
@isTest public class sendcontacttest{ static testMethod void runTest1() { Account account = new Account(); account.Name = 'Acc3'; insert account; Contact contact = new Contact(); contact.FirstName = 'Todda'; contact.LastName = 'Wilmss'; contact.AccountID = account.Id; contact.Email = 'twilms@verisign.conm'; contact.MobilePhone = '918527116723'; insert contact; ApexPages.StandardController sc2 = new ApexPages.StandardController(Contact); apexpages.currentpage().getparameters().put('ID',contact.id); String conId = ApexPages.currentPage().getParameters().get('Id'); String EmailCon =[Select email from Contact where Id=:conId ].email; sendmailexample testDObj1 = new sendmailexample(sc2); testDObj1.AddRecep='twilms@verisign.conm'; testDObj1.to ='twilms@verisign.conm'; testDObj1.EmailCon ='twilms@verisign.conm'; testDObj1.Email ='twilms@verisign.conm'; testDObj1.body='abc'; testDObj1.subject='abc'; test.startTest(); PageReference pageRef = Page.sendmail; // Your page name pageRef.getParameters().put('Id', String.valueOf(Contact.Id)); Test.setCurrentPage(pageRef); Test.setMock(HttpCalloutMock.class, new sendmailcontactmock()); ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object sendmailexample testDObj = new sendmailexample(sc1); testDObj.sendpost(); test.stopTest(); } static testMethod void runTest5(){ Account account = new Account(); account.Name = 'Acc3'; insert account; Contact contact = new Contact(); contact.FirstName = 'Todda'; contact.LastName = 'Wilmss'; contact.AccountID = account.Id; contact.Email = 'twilms@verisign.conm'; contact.MobilePhone = '918527116723'; insert contact; ApexPages.StandardController sc2 = new ApexPages.StandardController(Contact); apexpages.currentpage().getparameters().put('ID',contact.id); String conId = ApexPages.currentPage().getParameters().get('Id'); String EmailCon =[Select email from Contact where Id=:conId ].email; sendmailexample testDObj1 = new sendmailexample(sc2); testDObj1.AddRecep='twilms@verisign.conm'; testDObj1.to ='twilms@verisign.conm'; testDObj1.EmailCon ='twilms@verisign.conm'; testDObj1.Email ='twilms@verisign.conm'; testDObj1.body='abc'; testDObj1.subject='abc'; test.StartTest(); PageReference pageRef = page.sendmail; Test.setCurrentPage(pageRef); ApexPages.StandardController sc = new ApexPages.standardController(Contact); sendmailexample testDObj = new sendmailexample(sc); testDObj.EmailCon ='twilms@verisign.conm'; testDObj.processSelected(); test.StopTest(); } }
Public class sendmailexample{ public String to{get; set;} public String AddRecep{get; set;} public String subject {get; set;} public String body {get; set;} public String table3{get; set;} public String MySessionID = UserInfo.getSessionID(); public String conId = ApexPages.currentPage().getParameters().get('Id'); public String EmailCon =[Select email from Contact where Id=:conId ].email; public String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId(); public string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; public String Acode= Userinfo.getuserid(); public String Oid = UserInfo.getOrganizationId(); Blob cryptoKey= EncodingUtil.base64Decode(c); Blob data = Blob.valueOf(MySessionID ); Blob data1 = Blob.valueOf(myurl); Blob data2 = Blob.valueOf(conId); Blob data3 = Blob.valueOf(EmailCon); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1); Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2); Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 ); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); public String b64Data = EncodingUtil.base64Encode(encryptedData); public String b64Data1 = EncodingUtil.base64Encode(encryptedData1); public String b64Data2 = EncodingUtil.base64Encode(encryptedData2); public String b64Data3 = EncodingUtil.base64Encode(encryptedData3); public String b64Data4 = EncodingUtil.base64Encode(encryptedData4); public String b64Data5 = EncodingUtil.base64Encode(encryptedData5); public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8'); public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); public sendmailexample(ApexPages.StandardController controller) { AddRecep = ''; body=apexpages.currentpage().getparameters().get('att'); } public void sendpost(){ String MySessionID = UserInfo.getSessionID(); String conId = ApexPages.currentPage().getParameters().get('Id'); String EmailCon =[Select email from Contact where Id=:conId ].email; String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId(); string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; String Acode= Userinfo.getuserid(); String Oid = UserInfo.getOrganizationId(); Blob cryptoKey= EncodingUtil.base64Decode(c); Blob data = Blob.valueOf(MySessionID ); Blob data1 = Blob.valueOf(myurl); Blob data2 = Blob.valueOf(conId); Blob data3 = Blob.valueOf(EmailCon); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob data6 = Blob.valueOf(to); Blob data7 = Blob.valueOf(AddRecep); Blob data8 = Blob.valueOf(subject); Blob data9 = Blob.valueOf(body); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1); Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2); Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 ); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); Blob encryptedData6 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data6 ); Blob encryptedData7 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data7 ); Blob encryptedData8 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data8 ); Blob encryptedData9 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data9 ); String b64Data = EncodingUtil.base64Encode(encryptedData); String b64Data1 = EncodingUtil.base64Encode(encryptedData1); String b64Data2 = EncodingUtil.base64Encode(encryptedData2); String b64Data3 = EncodingUtil.base64Encode(encryptedData3); String b64Data4 = EncodingUtil.base64Encode(encryptedData4); String b64Data5 = EncodingUtil.base64Encode(encryptedData5); String b64Data6 = EncodingUtil.base64Encode(encryptedData6); String b64Data7 = EncodingUtil.base64Encode(encryptedData7); String b64Data8 = EncodingUtil.base64Encode(encryptedData8); String b64Data9 = EncodingUtil.base64Encode(encryptedData9); String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8'); String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8'); String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); String too= EncodingUtil.urlEncode(b64Data6, 'UTF-8'); String cccc= EncodingUtil.urlEncode(b64Data7, 'UTF-8'); String sbj= EncodingUtil.urlEncode(b64Data8, 'UTF-8'); String bdy= EncodingUtil.urlEncode(b64Data9, 'UTF-8'); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); req.setEndpoint('https://www.demomail.net/sf/api/SaveDemoMailPost'); req.setMethod('POST'); req.setHeader('Content-Type', 'application/x-www-form-urlencoded'); req.setBody('AUCode='+aucode+'&SOrgID='+ocode+'&Subject='+sbj+'&Body='+bdy+'&To='+too+'&CC='+cccc+'&Bcc='); system.debug('???'+aucode); try { res = http.send(req); if (res.getBody() != null) { System.debug('#Success!'); } else { System.debug('HTTP error: ' + res.getStatusCode()); } System.debug(res.getBody()); } catch(System.CalloutException e) { System.debug('Callout error: '+ e); } } public List<wrapContact> wrapContactList {get; set;} public List<Contact> selectedContacts{get;set;} Public String selectId {get;set;} public sendmailexample(){ body = apexpages.currentpage().getparameters().get('att'); if(wrapContactList == null) { wrapContactList= new List<wrapContact>(); for(Contact a: [SELECT Name,FirstName,LastName,Email,Title FROM Contact ORDER by Name ASC]) { wrapContactList.add(new wrapContact(a)); } } body = ''; to = EmailCon; } public void processSelected() { AddRecep = ''; selectedContacts = new List<Contact>(); for(wrapContact wrapContactObj : wrapContactList) { if(wrapContactObj.selected == true) { selectedContacts.add(wrapContactObj.acc); if (AddRecep == '') { AddRecep = wrapContactObj.acc.Email; } else { AddRecep += ';' + wrapContactObj.acc.Email ; } } } } public class wrapContact { public Contact acc {get; set;} public Boolean selected {get; set;} public wrapContact (Contact a) { acc = a; selected = false; } } }
- rupesh ranjan
- March 07, 2016
- Like
- 0
Error In Test Class kindly PLs any one help me out urgent basis
Error MessageSystem.NullPointerException: Argument cannot be null.
Stack TraceClass.sendmailp.sendpost: line 65, column 1
Class.sendmailcontacttest.runTest1: line 25, column 1
&
Error MessageSystem.NullPointerException: Attempt to de-reference a null object
Stack TraceClass.sendmailp.callapi2: line 1164, column 1
Class.sendmailcontacttest.runTest3: line 49, column 1
Stack TraceClass.sendmailp.sendpost: line 65, column 1
Class.sendmailcontacttest.runTest1: line 25, column 1
&
Error MessageSystem.NullPointerException: Attempt to de-reference a null object
Stack TraceClass.sendmailp.callapi2: line 1164, column 1
Class.sendmailcontacttest.runTest3: line 49, column 1
Test Class @isTest public class sendmailcontacttest{ static testMethod void runTest1() { Account account = new Account(); account.Name = 'Acc3'; insert account; Contact contact = new Contact(); contact.FirstName = 'Todda'; contact.LastName = 'Wilmss'; contact.AccountID = account.Id; contact.Email = 'twilms@verisign.conm'; contact.MobilePhone = '918527116723'; insert contact; test.startTest(); PageReference pageRef = Page.sendmail; // Your page name pageRef.getParameters().put('Id', String.valueOf(Contact.Id)); Test.setCurrentPage(pageRef); Test.setMock(HttpCalloutMock.class, new sendmailcontactmock()); ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object sendmailp testDObj = new sendmailp(); testDObj.sendpost(); test.stopTest(); } static testMethod void runTest3() { Account account = new Account(); account.Name = 'Acc3'; insert account; Contact contact = new Contact(); contact.FirstName = 'Todda'; contact.LastName = 'Wilmss'; contact.AccountID = account.Id; contact.Email = 'twilms@verisign.conm'; contact.MobilePhone = '918527116723'; insert contact; test.startTest(); PageReference pageRef = Page.Leadpage; // Your page name pageRef.getParameters().put('Id', String.valueOf(Contact.Id)); Test.setCurrentPage(pageRef); Test.setMock(HttpCalloutMock.class, new sendmailcontactmock()); ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object sendmailp testDObj = new sendmailp(); testDObj.callapi2(); test.stopTest(); } static testMethod void runTest4() { Account account = new Account(); account.Name = 'Acc3'; insert account; Contact contact = new Contact(); contact.FirstName = 'Todda'; contact.LastName = 'Wilmss'; contact.AccountID = account.Id; contact.Email = 'twilms@verisign.conm'; contact.MobilePhone = '918527116723'; insert contact; test.startTest(); PageReference pageRef = Page.Leadpage; // Your page name pageRef.getParameters().put('Id', String.valueOf(Contact.Id)); Test.setCurrentPage(pageRef); Test.setMock(HttpCalloutMock.class, new sendmailcontactmock()); ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object sendmailp testDObj = new sendmailp(); testDObj.getperformcallout(); test.stopTest(); } }
Mock Class @IsTest(seeAllData = false) global class sendmailcontactmock implements HttpCalloutMock { global HTTPResponse respond(HTTPRequest req) { HttpResponse res = new HttpResponse(); res.setHeader('Content-Type', 'application/json'); res.setBody('[{"foo":"bar"}]'); res.setStatusCode(200); return res; } }
Main Class Public class sendmailp{ public String to{get; set;} public String AddRecep{get; set;} public String subject {get; set;} public String body {get; set;} public String table3{get; set;} public String toAddresses {get; set;} public String MySessionID = UserInfo.getSessionID(); public String conId = ApexPages.currentPage().getParameters().get('Id'); public String EmailCon =[Select email from Contact where Id=:conId ].email; public String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId(); public string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; public String Acode= Userinfo.getuserid(); public String Oid = UserInfo.getOrganizationId(); Blob cryptoKey= EncodingUtil.base64Decode(c); Blob data = Blob.valueOf(MySessionID ); Blob data1 = Blob.valueOf(myurl); Blob data2 = Blob.valueOf(conId); Blob data3 = Blob.valueOf(EmailCon); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1); Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2); Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 ); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); public String b64Data = EncodingUtil.base64Encode(encryptedData); public String b64Data1 = EncodingUtil.base64Encode(encryptedData1); public String b64Data2 = EncodingUtil.base64Encode(encryptedData2); public String b64Data3 = EncodingUtil.base64Encode(encryptedData3); public String b64Data4 = EncodingUtil.base64Encode(encryptedData4); public String b64Data5 = EncodingUtil.base64Encode(encryptedData5); public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8'); public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); public sendmailp(ApexPages.StandardController controller) { AddRecep = ''; body=apexpages.currentpage().getparameters().get('att'); } public void sendpost(){ String MySessionID = UserInfo.getSessionID(); String conId = ApexPages.currentPage().getParameters().get('Id'); String EmailCon =[Select email from Contact where Id=:conId ].email; String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId(); string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; String Acode= Userinfo.getuserid(); String Oid = UserInfo.getOrganizationId(); Blob cryptoKey= EncodingUtil.base64Decode(c); Blob data = Blob.valueOf(MySessionID ); Blob data1 = Blob.valueOf(myurl); Blob data2 = Blob.valueOf(conId); Blob data3 = Blob.valueOf(EmailCon); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob data6 = Blob.valueOf(to); Blob data7 = Blob.valueOf(AddRecep); Blob data8 = Blob.valueOf(subject); Blob data9 = Blob.valueOf(body); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1); Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2); Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 ); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); Blob encryptedData6 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data6 ); Blob encryptedData7 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data7 ); Blob encryptedData8 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data8 ); Blob encryptedData9 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data9 ); String b64Data = EncodingUtil.base64Encode(encryptedData); String b64Data1 = EncodingUtil.base64Encode(encryptedData1); String b64Data2 = EncodingUtil.base64Encode(encryptedData2); String b64Data3 = EncodingUtil.base64Encode(encryptedData3); String b64Data4 = EncodingUtil.base64Encode(encryptedData4); String b64Data5 = EncodingUtil.base64Encode(encryptedData5); String b64Data6 = EncodingUtil.base64Encode(encryptedData6); String b64Data7 = EncodingUtil.base64Encode(encryptedData7); String b64Data8 = EncodingUtil.base64Encode(encryptedData8); String b64Data9 = EncodingUtil.base64Encode(encryptedData9); String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8'); String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8'); String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8'); String too= EncodingUtil.urlEncode(b64Data6, 'UTF-8'); String cccc= EncodingUtil.urlEncode(b64Data7, 'UTF-8'); String sbj= EncodingUtil.urlEncode(b64Data8, 'UTF-8'); String bdy= EncodingUtil.urlEncode(b64Data9, 'UTF-8'); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); req.setEndpoint('https://www.demomail.net/sf/api/SaveDemoMailPost'); req.setMethod('POST'); req.setHeader('Content-Type', 'application/x-www-form-urlencoded'); req.setBody('AUCode='+aucode+'&SOrgID='+ocode+'&Subject='+sbj+'&Body='+bdy+'&To='+too+'&CC='+cccc+'&Bcc='); system.debug('???'+aucode); try { res = http.send(req); if (res.getBody() != null) { System.debug('#Success!'); } else { System.debug('HTTP error: ' + res.getStatusCode()); } System.debug(res.getBody()); } catch(System.CalloutException e) { System.debug('Callout error: '+ e); } } public List<wrapContact> wrapContactList {get; set;} public List<Contact> selectedContacts{get;set;} Public String selectId {get;set;} public sendmailp(){ body = apexpages.currentpage().getparameters().get('att'); if(wrapContactList == null) { wrapContactList= new List<wrapContact>(); for(Contact a: [SELECT Name,FirstName,LastName,Email,Title FROM Contact ORDER by Name ASC]) { wrapContactList.add(new wrapContact(a)); } } normalList = true; selectedList = false; body = ''; to = EmailCon; } public void processSelected() { AddRecep = ''; selectedContacts = new List<Contact>(); for(wrapContact wrapContactObj : wrapContactList) { if(wrapContactObj.selected == true) { selectedContacts.add(wrapContactObj.acc); if (AddRecep == '') { AddRecep = wrapContactObj.acc.Email; } else { AddRecep += ';' + wrapContactObj.acc.Email ; } } } } public class wrapContact { public Contact acc {get; set;} public Boolean selected {get; set;} public wrapContact (Contact a) { acc = a; selected = false; } } public List<video> ConsoleWrapperList1{get;set;} public String consolewrap{get;set;} public String SessionId = ''; public void callapi2(){ String SessionId = ''; string testSessionId = ''; for( consolewrap cwt : ConsoleWrapperList){ testSessionId += cwt.sid; if(cwt.selected){ if(SessionId == ''){ SessionId += cwt.SessionId; }else{ SessionId += ','+ cwt.SessionId; } } } system.debug('testSessionId+++'+testSessionId); List<video> ConsoleWrapperList1 = new List<video>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); system.debug('SessionId+++'+SessionId); string url = 'https://www.demomail.net/sf/api/SendVideoContactPreview?AUCode='+aucode+'&SOrgID='+ocode+'&SessionIds='+SessionId; req.setEndpoint(url); req.setMethod('GET'); res = http.send(req); if(res.getstatusCode() == 200 && res.getbody() != null){ String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r',''); ConsoleWrapperList1=(List<video>)System.JSON.deserialize(replaceIllegal,List<video>.class); system.debug('ConsoleWrapperList1+++'+ConsoleWrapperList1); body = ConsoleWrapperList1.get(0).bodyT; } } public String ssnid{get;set;} public boolean normalList{get;set;} public boolean selectedList{get;set;} public String Title{get;set;} public Boolean selected {get; set;} public List<consolewrap> ConsoleWrapperList{get;set;} public List<consolewrap> getperformcallout(){ ConsoleWrapperList = new List<consolewrap>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); string url = 'https://www.demomail.net/sf/api/SendVideoContact?AUCode='+aucode+'&SOrgID='+ocode+'&id='+SessionId; System.debug('##: '+ SessionId); req.setEndpoint(url); req.setMethod('GET'); res = http.send(req); if(res.getstatusCode() == 200 && res.getbody() != null){ ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class); System.debug('value: '+ ConsoleWrapperList ); } return consolewrapperlist; } }
- rupesh ranjan
- March 06, 2016
- Like
- 0
Any one pls remove this error from test class System.NullPointerException: Argument cannot be null.
Any one pls remove this error from test class
System.NullPointerException: Argument cannot be null.
Class.Leadpage.<init>: line 19, column 1
Class.Leadtestsss.runTest1: line 31, column 1
System.NullPointerException: Argument cannot be null.
Class.Leadpage.<init>: line 19, column 1
Class.Leadtestsss.runTest1: line 31, column 1
TEST Class @isTest public class Leadtestss{ static testMethod void runTest1() { Account account = new Account(); account.Name = 'Acc3'; insert account; Contact contact = new Contact(); contact.FirstName = 'Todda'; contact.LastName = 'Wilmss'; contact.AccountID = account.Id; contact.Email = 'twilms@verisign.conm'; contact.MobilePhone = '918527116723'; insert contact; Lead lead = new Lead(); lead.FirstName = 'test'; lead.LastName = 'foo'; lead.company='Acc3'; insert lead; test.startTest(); PageReference pageRef = Page.Leadpage; pageRef.getParameters().put('Id', String.valueOf(lead.Id)); Test.setCurrentPage(pageRef); Test.setMock(HttpCalloutMock.class, new Leadpagemock()); ApexPages.StandardController sc1 = new ApexPages.StandardController(Lead);//Instance of your object Leadpage testDObj = new Leadpage(); testDObj.getperformcallout(); test.stopTest(); } }
Page MOCK Class @IsTest(seeAllData = false) global class Leadpagemock implements HttpCalloutMock { global HTTPResponse respond(HTTPRequest req) { HttpResponse res = new HttpResponse(); res.setHeader('Content-Type', 'application/json'); res.setBody('[{"foo":"bar"}]'); res.setStatusCode(200); return res; } }
Main Class public class Leadpage{ public Leadpage(ApexPages.StandardController controller) { } public Leadpage() {} public String MySessionID = UserInfo.getSessionID(); public String conId = ApexPages.currentPage().getParameters().get('Id'); public String EmailCon=[Select email from Lead where Id=:conId ].email; public String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId(); public string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw='; public String Acode='00530000000rLMxAAM'; public String Oid = UserInfo.getOrganizationId(); Blob cryptoKey= EncodingUtil.base64Decode(c); Blob data = Blob.valueOf(MySessionID ); Blob data1 = Blob.valueOf(myurl); Blob data2 = Blob.valueOf(conId); Blob data3 = Blob.valueOf(EmailCon); Blob data4 = Blob.valueOf(Acode); Blob data5 = Blob.valueOf(Oid); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1); Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2); Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 ); Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 ); Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 ); public String b64Data = EncodingUtil.base64Encode(encryptedData); public String b64Data1 = EncodingUtil.base64Encode(encryptedData1); public String b64Data2 = EncodingUtil.base64Encode(encryptedData2); public String b64Data3 = EncodingUtil.base64Encode(encryptedData3); public String b64Data4 = EncodingUtil.base64Encode(encryptedData4); public String b64Data5 = EncodingUtil.base64Encode(encryptedData5); String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8'); public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8'); public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8'); public String ocode= EncodingUtil.urlEncode (b64Data5, 'UTF-8'); public List<LeadVideoViewAllWrap> ConsoleWrapperList{get;set;} public List<LeadVideoViewAllWrap> getperformcallout(){ ConsoleWrapperList = new List<LeadVideoViewAllWrap>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); string url = 'https://www.demomail.net/sf/api/LeadVideoViewAllController?AUCode='+aucode+'&SOrgID='+ocode+'&Email='+email+'&session='+testurl; req.setEndpoint(url); req.setMethod('GET'); res = http.send(req); if(res.getstatusCode() == 200 && res.getbody() != null){ ConsoleWrapperList=(List<LeadVideoViewAllWrap>)json.deserialize(res.getbody(),List<LeadVideoViewAllWrap>.class); } return consolewrapperlist; } }
- rupesh ranjan
- March 06, 2016
- Like
- 0
Encryption are not working plss Help its urgent
Encryption are not working plss Help its urgent
public String to{get; set;} Blob data6 = Blob.valueOf(to); Blob encryptedData6 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data6 ); public String b64Data6 = EncodingUtil.base64Encode(encryptedData6); public String too= EncodingUtil.urlEncode(b64Data6, 'UTF-8');
- rupesh ranjan
- March 02, 2016
- Like
- 0
Not Geting any value for API call
<apex:pageBlockTable value="{!performcallout4}" var="wrap" width="100%"> <apex:column headerValue="Subject" value="{!wrap.Subject}"/> <apex:column headerValue="Video Title" value="{!wrap.SessionTitle}"/> <apex:column headerValue="Sent Date" value="{!wrap.SentDate}"/> <apex:column headerValue="Subject" value="{!wrap.Subject}"/> <apex:column headerValue="Sent Date" value="{!wrap.SentDate}"/> <apex:column headerValue="Recipients" value="{!wrap.NoOfContacts}"/> <apex:column headerValue="Opens" value="{!wrap.OpenTimes}"/> <apex:column headerValue="View Count" value="{!wrap.ViewedTimes}"/> <apex:column headerValue="Part of mail merge?" value="{!wrap.SenderEmail}"/> </apex:pageBlockTable>
Visualforce Error
Help for this Page
System.AssertException: Assertion Failed: <html><head><title>Object moved</title></head><body> <h2>Object moved to <a href="https://www.demomail.net/sf/">here</a>.</h2> </body></html>
public class Contactpage1{ public Contactpage1(ApexPages.StandardController controller) { } public List<contactDemoMailSentwrap> ConsoleWrapperList4{get;set;} public List<contactDemoMailSentwrap> getperformcallout4(){ ConsoleWrapperList4 = new List<contactDemoMailSentwrap>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); req.setEndpoint('https://www.demomail.net/sf/api/ContactDemoMailSent?Email=twilms@verisign.con&NameSpace=Demos%20On%20Demand%20Report'); req.setTimeout(10000); req.setMethod('GET'); res = http.send(req); //System.assert(false,res.getBody()); if(res.getstatusCode() == 200){ String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r',''); ConsoleWrapperList4= (List<contactDemoMailSentwrap>)System.JSON.deserialize(replaceIllegal,List<contactDemoMailSentwrap>.class); System.debug('***********: '+ ConsoleWrapperList4 ); } return consolewrapperlist4; } }
- rupesh ranjan
- February 24, 2016
- Like
- 0
I want to write Test class
I want to write Test class for belowclass
public class Contactpage{ public Contactpage(ApexPages.StandardController controller) { } public List<contactDemoMailSentwrap> ConsoleWrapperList4{get;set;} public List<contactDemoMailSentwrap> getperformcallout4(){ ConsoleWrapperList4 = new List<contactDemoMailSentwrap>(); HttpRequest req = new HttpRequest(); HttpResponse res = new HttpResponse(); Http http = new Http(); req.setEndpoint('https://www.demomail.net/sf/api/ContactDemoMailSent?Email=twilms@verisign.con&NameSpace=Demos%20On%20Demand%20Report'); req.setMethod('GET'); req.setTimeout(10000); res = http.send(req); //System.assert(false,res.getBody()+'-----'); if(res.getstatusCode() == 200 && res.getbody() != null){ String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r',''); ConsoleWrapperList4=(List<contactDemoMailSentwrap>)System.JSON.deserialize(replaceIllegal,List<contactDemoMailSentwrap>.class); } return consolewrapperlist4; } }
- rupesh ranjan
- February 23, 2016
- Like
- 0
I want to display value like this. (highlighted with Cross cancel)
I want to display value like this. (highlighted with Cross cancel)
- rupesh ranjan
- February 19, 2016
- Like
- 0
Why mails are coming into Spam Folder
public pageReference send(){ Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); List<String> ccAddresses =new List<String>(); if (AddRecep != '' && AddRecep != null) { ccAddresses = AddRecep.split(';'); email.setTargetObjectId(conId); email.setCcAddresses(ccAddresses); email.setSubject(subject); email.setHtmlBody(body); Messaging.SendEmailResult [] res = Messaging.SendEmail(new Messaging.SingleEmailMessage[] {email}); for ( Messaging.sendEmailResult result : res ) { if ( !res[0].isSuccess () ) { System.debug ( result ); } } } return null; }
- rupesh ranjan
- February 19, 2016
- Like
- 1
Not getting any Value in CK editor on Parent Page . Value is coming through action button of child page How to reRender the Parent page
Not getting any Value in CK editor on Parent Page . Value is coming through action button of child page
How to reRender the Parent page
//////////////////////Parent Page////////////////////////////////
<apex:page StandardController="Contact" extensions="AccountSelectClassController" >
<script>
var newWin=null;
function check(){
var url='/apex/selectvideo2';
newWin=window.open(url, 'Popup','height=500,width=700,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
}
function closePopup(){
if (null!=newWin){
newWin.close();
}
}
</script>
<apex:form id="frmId">
<apex:outputLabel value="Choose Video "/>
<apex:outputLink onClick="check();return false;"> <br/>
Click here to choose session </apex:outputLink>
<br/><br/>
<apex:outputLabel value="Body" for="Body"/>:<br/>
<apex:inputtextarea value="{!body}" id="body" styleClass="ckeditor" richtext="false" style="width: 500px; height: 150px;">
</apex:inputtextarea>
<br/><br/><br/>
<apex:includescript value="{!URLFOR($Resource.CkEditor,'ckeditor/ckeditor.js')}" />
</apex:pageblock>
</apex:form>
</apex:page>
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ child Pop up page////////////////////////////////
<apex:commandButton value="Done" onclick="CloseWindow(); return false;" action="{!callapi2}" />
</apex:pageBlock>
<script>
function CloseWindow(){
var winMain=window.opener;
if (null==winMain){
winMain=window.parent.opener;
}
winMain.closePopup()
}
</script>
</apex:form>
/////////////////////////Controller\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
public void callapi2(){
//body = '';
String SessionId = '';
for( consolewrap cwt : selectedWrapperList){
if(cwt.selected){
if(SessionId == ''){
SessionId += cwt.sid;
}else{
SessionId += ','+ cwt.sid;
}
}
}
List<video> ConsoleWrapperList1 = new List<video>();
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('http://webapi.demomail.net/test/SendVideoBody.js?id='+SessionId);
req.setMethod('GET');
res = http.send(req);
if(res.getstatusCode() == 200 && res.getbody() != null){
String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','').replace('','');
ConsoleWrapperList1=(List<video>)System.JSON.deserialize(replaceIllegal,List<video>.class);
body = ConsoleWrapperList1.get(0).bodyT;
System.debug('***********: '+ body );
}
}
How to reRender the Parent page
//////////////////////Parent Page////////////////////////////////
<apex:page StandardController="Contact" extensions="AccountSelectClassController" >
<script>
var newWin=null;
function check(){
var url='/apex/selectvideo2';
newWin=window.open(url, 'Popup','height=500,width=700,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
}
function closePopup(){
if (null!=newWin){
newWin.close();
}
}
</script>
<apex:form id="frmId">
<apex:outputLabel value="Choose Video "/>
<apex:outputLink onClick="check();return false;"> <br/>
Click here to choose session </apex:outputLink>
<br/><br/>
<apex:outputLabel value="Body" for="Body"/>:<br/>
<apex:inputtextarea value="{!body}" id="body" styleClass="ckeditor" richtext="false" style="width: 500px; height: 150px;">
</apex:inputtextarea>
<br/><br/><br/>
<apex:includescript value="{!URLFOR($Resource.CkEditor,'ckeditor/ckeditor.js')}" />
</apex:pageblock>
</apex:form>
</apex:page>
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ child Pop up page////////////////////////////////
<apex:commandButton value="Done" onclick="CloseWindow(); return false;" action="{!callapi2}" />
</apex:pageBlock>
<script>
function CloseWindow(){
var winMain=window.opener;
if (null==winMain){
winMain=window.parent.opener;
}
winMain.closePopup()
}
</script>
</apex:form>
/////////////////////////Controller\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
public void callapi2(){
//body = '';
String SessionId = '';
for( consolewrap cwt : selectedWrapperList){
if(cwt.selected){
if(SessionId == ''){
SessionId += cwt.sid;
}else{
SessionId += ','+ cwt.sid;
}
}
}
List<video> ConsoleWrapperList1 = new List<video>();
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('http://webapi.demomail.net/test/SendVideoBody.js?id='+SessionId);
req.setMethod('GET');
res = http.send(req);
if(res.getstatusCode() == 200 && res.getbody() != null){
String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','').replace('','');
ConsoleWrapperList1=(List<video>)System.JSON.deserialize(replaceIllegal,List<video>.class);
body = ConsoleWrapperList1.get(0).bodyT;
System.debug('***********: '+ body );
}
}
- rupesh ranjan
- February 16, 2016
- Like
- 0
Problem is not getting mail to List mail of address
Problem is not getting mail to List mail of address only mail goes to "rupesh@webmindinfotech.com". But i want List of mail that should be fire.
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
List<String> toAddress =new List<String>();
String emailadd = 'rupesh@webmindinfotech.com';
List<String> toAddresses = emailadd.split(';');
email.setToAddresses(toAddresses );
email.setSubject(subject);
email.setPlainTextBody(body);
email.setBccSender(true);
Messaging.SendEmailResult [] res = Messaging.SendEmail(new Messaging.SingleEmailMessage[] {email});
for ( Messaging.sendEmailResult result : res ) {
if ( !res[0].isSuccess () ) {
System.debug ( result );
}
else{
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.INFO, 'Email Sent Successfully' );
ApexPages.addMessage(msg);
}
}
return null;
}
public SendEmail(){
body = apexpages.currentpage().getparameters().get('att');
}
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
List<String> toAddress =new List<String>();
String emailadd = 'rupesh@webmindinfotech.com';
List<String> toAddresses = emailadd.split(';');
email.setToAddresses(toAddresses );
email.setSubject(subject);
email.setPlainTextBody(body);
email.setBccSender(true);
Messaging.SendEmailResult [] res = Messaging.SendEmail(new Messaging.SingleEmailMessage[] {email});
for ( Messaging.sendEmailResult result : res ) {
if ( !res[0].isSuccess () ) {
System.debug ( result );
}
else{
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.INFO, 'Email Sent Successfully' );
ApexPages.addMessage(msg);
}
}
return null;
}
public SendEmail(){
body = apexpages.currentpage().getparameters().get('att');
}
- rupesh ranjan
- February 05, 2016
- Like
- 0