@isTest
private class Ag_AddendumTriggerHandlerTracker{
static private Account objAccount;
static private Account objBrokerAccount;
static private Account objSupplierBroker;
static private Account objOtherAccount;
static private Account objBuyerAccount;
static private Ag_Commodity_Master__c objCommodity;
static private Ag_Templates__c objTemplate;
static private Ag_Related_Commodities__c objRelatedCommodity;
static private Ag_Purchase_Contract__c objPurchaseContract;
static private Recordtype objRT;
static private Ag_Shipping__c objShipping;
static private Ag_Templates__c objShippingTemplate;
static private Ag_Related_Sales_Contract__c objRSC;
static private Ag_Sales_Contract__c objSalesCon;
static private Ag_Addendum__c objAddendum;
static testMethod void ValidateAddendum() {
LoadData();
List<Ag_Addendum__c> lstAddendum = new List<Ag_Addendum__c>();
lstAddendum.add(objAddendum);
Ag_AddendumTriggerHandler obj2= new Ag_AddendumTriggerHandler ();
obj2.UpdateWhenAddendumApproved(lstAddendum);
obj2.test(lstAddendum);
}
static testMethod void ValidateAddendum2() {
LoadData();
CreateAddendum1();
List<Ag_Addendum__c> lstAddendum = new List<Ag_Addendum__c>();
lstAddendum.add(objAddendum);
Ag_AddendumTriggerHandler obj2= new Ag_AddendumTriggerHandler ();
obj2.UpdateWhenAddendumApproved(lstAddendum);
obj2.test(lstAddendum);
}
static testMethod void ValidateAddendum3() {
LoadData();
CreateAddendum2();
List<Ag_Addendum__c> lstAddendum = new List<Ag_Addendum__c>();
lstAddendum.add(objAddendum);
Ag_AddendumTriggerHandler obj2= new Ag_AddendumTriggerHandler ();
obj2.UpdateWhenAddendumApproved(lstAddendum);
obj2.test(lstAddendum);
}
static testMethod void ValidateAddendum4() {
LoadData();
CreateAddendum4();
List<Ag_Addendum__c> lstAddendum = new List<Ag_Addendum__c>();
lstAddendum.add(objAddendum);
Ag_AddendumTriggerHandler obj2= new Ag_AddendumTriggerHandler ();
obj2.UpdateWhenAddendumApproved(lstAddendum);
obj2.test(lstAddendum);
}
static testMethod void ValidateAddendum5() {
LoadData();
CreateAddendum5();
List<Ag_Addendum__c> lstAddendum = new List<Ag_Addendum__c>();
lstAddendum.add(objAddendum);
Ag_AddendumTriggerHandler obj2= new Ag_AddendumTriggerHandler ();
obj2.UpdateWhenAddendumApproved(lstAddendum);
//S lstAddendum[0].Ag_Purchase_Contract__c = null;
//S update lstAddendum;
obj2.test(lstAddendum);
}
private static void LoadData()
{
CreateAccount();
CreateOtherAccount();
CreateBrokerAccount();
CreateBuyerAccount();
CreateSuppBrokerAccount();
CreateTemplate();
CreateShippingTemplate();
CreateCommodity();
CreatePurchaseContract();
CreateRelatedCommodity();
CreateShipping();
CreateSalesContract();
CreateRelatedSalesContract();
CreateAddendum();
CreateAddendum3();
CreateAddendum4();
CreateAddendum5();
}
static void CreateAccount()
{
objRT=[select id, name, SObjectType
From RecordType
Where SObjectType= 'Account'
AND name= 'Supplier Account'];
objAccount = new Account(Name = 'TestAccount',Phone='01533673',recordTypeId=objRT.id,Ag_Email__c = 'test@gmail.com',BillingCountry = 'TestCountry',Ag_Is_Approved__c=true);
insert objAccount;
Account objTempAccount = [select Name from Account where Id = :objAccount.Id];
System.assertEquals(objAccount.Name, objTempAccount.Name);
}
static void CreateOtherAccount()
{
objRT=[select id, name, SObjectType
From RecordType
Where SObjectType= 'Account'
AND name= 'Other Accounts'];
objOtherAccount = new Account(Name = 'TestAccount23',Phone='01533673',recordTypeId=objRT.id,Ag_Email__c = 'test45@gmail.com',BillingCountry = 'TestCountry1',Ag_Is_Approved__c=true);
insert objOtherAccount;
Account objOtherTempAccount = [select Name from Account where Id = :objOtherAccount.Id];
System.assertEquals(objOtherAccount.Name, objOtherTempAccount.Name);
}
static void CreateBrokerAccount()
{
objRT=[select id, name, SObjectType
From RecordType
Where SObjectType= 'Account'
AND name= 'Buyer Broker'];
objBrokerAccount = new Account(Name = 'TestAccount',Phone='01533673',recordTypeId=objRT.id,Ag_Email__c = 'test12@gmail.com',BillingCountry = 'TestCountry',Ag_Is_Approved__c=true);
insert objBrokerAccount;
Account objTempBrokerAccount = [select Name from Account where Id = :objBrokerAccount.Id];
System.assertEquals(objBrokerAccount.Name, objTempBrokerAccount.Name);
}
static void CreateSuppBrokerAccount()
{
objRT=[select id, name, SObjectType
From RecordType
Where SObjectType= 'Account'
AND name= 'Supplier Broker'];
objSupplierBroker = new Account(Name = 'TestSuppAccount',Phone='01533673',recordTypeId=objRT.id,Ag_Email__c = 'test12@gmail.com',BillingCountry = 'TestCountry',Ag_Is_Approved__c=true);
insert objSupplierBroker;
Account objTempSuppBrokerAccount = [select Name from Account where Id = :objSupplierBroker.Id];
System.assertEquals(objSupplierBroker.Name, objTempSuppBrokerAccount.Name);
}
static void CreateBuyerAccount()
{
objRT=[select id, name, SObjectType
From RecordType
Where SObjectType= 'Account'
AND name= 'Buyer Account'];
objBuyerAccount = new Account(Name = 'TestBuyerAccount',Phone='01533673',recordTypeId=objRT.id,Ag_Email__c = 'test12@gmail.com',BillingCountry = 'TestCountry',Ag_Is_Approved__c=true);
insert objBuyerAccount;
Account objTempBuyerAccount = [select Name from Account where Id = :objBuyerAccount.Id];
System.assertEquals(objBuyerAccount.Name, objTempBuyerAccount.Name);
}
static void CreateTemplate()
{
objRT=[select id, name, SObjectType
From RecordType
Where SObjectType= 'Ag_Templates__c'
AND name= 'Purchase Contract'];
objTemplate = new Ag_Templates__c(recordTypeId=objRT.id,Name='TestTemplate',Ag_Other_Terms_and_Conditions__c='Testing Term');
insert objTemplate;
Ag_Templates__c objTempTemplate = [select id,Name from Ag_Templates__c where id = :objTemplate.id];
System.assertEquals(objTemplate.Name, objTempTemplate.Name);
}
static void CreateShippingTemplate()
{
objRT=[select id, name, SObjectType
From RecordType
Where SObjectType= 'Ag_Templates__c'
AND name= 'Shipping Instruction'];
objShippingTemplate = new Ag_Templates__c(recordTypeId=objRT.id,Name='TestTemplate',Ag_Other_Terms_and_Conditions__c='Testing Term',Ag_Template_Type__c='Sales');
//insert objTemplate;
//Ag_Templates__c objShipTempTemplate = [select id,Name from Ag_Templates__c where id = :objShippingTemplate.id];
//System.assertEquals(objShippingTemplate.Name, objShipTempTemplate.Name);
}
static void CreateCommodity()
{
objCommodity = new Ag_Commodity_Master__c(Name = 'TestCommodity',AG_Active__c=true,AG_Commodity_Code__c='Code 2',AG_UOM__c='MT',AG_Commodity_Family__c='COAL');
objCommodity.CurrencyIsoCode='INR';
insert objCommodity;
Ag_Commodity_Master__c objtempComm = [select id,Name from Ag_Commodity_Master__c where id = : objCommodity.id];
System.assertEquals(objCommodity.Name, objtempComm.Name);
}
static void CreateRelatedCommodity()
{
objRelatedCommodity = new Ag_Related_Commodities__c(Ag_Commodity_Master__c = objCommodity.id,Ag_Purchase_Contract__c=objPurchaseContract.id
,Ag_Price__c=65.23,Ag_Commodity_Family__c='COAL',Ag_Finalized_Price__c=true,Ag_Port_Of_Discharge__c ='testDis');
objRelatedCommodity.CurrencyIsoCode='INR';
insert objRelatedCommodity;
Ag_Related_Commodities__c objtempRelComm = [select id,Name,Ag_Commodity_Master__c from Ag_Related_Commodities__c where id = :objRelatedCommodity.id];
System.assertEquals(objRelatedCommodity.Ag_Commodity_Master__c, objtempRelComm.Ag_Commodity_Master__c);
}
static void CreateShipping()
{
objShipping = new Ag_Shipping__c(Ag_Insurance_Company__c=objOtherAccount.id,Ag_Purchase_Contract__c=objPurchaseContract.id,
Ag_Shipment_start_date__c = system.today(),Ag_Shipment_end_date__c=system.today(),
Ag_Port_of_Discharge__c = 'test12',Ag_Port_of_Loading__c='34');
objShipping.CurrencyIsoCode = 'INR';
insert objShipping;
}
static void CreateSalesContract()
{
objSalesCon = new Ag_Sales_Contract__c(Ag_Broker__c=objBrokerAccount.id,Ag_Account__c=objBuyerAccount.id,Ag_Commodity_family__c='COAL',Ag_Quantity__c=2,Ag_UOM__c='MT',Ag_Templates__c=objShippingTemplate.id,CurrencyIsoCode='INR');
insert objSalesCon;
}
static void CreateRelatedSalesContract()
{
objRSC = new Ag_Related_Sales_Contract__c(Ag_Sales_Contract__c = objSalesCon.id,Ag_Net_Weight__c=5,Ag_Shipping__c=objShipping.id);
objRSC.CurrencyIsoCode='INR';
insert objRSC;
}
static void CreatePurchaseContract()
{
objPurchaseContract = new Ag_Purchase_Contract__c();
objPurchaseContract.Ag_Broker__c=objSupplierBroker.id;
objPurchaseContract.Ag_Contract_Date__c= system.today();
objPurchaseContract.Ag_Commodity_Name__c = objCommodity.id;
objPurchaseContract.Ag_Commodity_family__c = 'COAL';
objPurchaseContract.Ag_Quantity__c = 2;
objPurchaseContract.Ag_UOM__c = 'MT';
objPurchaseContract.CurrencyIsoCode = 'INR';
objPurchaseContract.Ag_Shipment_Type__c='CIF';
insert objPurchaseContract;
//A Ag_Purchase_Contract__c objTempPurchaseContract = [select id,Name,Ag_Broker__c from Ag_Purchase_Contract__c where id = : objPurchaseContract.id];
//A System.assertEquals(objPurchaseContract.Ag_Broker__c, objTempPurchaseContract.Ag_Broker__c);
}
static void CreateAddendum()
{
objAddendum = new Ag_Addendum__c();
objRT = [Select id,Name,SObjectType from RecordType where SObjectType = 'Ag_Addendum__c' and
Name = 'Purchase Contract Addendum'];
objAddendum.RecordTypeId = objRT.Id;
objAddendum.Ag_Approval_Stages__c = 'Addendum pending for approval';
objAddendum.Ag_Purchase_Contract__c= objPurchaseContract.Id;
objAddendum.CurrencyIsoCode = 'INR';
insert objAddendum;
}
static void CreateAddendum1()
{
objAddendum = new Ag_Addendum__c();
objRT = [Select id,Name,SObjectType from RecordType where SObjectType = 'Ag_Addendum__c' and
Name = 'Purchase Contract Addendum'];
objAddendum.RecordTypeId = objRT.Id;
objAddendum.Ag_Approval_Stages__c = 'Addendum Approved';
objAddendum.Ag_Purchase_Contract__c= objPurchaseContract.Id;
objAddendum.CurrencyIsoCode = 'INR';
insert objAddendum;
}
static void CreateAddendum2()
{
objAddendum = new Ag_Addendum__c();
objRT = [Select id,Name,SObjectType from RecordType where SObjectType = 'Ag_Addendum__c' and
Name = 'Purchase Contract Addendum'];
objAddendum.RecordTypeId = objRT.Id;
objAddendum.Ag_Approval_Stages__c = 'Addendum Rejected';
objAddendum.CurrencyIsoCode = 'INR';
objAddendum.Ag_Purchase_Contract__c= objPurchaseContract.Id;
insert objAddendum;
}
static void CreateAddendum3()
{
objAddendum = new Ag_Addendum__c();
objAddendum.Ag_Approval_Stages__c = 'Addendum pending for approval';
objAddendum.CurrencyIsoCode = 'INR';
objAddendum.Ag_Sales_Contract__c= objSalesCon.Id;
insert objAddendum;
}
static void CreateAddendum4()
{
objAddendum = new Ag_Addendum__c();
objAddendum.Ag_Approval_Stages__c = 'Addendum Approved';
objAddendum.CurrencyIsoCode = 'INR';
objAddendum.Ag_Sales_Contract__c= objSalesCon.Id;
insert objAddendum;
}
static void CreateAddendum5()
{
objAddendum = new Ag_Addendum__c();
objAddendum.Ag_Approval_Stages__c = 'Addendum Rejected';
objAddendum.CurrencyIsoCode = 'INR';
objAddendum.Ag_Sales_Contract__c= objSalesCon.Id;
insert objAddendum;
}
}
No comments:
Post a Comment