@isTest
public class NewAndEditUserFaultInfoControllerTest {
    @TestSetup
    static void makeData(){
        TestDataUtility.CreatePIPolicyConfiguration();
    }
    static testMethod void NewAndEditLoanerApplicationController1() {
        Contact ccn = TestDataUtility.CreateContacts(1)[0];
        ccn.AWS_Data_Id__c = 'a0m0l000002XnpsAAC';
        update ccn;
        Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock());
        loaner_application__c la = TestDataUtility.Createloanerapplications(1)[0];
        //User_FaultInfo__c UF = new User_FaultInfo__c();
        User_FaultInfo__c ca = new User_FaultInfo__c();
    	ca.ORIGIN__c = 'Web';
    	ca.SUBJECT__c = 'test';
    	ca.OFFICE_OWNER__c = 'Beijing';
    	ca.Product_Type__c = 'NDT';
    	ca.TYPE__c = 'Service';
    	ca.LOGISTICS_SHIPMENT_TYPE__c = 'Domestic';
    	ca.STATUS__c = 'Not Started';
    	ca.PRIORITY__c = 'High';
    	insert ca;
        ca.COMPANY__c = ccn.AccountId;
        ca.CONTACT__c = ccn.Id;
        ca.UFContact__c = ccn.Id;
        update ca;
        

        Test.startTest();
        ApexPages.StandardController con =  new ApexPages.StandardController(ca);
        NewAndEditUserFaultInfoController qis = new NewAndEditUserFaultInfoController(con);
        qis.PIPL_Input_Account_Error_Msg = 'error';
        qis.staticResourceContact = 'contact';
        qis.contactId = '111';
        
        
        String qisJson = '{"Name":"23432432","ORIGIN__c":"E-mail","SUBJECT__c":"fdsafads","OFFICE_OWNER__c":"Beijing","INCIDENT_DATE__c":"","SYSTEM_TYPE__c":"","INBOUND_EMAIL_ADDRESS__c":"","TRAN__c":"","ZONE__c":"","Product_Type__c":"","TYPE__c":"Question","UFPhone__c":"***********","PAYMENT_TERM__c":"","ASSIGNED_TO__c":"00528000000YVZE","SUBSIDIARY__c":"","CONTACT__c":"0030l00000mqqfiAAA","COMPANY__c":"0010l00001QAz54","LOGISTICS_SHIPMENT_TYPE__c":"Domestic","VISUAL_WORK_ORDER_NUMBER__c":"","LAST_MESSAGE_DATETIME__c":"","STATUS__c":"In Progress","BID_TOTAL__c":"","PRIORITY__c":"Medium","SERIAL_NUMBER_NOT_MANDATORY__c":"","SEND_TO_CUSTOMER__c":false,"INTERNAL_ONLY__c":true,"Interactions__c":"","interactionsHistory__c":"","UFPhone_Encrypted__c":"af6b1eac5a3196e7918745a50b42cc04","INBOUND_EMAIL_ADDRESS_Encrypted__c":"","AWS_Data_Id__c":"963391015715078145"}';
        NewAndEditUserFaultInfoController.saveUserFaultInfo(qisJson,'avgwshDFcxAS',False);
        Test.stopTest();
    }
    
    static testMethod void NewAndEditLoanerApplicationController2() {
        Contact ccn = TestDataUtility.CreateContacts(1)[0];
        ccn.AWS_Data_Id__c = 'a0m0l000002XnpsAAC';
        update ccn;
        Test.setMock(HttpCalloutMock.class, new TestDataUtility.CreateMetaDataUtilityHttpMock());
        loaner_application__c la = TestDataUtility.Createloanerapplications(1)[0];
        //User_FaultInfo__c UF = new User_FaultInfo__c();
        User_FaultInfo__c ca = new User_FaultInfo__c();
    	ca.ORIGIN__c = 'Web';
    	ca.SUBJECT__c = 'test';
    	ca.OFFICE_OWNER__c = 'Beijing';
    	ca.Product_Type__c = 'NDT';
    	ca.TYPE__c = 'Service';
    	ca.LOGISTICS_SHIPMENT_TYPE__c = 'Domestic';
    	ca.STATUS__c = 'Not Started';
    	ca.PRIORITY__c = 'High';
    	insert ca;
        ca.COMPANY__c = ccn.AccountId;
        // ca.CONTACT__c = ccn.Id;
        update ca;
        

        Test.startTest();
        ApexPages.StandardController con =  new ApexPages.StandardController(ca);
        NewAndEditUserFaultInfoController qis = new NewAndEditUserFaultInfoController(con);
        qis.PIPL_Input_Account_Error_Msg = 'error';
        qis.staticResourceContact = 'contact';
        qis.contactId = '111';
        
        
        String qisJson = '{"Name":"23432432","ORIGIN__c":"E-mail","SUBJECT__c":"fdsafads","OFFICE_OWNER__c":"Beijing","INCIDENT_DATE__c":"","SYSTEM_TYPE__c":"","INBOUND_EMAIL_ADDRESS__c":"","TRAN__c":"","ZONE__c":"","Product_Type__c":"","TYPE__c":"Question","UFPhone__c":"***********","PAYMENT_TERM__c":"","ASSIGNED_TO__c":"00528000000YVZE","SUBSIDIARY__c":"","CONTACT__c":"0030l00000mqqfiAAA","COMPANY__c":"0010l00001QAz54","LOGISTICS_SHIPMENT_TYPE__c":"Domestic","VISUAL_WORK_ORDER_NUMBER__c":"","LAST_MESSAGE_DATETIME__c":"","STATUS__c":"In Progress","BID_TOTAL__c":"","PRIORITY__c":"Medium","SERIAL_NUMBER_NOT_MANDATORY__c":"","SEND_TO_CUSTOMER__c":false,"INTERNAL_ONLY__c":true,"Interactions__c":"","interactionsHistory__c":"","UFPhone_Encrypted__c":"af6b1eac5a3196e7918745a50b42cc04","INBOUND_EMAIL_ADDRESS_Encrypted__c":"","AWS_Data_Id__c":"963391015715078145"}';

        NewAndEditUserFaultInfoController.saveUserFaultInfo(qisJson,'avgwshDFcxAS',True);
        Test.stopTest();
    }
}