Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @author
- * @since May 23, 2019
- * @history May 23, 2019 - Atos - Create Apex class
- *
- */
- @isTest
- public class FII_Soap_ContractInformation_Test {
- @testSetup
- private static void initializeVariables(){
- Test.setMock(HttpCalloutMock.class, new UtilHttpMock.BasicMock());
- Test.setMock(WebServiceMock.class, new UtilSoapMock.SICLI008Mock());
- // Creating account
- Account account = FII_Soap_Test_Abstract_Factory.createAccountComplete();
- // Inserting account
- insert account;
- // Creating address
- B2C_Address__c address = FII_Soap_Test_Abstract_Factory.createAddress(account.Id);
- // Inserting address
- insert address;
- // Creating comntract
- Contract contract = FII_Soap_Test_Abstract_Factory.createContract(account.Id, address.Id);
- contract.Contract_number__c = '12009291';
- // Inserting contract
- insert contract;
- }
- /**
- * checkPArameters checks the class with the correct parameters
- */
- @isTest
- static void checkPArameters () {
- Test.startTest();
- // Creating querys
- Account account = [
- SELECT Id
- FROM Account LIMIT 1
- ];
- Contract contract = [
- SELECT Id
- FROM Contract LIMIT 1
- ];
- // Creating request
- FII_Soap_ContractInformation.ContractInformation request = new FII_Soap_ContractInformation.ContractInformation();
- //Creating response
- FII_Soap_ContractInformation.MessageResponse response;
- request.customerId = account.Id;
- response = FII_Soap_ContractInformation.getContractInformation('007', request);
- Test.stopTest();
- // Creating asserts
- System.Assert(!response.contracts.contract.isEmpty());
- System.AssertEquals(contract.Id, response.contracts.contract.get(0).contractId);
- }
- /**
- * checkDifferentParameters checksthe class with a different contractNumber and Id
- */
- @isTest
- static void checkDifferentParameters () {
- Test.startTest();
- // Creating query
- Contract contract = [
- SELECT Id, ContractNumber
- FROM Contract LIMIT 1
- ];
- // Creating request
- FII_Soap_ContractInformation.ContractInformation request = new FII_Soap_ContractInformation.ContractInformation();
- request.contractNumber = '12009291';
- request.idNumber = '11111111H';
- request.idType = 'NIF';
- // Creating response
- FII_Soap_ContractInformation.MessageResponse response;
- response = FII_Soap_ContractInformation.getContractInformation('007', request);
- Test.stopTest();
- // Creating asserts
- System.Assert(!response.contracts.contract.isEmpty());
- System.AssertEquals(contract.Id, response.contracts.contract.get(0).contractId);
- }
- /**
- * checkPArametersWithContact checks the class using a number and a contractId
- */
- @isTest
- static void checkPArametersWithContact () {
- Test.startTest();
- // Creating querys
- Contract contract = [
- SELECT Id
- FROM Contract LIMIT 1
- ];
- B2C_Address__c address = [
- SELECT Id
- FROM B2C_Address__c LIMIT 1
- ];
- Test.stopTest();
- // Creating request
- FII_Soap_ContractInformation.ContractInformation request = new FII_Soap_ContractInformation.ContractInformation();
- request.address.addressId = address.Id;
- // Creating response
- FII_Soap_ContractInformation.MessageResponse response;
- response = FII_Soap_ContractInformation.getContractInformation('007', request);
- // Creating asserts
- System.Assert(!response.contracts.contract.isEmpty());
- System.AssertEquals(contract.Id, response.contracts.contract.get(0).contractId);
- }
- /**
- * checkPArametersWithoutAddress check the class without an addresId
- */
- @isTest
- static void checkPArametersWithoutAddress () {
- Test.startTest();
- // Creating querys
- Contract contract = [
- SELECT Id, CUPS__c
- FROM Contract LIMIT 1
- ];
- Test.stopTest();
- // Creating request
- FII_Soap_ContractInformation.ContractInformation request = new FII_Soap_ContractInformation.ContractInformation();
- request.cups = contract.CUPS__c;
- // Creating response
- FII_Soap_ContractInformation.MessageResponse response;
- response = FII_Soap_ContractInformation.getContractInformation('007', request);
- // Creating asserts
- System.Assert(!response.contracts.contract.isEmpty());
- System.AssertEquals(contract.Id, response.contracts.contract.get(0).contractId);
- }
- /**
- * mandatoryFieldsTest checks the null parameters of the response
- */
- @isTest
- static void mandatoryFieldsTest () {
- // Creating null request
- FII_Soap_ContractInformation.ContractInformation request = new FII_Soap_ContractInformation.ContractInformation();
- // Creating response
- FII_Soap_ContractInformation.MessageResponse response;
- response = FII_Soap_ContractInformation.getContractInformation('007', request);
- // Creating asserts
- System.Assert(!response.messages.message.isEmpty());
- System.AssertEquals(Label.ERR_103, response.messages.message.get(0).errorCode);
- }
- /**
- * noResultsTest cheks the class with a contractId only
- */
- @isTest
- static void noResultsTest () {
- Test.startTest();
- // Creating query
- Contract contract = [
- SELECT Id
- FROM Contract LIMIT 1
- ];
- Test.stopTest();
- // Creating request
- FII_Soap_ContractInformation.ContractInformation request = new FII_Soap_ContractInformation.ContractInformation();
- request.customerId = contract.Id;
- // Creating response
- FII_Soap_ContractInformation.MessageResponse response;
- response = FII_Soap_ContractInformation.getContractInformation('007', request);
- // Creating asserts
- System.Assert(response.contracts.contract.isEmpty());
- System.Assert(!response.messages.message.isEmpty());
- System.AssertEquals(Label.ERR_100,response.messages.message.get(0).errorCode);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement