@isTest private class UpdateContractAimAmountHandlerTest { @isTest static void test_method_one() { // Implement test code Account account2 = new Account(); account2.Name = 'test1经销商'; account2.RecordTypeId = '01210000000Qem1'; insert account2; Contact contact2 = new Contact(); contact2.AccountId = account2.Id; contact2.Agency_User__c = true; contact2.FirstName = '責任者'; contact2.LastName = 'test1经销商'; insert contact2; Profile p = [select Id from Profile where Name = '901_经销商活动系统' ]; User user = new User(); user.isActive = true; //user.isActive = true; user.ProfileId = p.Id; user.ContactId = contact2.Id; user.FirstName = 'ユーザー'; user.LastName = 'テスト'; user.Email = 'test_user@example.com'; user.emailencodingkey='UTF-8'; user.languagelocalekey='zh_CN'; user.localesidkey='ja_JP'; user.timezonesidkey='Asia/Shanghai'; user.Username = 'test_user@example.com'; user.Alias = 'テユ'; user.CommunityNickname = 'テストユーザー'; insert user; Account account = new Account(); account.RecordTypeId = '01210000000QjCNAA0'; account.Name = '契約'; account.Aim_Price_GIR__c = 1000; account.Aim_Price_ET__c = 2000; account.Aim_Price_SP__c = 3000; account.Contract_Fiscal_Period__c = '150P'; account.ParentId = account2.Id; insert account; List < RecordType > rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院' ]; Account hospital = new Account(); hospital.RecordTypeId = rectCo[0].Id; hospital.Is_Active__c = '有効'; hospital.Name = 'test医院'; // hospital.AwaitToSendAWS__c = true; upsert hospital; List resList = [select Id, Department_Cateogy_l__c, OCM_Term__c,Aim_Price__c from Agency_Opportunity__c]; System.assertEquals(resList.size(), 3); for(Agency_Opportunity__c res : resList) { if (res.Department_Cateogy_l__c == 'GIR') { System.assertEquals(res.Aim_Price__c, 1000); } if (res.Department_Cateogy_l__c == 'ET') { System.assertEquals(res.Aim_Price__c, 2000); } if (res.Department_Cateogy_l__c == 'SP') { System.assertEquals(res.Aim_Price__c, 3000); } } } }