-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
4Questions
-
3Replies
Multiple soql statements pull similar data, but i'm trying to figure out a test class for the old info.
public Risk_AnalysisExtController(ApexPages.StandardController stdController) {
string trustedTicket ='';
//dashboard url with trusted ticket
server = 'https://test.tableaureporting.test.com';
if (Functions.isProduction()) server = 'https://tableaureporting.test.com';
//currently loggedin user
User u = [select name, Alias, CommunityNickname, FederationIdentifier, Domain_Credential__c, SAP_Partner_Number__c from user where Id = :UserInfo.getUserId() limit 1]; //added Domain_Credential__c
string userid = '';
if(vUser(u.id).equals('Correct'))
userid =u.Domain_Credential__c.toLowerCase();
if(u.SAP_Partner_Number__c!=null)uId = String.valueof('000'+u.SAP_Partner_Number__c);
system.debug('uId'+uId);
// system.debug('userid = ' +userid);
// system.debug('server = '+ server);
//retrieve trusted ticket
trustedTicket = getTicket(userid, 'Sales_Ops', server);
rootURL = server+ '/trusted/'+trustedTicket;
system.debug('rootURL = '+rootURL);
system.debug('trustedTicket = '+ trustedTicket);
//buffer
serListHistory = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c where Serial_Number__c=: paramSer];
serListAllExist = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c where Serial_Number__c=: paramSer];
serListAllNew = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c where Serial_Number__c=: paramSer];
listRiskAnalysis = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c];
public void ShowSer() {
// system.debug('paramSer = '+paramSer);
// system.debug('paramCust = '+paramCust);
// system.debug('paramThem ='+paramThem);
// system.debug('inputComment = '+inputComment);
// system.debug('paramBrandT = '+paramBrandT);
if((paramSer!=null && paramCust != null && paramThem != null) && (paramSer!='' && paramCust != '' && paramThem != '') ) {
//Risk_Analysis__c serList;
serList = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c, Removal_Reason__c,
Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c where Serial_Number__c =: paramSer and Theme__c =:paramThem ];
if(serList.isEmpty()) {
String CustNum;
CustNum = paramCust.right(7);
Risk_Analysis__c riskTemp = new Risk_Analysis__c(
Serial_Number__c = paramSer,
Customer__c = CustNum,
Theme__c = paramThem,
Comments__c = inputComment,
End_of_Life_Date__c = inputDate,
Action__c = actionOpt,
Removal_Reason__c = removalReason,
Customer_Name__c = paramCustText,
Brand_Name__c = paramBrandT,
Theme_Name__c = paramThemText,
Cabinet__c = paramMat
);
MapCheckSer.put(paramSer, riskTemp);
serListAllNew = MapCheckSer.values();
MapCommentsExist.put(paramSer, inputComment);
}
if(!serList.isEmpty()) {
Risk_Analysis__c serListTemp;
serListTemp = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c, Removal_Reason__c,
Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c where Serial_Number__c =: paramSer and Theme__c =:paramThem ];
MapCheckExist.put(serListTemp.Serial_Number__c, serListTemp);
serListHistory = MapCheckExist.values();
MapCommentsExist.put(paramSer, serListTemp.Comments__c);
}
// system.debug('MapCommentsExist value = '+MapCommentsExist);
}
}
public void saveAll() {
boolean hasComments = true;
if(serListAllNew!=null) {
for(integer j= 0; j<serListAllNew.size(); j++) {
if(serListAllNew.get(j).Comments__c == null || serListAllNew.get(j).Comments__c == '' || serListAllNew.get(j).Comments__c == ' ')
hasComments = false;
}
if(hasComments == true) {
insert serListAllNew;
serListAllNew.clear();
MapCheckSer.clear();
}
else
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Please enter a comment, or remove this record from the list to process further.') );
}
if(serListHistory!=null) {
for(integer j= 0; j<serListHistory.size(); j++) {
if(serListHistory.get(j).Comments__c == null || serListHistory.get(j).Comments__c == '')
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Please enter a comment, or remove this record from the list to process further.') );
else {
upsert serListHistory;
serListHistory.clear();
MapCheckExist.clear();
}
}
}
}
}
So theres some of the prelimary, now i have coverage on everything there minus a apexpages.addmessage, but thats just one line so i don't mind right now. my main issue is this
//Test, please don't delete
/*public void myTest() {
outputComment = inputComment;
}*/
public PageReference removeRecord() {
outputSer = inputSer;
Risk_Analysis__c removedItem;
if(MapCheckSer.containsKey(inputSer)) {
removedItem = MapCheckSer.remove(inputSer);
serListAllNew.clear();
serListAllNew = MapCheckSer.values();
PageReference page = new PageReference(ApexPages.currentPage().getURL());
page.setRedirect(true);
return null;
}
else if(MapCheckExist.containsKey(inputSer)) {
removedItem = MapCheckExist.remove(inputSer);
serListHistory.clear();
serListHistory = MapCheckExist.values();
PageReference page = new PageReference(ApexPages.currentPage().getURL());
page.setRedirect(true);
return null;
}
return null;
The else if statement, i can't get that to get coverage. Now i was handed this code and told "hey intern finish test coverage, get it to 90%" i'm at 87%.... :(
now if i don't have data for either the if line will be covers and the else if line will be covered but obviously it wont cover
else if(MapCheckExist.containsKey(inputSer)) {
removedItem = MapCheckExist.remove(inputSer);
serListHistory.clear();
serListHistory = MapCheckExist.values();
PageReference page = new PageReference(ApexPages.currentPage().getURL());
page.setRedirect(true);
return null;
I'm stuck..
-
- Enozzir
- July 25, 2018
- Like
- 0
lowly intern is search of help regarding wrapper class test coverage
public class Risk_AnalysisExtController {
public String server {get;set;}
public String rootURL {get;set;}
public string uId {get;set;}
public String inputSer {get; set;} //line290
public List<Risk_Analysis__c> listRiskAnalysis {get; set;} //All
public List<Risk_Analysis__c> custListHistory {get; set;} //when user select customer
public List<Risk_Analysis__c> serListHistory {get; set;} //when user select serial
public List<Risk_Analysis__c> serListAllExist {get; set;}
public List<Risk_Analysis__c> serList {get; set;}
public List<Risk_Analysis__c> serListAllNew {get; set;}
public string paramCust {get; set;}
public string paramSer {get; set;}
public string paramThem {get; set;}
public string inputComment {get; set;}
public string paramCustText {get; set;}
public string paramThemText {get; set;}
public string paramBrandT {get; set;}
public string paramMat {get; set;}
public string actionOpt {get; set;}
public date inputDate {get; set;}
public string removalReason {get; set;}
//public Id machId {get; set;}
Map<string, Risk_Analysis__c> MapCheckSer = new Map<string, Risk_Analysis__c>();
Map<string, Risk_Analysis__c> MapCheckExist = new Map<string, Risk_Analysis__c>();
Map<string, string> MapCommentsExist = new Map<string, string>();
public string outputSer {get; set;} //line292
//public string delCust {get; set;}
//public string delSer {get; set;}
//private list<Risk_Analysis__c> delRisk = new list<Risk_Analysis__c>();
private Risk_Analysis__c delRisk ;
public PageReference pageRef;
public Map<string, string> URLParameters = ApexPages.currentPage().getParameters();
public Id currentPageId;
List<riskWrapper> rList = new List<riskWrapper>();
List<Risk_Analysis__c> selectedRecords = new List<Risk_Analysis__c>();
public List<Risk_Analysis__c> delRecords = new List<Risk_Analysis__c>();
public list<riskWrapper> riskList = new List<riskWrapper>();// {get; set;}
public Risk_AnalysisExtController(ApexPages.StandardController stdController) {
string trustedTicket ='';
//dashboard url with trusted ticket
server = 'https://test.tableaureporting.test.com';
if (Functions.isProduction()) server = 'https://tableaureporting.test.com';
//currently loggedin user
User u = [select name, Alias, CommunityNickname, FederationIdentifier, Domain_Credential__c, SAP_Partner_Number__c from user where Id = :UserInfo.getUserId() limit 1]; //added Domain_Credential__c
string userid = '';
if(vUser(u.id).equals('Correct'))
userid =u.Domain_Credential__c.toLowerCase();
if(u.SAP_Partner_Number__c!=null)uId = String.valueof('000'+u.SAP_Partner_Number__c);
// system.debug('uId'+uId);
// system.debug('userid = ' +userid);
// system.debug('server = '+ server);
//retrieve trusted ticket
trustedTicket = getTicket(userid, 'Sales_Ops', server);
rootURL = server+ '/trusted/'+trustedTicket;
system.debug('rootURL = '+rootURL);
system.debug('trustedTicket = '+ trustedTicket);
//buffer
serListHistory = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c where Serial_Number__c=: paramSer];
serListAllExist = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c where Serial_Number__c=: paramSer];
serListAllNew = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c where Serial_Number__c=: paramSer];
listRiskAnalysis = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c];
/*if(paramCust!= null && paramCust.isNumeric() && (paramSer == null || paramSer == '')) {
String CustNumTemp;
CustNumTemp = paramCust.right(7);
custListHistory = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c, Delete__c
from Risk_Analysis__c where Customer__c =: CustNumTemp];
}
MapCommentsExist.put(paramSer, inputComment);*/
}
public class riskWrapper
{
public Risk_Analysis__c risk{get; set;}
public Boolean selected {get; set;}
public RiskWrapper(Risk_Analysis__c r)
{
risk = r;
selected = false;
}
}
So here's a section of of a class i have to write a test class for. They want 90% coverage, I'm at 87%, lol woe is me.
My one problem is the wrapper class, through the rest of the code and this snippet it's the one thing i can't seem to get coverage one.... I've tried
class.wrapper wrap = new class.wrapper();But i cant seem to figure that one out....i tried to insert and also map<string,string> mapvr = new map<string,string(); refer to the class set var; list<apexpages.message>msgs = apexpages.getmessages(); then mpvr.put(field, data) then trying to force the wrapper by referencing to it directly..
I only need coverage not functionality at this point because that's all been tested and the rest of my test class covers 87% of the functionallity.
-
- Enozzir
- July 25, 2018
- Like
- 0
Unable to get my testclass to cover a an if statement that references user data
public class Risk_AnalysisExtController {
public String server {get;set;}
public String rootURL {get;set;}
public string uId {get;set;}
public String inputSer {get; set;} //line290
public List<Risk_Analysis__c> listRiskAnalysis {get; set;} //All
public List<Risk_Analysis__c> custListHistory {get; set;} //when user select customer
public List<Risk_Analysis__c> serListHistory {get; set;} //when user select serial
public List<Risk_Analysis__c> serListAllExist {get; set;}
public List<Risk_Analysis__c> serList {get; set;}
public List<Risk_Analysis__c> serListAllNew {get; set;}
public string paramCust {get; set;}
public string paramSer {get; set;}
public string paramThem {get; set;}
public string inputComment {get; set;}
public string paramCustText {get; set;}
public string paramThemText {get; set;}
public string paramBrandT {get; set;}
public string paramMat {get; set;}
public string actionOpt {get; set;}
public date inputDate {get; set;}
public string removalReason {get; set;}
//public Id machId {get; set;}
Map<string, Risk_Analysis__c> MapCheckSer = new Map<string, Risk_Analysis__c>();
Map<string, Risk_Analysis__c> MapCheckExist = new Map<string, Risk_Analysis__c>();
Map<string, string> MapCommentsExist = new Map<string, string>();
public string outputSer {get; set;} //line292
//public string delCust {get; set;}
//public string delSer {get; set;}
//private list<Risk_Analysis__c> delRisk = new list<Risk_Analysis__c>();
private Risk_Analysis__c delRisk ;
public PageReference pageRef;
public Map<string, string> URLParameters = ApexPages.currentPage().getParameters();
public Id currentPageId;
List<riskWrapper> rList = new List<riskWrapper>();
List<Risk_Analysis__c> selectedRecords = new List<Risk_Analysis__c>();
public List<Risk_Analysis__c> delRecords = new List<Risk_Analysis__c>();
public list<riskWrapper> riskList = new List<riskWrapper>();// {get; set;}
public Risk_AnalysisExtController(ApexPages.StandardController stdController) {
string trustedTicket ='';
//dashboard url with trusted ticket
server = 'https://test.tableaureporting.test.com';
if (Functions.isProduction()) server = 'https://tableaureporting.test.com';
//currently loggedin user
User u = [select name, Alias, CommunityNickname, FederationIdentifier, Domain_Credential__c, SAP_Partner_Number__c from user where Id = :UserInfo.getUserId() limit 1]; //added Domain_Credential__c
string userid = '';
if(vUser(u.id).equals('Correct'))
userid =u.Domain_Credential__c.toLowerCase();
if(u.SAP_Partner_Number__c!=null)uId = String.valueof('000'+u.SAP_Partner_Number__c);
// system.debug('uId'+uId);
// system.debug('userid = ' +userid);
// system.debug('server = '+ server);
//retrieve trusted ticket
trustedTicket = getTicket(userid, 'Sales_Ops', server);
rootURL = server+ '/trusted/'+trustedTicket;
system.debug('rootURL = '+rootURL);
system.debug('trustedTicket = '+ trustedTicket);
//buffer
serListHistory = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c where Serial_Number__c=: paramSer];
serListAllExist = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c where Serial_Number__c=: paramSer];
serListAllNew = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c where Serial_Number__c=: paramSer];
listRiskAnalysis = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c];
/*if(paramCust!= null && paramCust.isNumeric() && (paramSer == null || paramSer == '')) {
String CustNumTemp;
CustNumTemp = paramCust.right(7);
custListHistory = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c, Delete__c
from Risk_Analysis__c where Customer__c =: CustNumTemp];
}
MapCommentsExist.put(paramSer, inputComment);*/
}
public class riskWrapper
{
public Risk_Analysis__c risk{get; set;}
public Boolean selected {get; set;}
public RiskWrapper(Risk_Analysis__c r)
{
risk = r;
selected = false;
}
}
//prevent crashing sparkler server
public string vUser(string uid) {
User u = [select name, Alias, CommunityNickname, FederationIdentifier, Domain_Credential__c from user
where Id = :uid];
string uName = u.Domain_Credential__c.toLowerCase();
if(uname == null || !u.Domain_Credential__c.contains('@') || uName.substringBefore('@').contains('.')
|| uName.escapeJava().contains('\\') || uname.contains('@firm2.com') || uname.contains('@firm1.com') ) { //TKT-0931762
ApexPages.Message myMsg =
new ApexPages.Message(ApexPages.Severity.Error,
'Domain Credential Error. Please log an SFDC Internal HelpDesk ticket with a screenshot. Thank you.');
ApexPages.addMessage(myMsg);
return 'Domain Credential Error. Please log an SFDC Internal HelpDesk ticket with a screenshot. Thank you.';
}
else
return 'Correct';
}
So I've tried a multitude of methods (insert, update, .put) but i cant seem to get the last if statement at the end to come out as true in one of my testclasses.
this if statement
if(uname == null || !u.Domain_Credential__c.contains('@') || uName.substringBefore('@').contains('.')
|| uName.escapeJava().contains('\\') || uname.contains('@firm2.com') || uname.contains('@firm1.com') ) { //TKT-0931762
ApexPages.Message myMsg =
new ApexPages.Message(ApexPages.Severity.Error,
'Domain Credential Error. Please log an SFDC Internal HelpDesk ticket with a screenshot. Thank you.');
ApexPages.addMessage(myMsg);
return 'Domain Credential Error. Please log an SFDC Internal HelpDesk ticket with a screenshot. Thank you.';
*do note i'm not showing all my code just relevent sections*
For whatever reason nothing i do seems to be able to trigger that if statement and get that error message to blast off.
-
- Enozzir
- July 24, 2018
- Like
- 0
How to use dot notation to reference the record type?
So heres a small portion of my code
if(newOpp.Go_Live_Date__c != oldOpp.Install_Date__c && newOpp.Go_Live_Date__c != null)
newOpp.Install_Date__c = newpp.Go_Live_Date__c;
Now i wanted to add another && to the if statement, but i want to i want it to .... if the opp in question is a record type sales..ie equal to..
how would i go about that?
if(newOpp.Go_Live_Date__c != oldOpp.Install_Date__c && newOpp.Go_Live_Date__c != null)
newOpp.Install_Date__c = newpp.Go_Live_Date__c;
Now i wanted to add another && to the if statement, but i want to i want it to .... if the opp in question is a record type sales..ie equal to..
how would i go about that?
-
- Enozzir
- July 20, 2018
- Like
- 0
Unable to get my testclass to cover a an if statement that references user data
public class Risk_AnalysisExtController {
public String server {get;set;}
public String rootURL {get;set;}
public string uId {get;set;}
public String inputSer {get; set;} //line290
public List<Risk_Analysis__c> listRiskAnalysis {get; set;} //All
public List<Risk_Analysis__c> custListHistory {get; set;} //when user select customer
public List<Risk_Analysis__c> serListHistory {get; set;} //when user select serial
public List<Risk_Analysis__c> serListAllExist {get; set;}
public List<Risk_Analysis__c> serList {get; set;}
public List<Risk_Analysis__c> serListAllNew {get; set;}
public string paramCust {get; set;}
public string paramSer {get; set;}
public string paramThem {get; set;}
public string inputComment {get; set;}
public string paramCustText {get; set;}
public string paramThemText {get; set;}
public string paramBrandT {get; set;}
public string paramMat {get; set;}
public string actionOpt {get; set;}
public date inputDate {get; set;}
public string removalReason {get; set;}
//public Id machId {get; set;}
Map<string, Risk_Analysis__c> MapCheckSer = new Map<string, Risk_Analysis__c>();
Map<string, Risk_Analysis__c> MapCheckExist = new Map<string, Risk_Analysis__c>();
Map<string, string> MapCommentsExist = new Map<string, string>();
public string outputSer {get; set;} //line292
//public string delCust {get; set;}
//public string delSer {get; set;}
//private list<Risk_Analysis__c> delRisk = new list<Risk_Analysis__c>();
private Risk_Analysis__c delRisk ;
public PageReference pageRef;
public Map<string, string> URLParameters = ApexPages.currentPage().getParameters();
public Id currentPageId;
List<riskWrapper> rList = new List<riskWrapper>();
List<Risk_Analysis__c> selectedRecords = new List<Risk_Analysis__c>();
public List<Risk_Analysis__c> delRecords = new List<Risk_Analysis__c>();
public list<riskWrapper> riskList = new List<riskWrapper>();// {get; set;}
public Risk_AnalysisExtController(ApexPages.StandardController stdController) {
string trustedTicket ='';
//dashboard url with trusted ticket
server = 'https://test.tableaureporting.test.com';
if (Functions.isProduction()) server = 'https://tableaureporting.test.com';
//currently loggedin user
User u = [select name, Alias, CommunityNickname, FederationIdentifier, Domain_Credential__c, SAP_Partner_Number__c from user where Id = :UserInfo.getUserId() limit 1]; //added Domain_Credential__c
string userid = '';
if(vUser(u.id).equals('Correct'))
userid =u.Domain_Credential__c.toLowerCase();
if(u.SAP_Partner_Number__c!=null)uId = String.valueof('000'+u.SAP_Partner_Number__c);
// system.debug('uId'+uId);
// system.debug('userid = ' +userid);
// system.debug('server = '+ server);
//retrieve trusted ticket
trustedTicket = getTicket(userid, 'Sales_Ops', server);
rootURL = server+ '/trusted/'+trustedTicket;
system.debug('rootURL = '+rootURL);
system.debug('trustedTicket = '+ trustedTicket);
//buffer
serListHistory = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c where Serial_Number__c=: paramSer];
serListAllExist = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c where Serial_Number__c=: paramSer];
serListAllNew = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c where Serial_Number__c=: paramSer];
listRiskAnalysis = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c
from Risk_Analysis__c];
/*if(paramCust!= null && paramCust.isNumeric() && (paramSer == null || paramSer == '')) {
String CustNumTemp;
CustNumTemp = paramCust.right(7);
custListHistory = [Select Id, Customer__c, Comments__c, Serial_Number__c, Theme__c, End_of_Life_Date__c, Action__c,
Removal_Reason__c, Customer_Name__c, Brand_Name__c, Theme_Name__c, Cabinet__c, Delete__c
from Risk_Analysis__c where Customer__c =: CustNumTemp];
}
MapCommentsExist.put(paramSer, inputComment);*/
}
public class riskWrapper
{
public Risk_Analysis__c risk{get; set;}
public Boolean selected {get; set;}
public RiskWrapper(Risk_Analysis__c r)
{
risk = r;
selected = false;
}
}
//prevent crashing sparkler server
public string vUser(string uid) {
User u = [select name, Alias, CommunityNickname, FederationIdentifier, Domain_Credential__c from user
where Id = :uid];
string uName = u.Domain_Credential__c.toLowerCase();
if(uname == null || !u.Domain_Credential__c.contains('@') || uName.substringBefore('@').contains('.')
|| uName.escapeJava().contains('\\') || uname.contains('@firm2.com') || uname.contains('@firm1.com') ) { //TKT-0931762
ApexPages.Message myMsg =
new ApexPages.Message(ApexPages.Severity.Error,
'Domain Credential Error. Please log an SFDC Internal HelpDesk ticket with a screenshot. Thank you.');
ApexPages.addMessage(myMsg);
return 'Domain Credential Error. Please log an SFDC Internal HelpDesk ticket with a screenshot. Thank you.';
}
else
return 'Correct';
}
So I've tried a multitude of methods (insert, update, .put) but i cant seem to get the last if statement at the end to come out as true in one of my testclasses.
this if statement
if(uname == null || !u.Domain_Credential__c.contains('@') || uName.substringBefore('@').contains('.')
|| uName.escapeJava().contains('\\') || uname.contains('@firm2.com') || uname.contains('@firm1.com') ) { //TKT-0931762
ApexPages.Message myMsg =
new ApexPages.Message(ApexPages.Severity.Error,
'Domain Credential Error. Please log an SFDC Internal HelpDesk ticket with a screenshot. Thank you.');
ApexPages.addMessage(myMsg);
return 'Domain Credential Error. Please log an SFDC Internal HelpDesk ticket with a screenshot. Thank you.';
*do note i'm not showing all my code just relevent sections*
For whatever reason nothing i do seems to be able to trigger that if statement and get that error message to blast off.

- Enozzir
- July 24, 2018
- Like
- 0