Advertisement
Wolffel

ConsultContractByCC

May 23rd, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.51 KB | None | 0 0
  1. /**
  2. *
  3. * @author
  4. * @since    May 22, 2019
  5. * @history  May 22, 2019 - Atos - Create Apex class
  6. *
  7. */
  8. @isTest
  9. private class FII_Soap_ConsultContractByCC_Test {
  10.  
  11.     @testSetup
  12.     private static void testSetup() {
  13.  
  14.         Test.setMock(HttpCalloutMock.class, new UtilHttpMock.BasicMock());
  15.         Test.setMock(WebServiceMock.class, new UtilSoapMock.SICLI008Mock());
  16.         // Creating account
  17.         Account account = FII_Soap_Test_Abstract_Factory.createAccount();
  18.         // Inserting account
  19.         insert account;
  20.         // Creating account2
  21.         Account account2 = FII_Soap_Test_Abstract_Factory.createAccountComplete();
  22.         // Inserting account2
  23.         insert account2;
  24.         // Creatting address
  25.         B2C_Address__c address = FII_Soap_Test_Abstract_Factory.createAddress(account.Id);
  26.         // Inserting address
  27.         insert address;
  28.         // Creatting address2
  29.         B2C_Address__c address2 = FII_Soap_Test_Abstract_Factory.createAddress(account2.Id);
  30.         // Inserting address2
  31.         insert address2;
  32.         // Creating billingProfile
  33.         B2C_Billing_Profile__c billingProfile =
  34.             FII_Soap_Test_Abstract_Factory.createBillingProfile(account.Id);
  35.         // Inserting billingProfile
  36.         insert billingProfile;
  37.         // Creating billingProfile
  38.         B2C_Billing_Profile__c billingProfile2 =
  39.             FII_Soap_Test_Abstract_Factory.createBillingProfile(account2.Id);
  40.         // Inserting billingProfile
  41.         insert billingProfile2;
  42.         // Creating contract
  43.         Contract contract =
  44.             FII_Soap_Test_Abstract_Factory.createContract(account.Id, address.Id, billingProfile.Id);
  45.         // Inserting contract
  46.         insert contract;
  47.     }
  48.    
  49.     /**
  50.      * checkBillingDataEmpty checks if the BillingData is related with the account
  51.      */
  52.     @isTest
  53.     static void checkBillingDataEmpty(){
  54.  
  55.         // Creating the request
  56.         FII_Soap_ConsultContractByCC.SearchContract request =
  57.             new FII_Soap_ConsultContractByCC.SearchContract();
  58.         // Value assigment
  59.         request.clientId = '0011X000005rkZ6Q00';
  60.         request.billingProfileId = '12345ID';
  61.         // Creating response
  62.         FII_Soap_ConsultContractByCC.MessageResponse response =
  63.         FII_Soap_ConsultContractByCC.getContractInformation(request);
  64.         // Creating Asserts
  65.         System.assertEquals(1,response.messages.message.size());
  66.         System.assertEquals(Label.ERR_004,response.messages.message.get(0).errorCode);
  67.     }
  68.  
  69.     /**
  70.      * consultContractMissingValues checks the missing values
  71.      */
  72.     @isTest
  73.     static void consultContractMissingValues(){
  74.        
  75.         // Creating request
  76.         FII_Soap_ConsultContractByCC.SearchContract request =
  77.             new FII_Soap_ConsultContractByCC.SearchContract();
  78.         // Creating response
  79.         FII_Soap_ConsultContractByCC.MessageResponse response =
  80.             FII_Soap_ConsultContractByCC.getContractInformation(request);
  81.         // Creating asserts
  82.         System.assertEquals(1,response.messages.message.size());
  83.         System.assertEquals(Label.ERR_002,response.messages.message.get(0).errorCode);
  84.     }
  85.  
  86.     /**
  87.      * checkNotRelatedContracts checks if an account has not a related contract
  88.      */
  89.     @isTest
  90.     static void checkNotRelatedContracts(){
  91.  
  92.         // Searching accounts
  93.         Account account2 = [
  94.             SELECT id
  95.             FROM account
  96.             WHERE NIF_CIF_Customer_NIE__c = '11111111H'
  97.  
  98.         ];
  99.         // Searcching billingProfiles
  100.         B2C_Billing_Profile__c billingProfile2 = [
  101.             SELECT id
  102.             FROM B2C_Billing_Profile__c WHERE Account_Payment_Holder__c =:account2.Id
  103.         ];
  104.  
  105.         // Creating  request
  106.         FII_Soap_ConsultContractByCC.SearchContract request =
  107.             new FII_Soap_ConsultContractByCC.SearchContract();
  108.         request.clientId = account2.Id;
  109.         request.billingProfileId = billingProfile2.Id;
  110.  
  111.         // Creating response
  112.         FII_Soap_ConsultContractByCC.MessageResponse response =
  113.         FII_Soap_ConsultContractByCC.getContractInformation(request);
  114.         // Creating Asserts
  115.         System.assertEquals(1,response.messages.message.size());
  116.         System.assertEquals('06',response.messages.message.get(0).errorCode);
  117.     }
  118.  
  119.      /**
  120.      * consultContractIsOkTest checks if the account has a related contract
  121.      */
  122.     @isTest
  123.     static void consultContractIsOkTest(){
  124.  
  125.         // Searching accounts
  126.         Account account = [
  127.             SELECT id
  128.             FROM account
  129.             WHERE NIF_CIF_Customer_NIE__c = '12312312K'
  130.         ];
  131.         // Searcching billingProfiles
  132.         B2C_Billing_Profile__c billingProfile = [
  133.            
  134.             SELECT id
  135.             FROM B2C_Billing_Profile__c WHERE Account_Payment_Holder__c =:account.Id
  136.         ];
  137.  
  138.         // Creating  request
  139.         FII_Soap_ConsultContractByCC.SearchContract request =
  140.             new FII_Soap_ConsultContractByCC.SearchContract();
  141.         request.clientId = account.Id;
  142.         request.billingProfileId = billingProfile.Id;
  143.         // Creating response
  144.         FII_Soap_ConsultContractByCC.MessageResponse response =
  145.             FII_Soap_ConsultContractByCC.getContractInformation(request);
  146.         // Creating asserts
  147.         System.assertEquals(0,response.messages.message.size());
  148.         System.assertEquals(account.id,request.clientId);
  149.         System.assertEquals(billingProfile.id,request.billingProfileId);
  150.     }
  151.  
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement