You need to sign in to do that
Don't have an account?
Stephanie Gethers
testing Apex
Hello when i am try to upload apex class and visualforce its say my that i need least 75% coverage..
if i try to upload this like Packages this is over the upload but when i am try to upload to Outbound Change Sets, i get only 45 % how its can be?
what can do i to upload the %....?
apex class:
public class appspotApiMedSuppController { public string fieldName {get;set;} public JSONParser parser {get;set;} public string full_name {get;set;} public string plan {get;set;} public Integer quarter{get;set;} public Integer annual{get;set;} public Integer semi_annual{get;set;} public Integer month{get;set;} public rateClass rate{get;set;} public class rateClass { public Integer quarter{get;set;} public Integer annual{get;set;} public Integer semi_annual{get;set;} public Integer month{get;set;} } public String type{get;set;} public String name{get;set;} public Double value{get;set;} public discountsClass discounts{get;set;} public class discountsClass { public String type{get;set;} public String name{get;set;} public Double value{get;set;} } public class MedSupp { public String full_name{get;set;} public String plan{get;set;} public String expires_date{get;set;} public rateClass rate{get;set;} public discountsClass discounts{get;set;} } public MedSupp med_supp{get;set;} public List<MedSupp> dataList {get;set;} public String zip {get;set;} public String gender {get;set;} public String tobacco {get;set;} public String expires_date{get;set;} public String Dateeffective {get;set;} public String requestEndPoint {get;set;} public Date birth {get;set;} public Integer age {get;set;} public static HttpResponse getInfoFromExternalService() { HttpRequest req = new HttpRequest(); req.setHeader('x-api-token', '3e63919db53fbaebe6f3c0ea316645ce3aa24c64402be35a157653e9fe12ad77'); req.setEndpoint('link'); req.setTimeout(15000); req.setMethod('GET'); Http h = new Http(); HttpResponse res = h.send(req); return res; } public appspotApiMedSuppController (){ Date effectiveDate = Date.today(); birth = (System.currentPageReference().getParameters().get('birth')!=null)? date.parse(System.currentPageReference().getParameters().get('birth')) : Date.today(); if( Date.newInstance(2000, birth.month(), birth.day()) <= Date.newInstance(2000, effectiveDate.month(), effectiveDate.day())) { age = effectiveDate.year() - birth.year(); } else { age = effectiveDate.year() - birth.year() -1; } if(effectiveDate.month()!=12) effectiveDate = Date.newInstance(effectiveDate.year(), effectiveDate.month()+1, 1); else effectiveDate = Date.newInstance(effectiveDate.year()+1,1, 1); Dateeffective = effectiveDate.year()+'-'+effectiveDate.month()+'-'+effectiveDate.day(); zip = null; gender=null; tobacco =null; zip = System.currentPageReference().getParameters().get('zip'); gender = System.currentPageReference().getParameters().get('gender'); tobacco = System.currentPageReference().getParameters().get('tobacco'); requestEndPoint='link'; Http http =new Http(); HttpRequest request = new HttpRequest(); request.setHeader('x-api-token', '6a3e8d00b0183e4d9fd9a2dbd058ec26aecd412920034145254d780b0d6c2fe6'); request.setEndpoint(requestEndPoint); request.setTimeout(15000); request.setMethod('GET'); HttpResponse response = http.send(request); if(response.getStatusCode() ==200){ dataList = new List<MedSupp>(); parser = JSON.createParser(response.getBody()); while (parser.nextToken() != null) { if (parser.getCurrentToken() == JSONToken.START_ARRAY) { while (parser.nextToken() != null) { med_supp = new MedSupp();rate = new rateClass();discounts = new discountsClass();fieldName = parser.getText(); if (fieldName == 'company_base'){ parser.nextToken(); if (parser.getCurrentToken() == JSONToken.START_OBJECT) { while (parser.nextToken() != null) { fieldName = parser.getText(); if(fieldName == 'parent_company_base') { parser.nextToken();parser.nextToken();parser.nextToken();parser.nextToken();parser.nextToken();parser.nextToken();parser.nextToken(); full_name = parser.getText(); break; } } } } if (fieldName == 'rate'){ parser.nextToken();rate =(rateClass)parser.readValueAs(rateClass.class);} if (fieldName == 'plan'){parser.nextToken();plan = parser.getText(); } if (fieldName == 'discounts'){parser.nextToken();parser.nextToken();discounts=(discountsClass)parser.readValueAs(discountsClass.class);} if (fieldName == 'location_base'){parser.nextToken();parser.nextToken();parser.nextToken();expires_date = parser.getText();expires_date = expires_date.substring(0,expires_date.indexOf('T'));} if (fieldName == 'age'){ if((plan=='F') || (plan=='N')|| (plan=='G')) { med_supp.full_name = full_name; med_supp.plan = plan; med_supp.expires_date=expires_date; med_supp.rate = rate; med_supp.discounts = discounts; dataList.add(med_supp); } } } } } } else{ ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,' There was an error retrieving the data information.'); } } }
Stephanie Gethers