You need to sign in to do that
Don't have an account?
Jacobus
File name mismatch with class name
Hi,
When I deploy my 2 web service mock classes to production, it fails with "File name mismatch with class name"?
Here are my 2 mock test classes :
@isTest(SeeAllData=true)
global class WebServiceMockImpl implements WebServiceMock {
global void doInvoke(
Object stub,
Object request,
Map<String, Object> response,
String endpoint,
String soapAction,
String requestName,
String responseNS,
String responseName,
String responseType) {
FAMExternalWebservice.SumbitReleaseFromThirdPartyResponse_element respElement = new FAMExternalWebservice.SumbitReleaseFromThirdPartyResponse_element();
respElement.SumbitReleaseFromThirdPartyResult = 'Mock response';
response.put('response_x', respElement);
}
}
@isTest
private class UpliftmentRequestWSDLTest {
@isTest static void testWSDL() {
// This causes a fake response to be generated
Test.setMock(WebServiceMock.class, new WebServiceMockImpl ());
FAMExternalWebservice.ThirdPartyReleaseEntry tpr = new FAMExternalWebservice.ThirdPartyReleaseEntry();
FAMExternalWebservice.SumbitReleaseFromThirdParty stub = new FAMExternalWebservice.SumbitReleaseFromThirdParty();
tpr.DateOfRequest = 'system.now()';
tpr.Insurer = 1;
tpr.ClaimNumber = 'claimno';
tpr.DateOfLoss = 'system.now()';
tpr.VehicleCondition = 1;
tpr.CustomerSurname = 'customerlastname';
tpr.CustomerName = 'customerfirstname';
tpr.VehicleCommercialPassenger = 'vehiclecommercialpassenger';
tpr.VehicleMake = 'vehiclemake';
tpr.VehicleModel = 'vehiclemodel';
tpr.VehicleMMCode = 'vehicleMMCode';
tpr.VehicleYear = 'vehicleyear';
tpr.VehicleRegistrationNumber = 'vehicleregistrationno';
tpr.LocationName = 'locationname';
tpr.LocationContactPerson = 'locationcontactperson';
tpr.LocationContactNumber = 'locationcontactno';
tpr.LocationEmailAddress = 'locationemailaddress';
tpr.LocationStreetAddress = 'locationstreetaddress';
tpr.LocationSuburb = 'locationsuburb';
tpr.LocationPostalCode = 'locationpostalcode';
tpr.LocationCity = 'locationcity';
tpr.LocationProvince = 'locationprovince';
tpr.SalesForceCapturer = 'salesforcecapturer';
tpr.SalesForceReferenceNumber = 'salesforcerefno';
// Call the method that invokes a callout
Test.startTest() ;
String output = stub.SumbitReleaseFromThirdParty(tpr);
Test.stopTest();
// Verify that a fake result is returned
System.assertEquals('Mock response', output);
}
}
When I deploy my 2 web service mock classes to production, it fails with "File name mismatch with class name"?
Here are my 2 mock test classes :
@isTest(SeeAllData=true)
global class WebServiceMockImpl implements WebServiceMock {
global void doInvoke(
Object stub,
Object request,
Map<String, Object> response,
String endpoint,
String soapAction,
String requestName,
String responseNS,
String responseName,
String responseType) {
FAMExternalWebservice.SumbitReleaseFromThirdPartyResponse_element respElement = new FAMExternalWebservice.SumbitReleaseFromThirdPartyResponse_element();
respElement.SumbitReleaseFromThirdPartyResult = 'Mock response';
response.put('response_x', respElement);
}
}
@isTest
private class UpliftmentRequestWSDLTest {
@isTest static void testWSDL() {
// This causes a fake response to be generated
Test.setMock(WebServiceMock.class, new WebServiceMockImpl ());
FAMExternalWebservice.ThirdPartyReleaseEntry tpr = new FAMExternalWebservice.ThirdPartyReleaseEntry();
FAMExternalWebservice.SumbitReleaseFromThirdParty stub = new FAMExternalWebservice.SumbitReleaseFromThirdParty();
tpr.DateOfRequest = 'system.now()';
tpr.Insurer = 1;
tpr.ClaimNumber = 'claimno';
tpr.DateOfLoss = 'system.now()';
tpr.VehicleCondition = 1;
tpr.CustomerSurname = 'customerlastname';
tpr.CustomerName = 'customerfirstname';
tpr.VehicleCommercialPassenger = 'vehiclecommercialpassenger';
tpr.VehicleMake = 'vehiclemake';
tpr.VehicleModel = 'vehiclemodel';
tpr.VehicleMMCode = 'vehicleMMCode';
tpr.VehicleYear = 'vehicleyear';
tpr.VehicleRegistrationNumber = 'vehicleregistrationno';
tpr.LocationName = 'locationname';
tpr.LocationContactPerson = 'locationcontactperson';
tpr.LocationContactNumber = 'locationcontactno';
tpr.LocationEmailAddress = 'locationemailaddress';
tpr.LocationStreetAddress = 'locationstreetaddress';
tpr.LocationSuburb = 'locationsuburb';
tpr.LocationPostalCode = 'locationpostalcode';
tpr.LocationCity = 'locationcity';
tpr.LocationProvince = 'locationprovince';
tpr.SalesForceCapturer = 'salesforcecapturer';
tpr.SalesForceReferenceNumber = 'salesforcerefno';
// Call the method that invokes a callout
Test.startTest() ;
String output = stub.SumbitReleaseFromThirdParty(tpr);
Test.stopTest();
// Verify that a fake result is returned
System.assertEquals('Mock response', output);
}
}
Thank you for your reply.
I am deploying via the force.com eclipse platform.
Tried deploying them one by one as well as both mock and wsdl2apex classes.
When testing the WebServiceMockImpl.cls and UpliftmentRequestWSDLTest.cls in the developer console, both of them PASS successfully.
My only issue is when I try and deploy to production using force.com eclipse platform, do I get the "File name mismatch with class name" failure.
And yes, both of them have -meta.xml files.
Appreciate your assistance.
Hi,
It's because your file name i.e., classname.cls does not match with your classname in the code/metadata.
If class name is 'MyClass' & the filename is 'myClass' then there's a discrepency. This may occur if someone updates the classname at a later stage.
We have faced the same issue during deployment & updating the class name in the code similar to the .cls filename solved the issue.
Hope this helps.
Thanks,
Vivek H