@isTest private class SSOpportunity2BatchTest { private static Product2 product = null; private static Id pricebookId = ControllerUtil.getStandardPricebook().Id; static { product = new Product2( Name='テスト商品'); insert product; } private static PricebookEntry buildPB(String input) { PricebookEntry entry = new PricebookEntry(Pricebook2Id=pricebookId, Product2Id=product.Id); entry.UnitPrice = 0; entry.IsActive = true; entry.UseStandardPrice = false; entry.CurrencyIsoCode = input; insert entry; return entry; } @isTest(SeeAllData=true) static void makeSqlTest() { Opportunity opp1 = new Opportunity(Name='aiueo1', Opportunity_No__c='test0629',StageName='出荷', CurrencyIsoCode='USD', CloseDate=Date.today(),Trade__c = '外貿'); Opportunity opp2 = new Opportunity(Name='aiueo2', StageName='出荷', CurrencyIsoCode='CNY', CloseDate=Date.today(),Trade__c = '内貿'); insert new Opportunity[] {opp1, opp2}; Id execBTId = Database.executeBatch(new SSOpportunityBatch(new Id[] {opp1.Id}), 1); Opportunity2__c opp3 = new Opportunity2__c(); opp3.RankNum_Country__c = 1; insert opp3; execBTId = Database.executeBatch(new SSOpportunity2Batch(new Id[] {opp3.Opportunity__c}), 1); execBTId = Database.executeBatch(new SSOpportunity2Batch(new Id[] {opp3.Id}), 1); SS_Batch_Column_Mapping__c setting = SS_Batch_Column_Mapping__c.getValues('Opportunity2__c'); String soql = SSOpportunity2Batch.makeSql(setting, new Set()); soql += ' limit 1'; Database.query(soql); String soql1 = SSOpportunity2Batch.makeSqlSS(setting, new Set()); soql1 += ' limit 1'; Database.query(soql1); SSOpportunity2Batch ssba = new SSOpportunity2Batch(null); List reuseUpdateList = new List(); reuseUpdateList.add(new Opportunity2__c(RankNum_Country__c=1)); ssba.reuseUpdate(reuseUpdateList,1); } }