
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.');
}
}
}

@isTest global class MockHttpResponseGenerator implements HttpCalloutMock {
// Implement this interface method
global HTTPResponse respond(HTTPRequest req) {
String responseString = '[{"annual_drug_deductible":20000,"month_rate":0,"contract_year":"2017","plan_type":"Local HMO","county":"DOUGLAS","additional_coverage_offered_in_the_gap":null,"plan_id":"1","contract_id":"H2802","special_needs_plan_type":null,"has_pdf_app":false,"excluded_zip5":[],"benefit_type_detail":null,"organization_name":"UnitedHealthcare","state":"NE","version":15,"effective_date":"2017-01-01T00:00:00","conditions":[],"zero_premium_with_full_low_income_subsidy":null,"status":1,"additional_coverage_type":"EA","e_app_link":"","last_modified":"2016-11-03T14:12:36.259450","key":"aghzfmNzZ2FwaXIjCxIWTWVkaWNhcmVBZHZhbnRhZ2VRdW90ZRiAgIDA9432CAyiARJtZWRpY2FyZV9hZHZhbnRhZ2U","in_network_moop":"$5,900","in_network_moop_sort":590000,"drug_benefit_type_detail":"Enhanced","benefits":[{"full_description":"<p>Does the plan provide Acupuncture as a supplemental benefit under Part C? No</p>","pd_view_display":false,"benefit_type":"Acupuncture"},{"full_description":"<p>$250.00 copay</p>","pd_view_display":true,"benefit_type":"Ambulance"}}]';
// and method.
System.assertEquals('https://csgapi.appspot.com/v1/med_supp/quotes.json?age=0&zip5=null&gender=null&tobacco=null&effective_date=2017-3-1', req.getEndpoint());
System.assertEquals('GET', req.getMethod());
// Create a fake response
HttpResponse res = new HttpResponse();
res.setHeader('Content-Type', 'application/json');
res.setBody(responseString);
res.setStatusCode(200);
return res;
}
}