You need to sign in to do that
Don't have an account?

i am stuck at code coverge how to increase it please help
This code is not covered by my test class how do i invoke this ?
if (hasProfilePic) {
if ( profilePicture.BodyLength > 0 ) {
if (profilePicture.Name.toLowerCase().endsWith('.png') || profilePicture.Name.toLowerCase().endsWith('.bmp') || profilePicture.Name.toLowerCase().endsWith('.jpg') || profilePicture.Name.toLowerCase().endsWith('.jpeg')) {
if (profilePicture.BodyLength <= 307200) {
if ( Pattern.matches('(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/((19|20)\\d\\d)', fieldDOB)) {
Account v_newAccount = new Account(Id = currentAccount.Id,
Suffix__c = fieldsuffix,
BillingCountry = fieldcountry,
Snowboarding_ab_level__c = fieldsnowboarding,
Mountain_Biking_ab_level__c = fieldmountainbiking ,
PersonEmail = fieldPersonEmail,
FirstName = fieldfirstname,
LastName = fieldlastname,
Salutation = fieldtitle,
EmergencyName__c = fieldEmergencyName,
EmergencyNumber__c = fieldEmergencyNumber,
AbLevel__c = fieldAbLevel,
ClientCitizen__c =fieldClientCitizen,
ClientEmail__c = fieldClientEmail,
DOB__c = Date.parse(fieldDOB),
Phone = fieldPhone,
BillingStreet = fieldStreet,
BillingCity = fieldCity,
BillingState = fieldState,
BillingPostalCode = fieldPostalCode,
Special_Requests__c = fieldRequests,
Special_Dietary_Concerns__c = fieldDietary,
Special_Medical_Concerns__c = fieldMedical,
Snowcat_Downhill__c = v_Snowcat_Downhill,
Gender__c = fieldGender,
Favorite_Drink__c = this.fieldFavoriteDrink,
Favorite_Retallack_Experience__c = this.fieldFavoriteRetallackExperience,
Preferred_Guide_Driver__c = fieldPreferedGuideDriver);
update v_newAccount;
editData = false;
//Current Account
currentAccount = [
SELECT Salutation,Mountain_Biking_ab_level__c,Snowboarding_ab_level__c,FirstName,LastName,EmergencyName__c,EmergencyNumber__c,AbLevel__c,ClientCitizen__c,ClientEmail__c,DOB__c, PersonEmail, Phone, IsPersonAccount,
BillingStreet, BillingCity, Gender__c, Preferred_Guide_Driver__c,
BillingState, BillingPostalCode,
Special_Requests__c, Special_Dietary_Concerns__c,
Special_Medical_Concerns__c, Snowcat_Downhill__c,
Favorite_Drink__c, Favorite_Retallack_Experience__c
FROM Account
WHERE Id = :currentOpp.AccountId];
firstPaymentCheckbox = false;
secondPaymentCheckbox = false;
if (profilePicture.BodyLength > 0) {
// delete existing avatars
delete [SELECT Id FROM Attachment WHERE Name LIKE 'ProfilePic_%' AND ParentId = :currentAccount.Id];
// insert new avatar
profilePicture.Name = 'ProfilePic_'+profilePicture.Name;
insert profilePicture;
hasProfilePic = TRUE;
curProfilePictureId = profilePicture.Id;
}
} else {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, ' Incorrect date. '));
}
} else {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, ' File size can not exceed 300kb. '));
}
} else {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, ' Only .jpeg, .jpg, .png, .bmp extensions supported. '));
}
if (hasProfilePic) {
if ( profilePicture.BodyLength > 0 ) {
if (profilePicture.Name.toLowerCase().endsWith('.png') || profilePicture.Name.toLowerCase().endsWith('.bmp') || profilePicture.Name.toLowerCase().endsWith('.jpg') || profilePicture.Name.toLowerCase().endsWith('.jpeg')) {
if (profilePicture.BodyLength <= 307200) {
if ( Pattern.matches('(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/((19|20)\\d\\d)', fieldDOB)) {
Account v_newAccount = new Account(Id = currentAccount.Id,
Suffix__c = fieldsuffix,
BillingCountry = fieldcountry,
Snowboarding_ab_level__c = fieldsnowboarding,
Mountain_Biking_ab_level__c = fieldmountainbiking ,
PersonEmail = fieldPersonEmail,
FirstName = fieldfirstname,
LastName = fieldlastname,
Salutation = fieldtitle,
EmergencyName__c = fieldEmergencyName,
EmergencyNumber__c = fieldEmergencyNumber,
AbLevel__c = fieldAbLevel,
ClientCitizen__c =fieldClientCitizen,
ClientEmail__c = fieldClientEmail,
DOB__c = Date.parse(fieldDOB),
Phone = fieldPhone,
BillingStreet = fieldStreet,
BillingCity = fieldCity,
BillingState = fieldState,
BillingPostalCode = fieldPostalCode,
Special_Requests__c = fieldRequests,
Special_Dietary_Concerns__c = fieldDietary,
Special_Medical_Concerns__c = fieldMedical,
Snowcat_Downhill__c = v_Snowcat_Downhill,
Gender__c = fieldGender,
Favorite_Drink__c = this.fieldFavoriteDrink,
Favorite_Retallack_Experience__c = this.fieldFavoriteRetallackExperience,
Preferred_Guide_Driver__c = fieldPreferedGuideDriver);
update v_newAccount;
editData = false;
//Current Account
currentAccount = [
SELECT Salutation,Mountain_Biking_ab_level__c,Snowboarding_ab_level__c,FirstName,LastName,EmergencyName__c,EmergencyNumber__c,AbLevel__c,ClientCitizen__c,ClientEmail__c,DOB__c, PersonEmail, Phone, IsPersonAccount,
BillingStreet, BillingCity, Gender__c, Preferred_Guide_Driver__c,
BillingState, BillingPostalCode,
Special_Requests__c, Special_Dietary_Concerns__c,
Special_Medical_Concerns__c, Snowcat_Downhill__c,
Favorite_Drink__c, Favorite_Retallack_Experience__c
FROM Account
WHERE Id = :currentOpp.AccountId];
firstPaymentCheckbox = false;
secondPaymentCheckbox = false;
if (profilePicture.BodyLength > 0) {
// delete existing avatars
delete [SELECT Id FROM Attachment WHERE Name LIKE 'ProfilePic_%' AND ParentId = :currentAccount.Id];
// insert new avatar
profilePicture.Name = 'ProfilePic_'+profilePicture.Name;
insert profilePicture;
hasProfilePic = TRUE;
curProfilePictureId = profilePicture.Id;
}
} else {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, ' Incorrect date. '));
}
} else {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, ' File size can not exceed 300kb. '));
}
} else {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, ' Only .jpeg, .jpg, .png, .bmp extensions supported. '));
}
Please paste your complete class as well as your Unit Test. Also, use the "< >" button in the editor here to format it so it's halfway readable.