@isTest
private class UpdateOppLineItemAgencySubtotalTest {



	private static Product2 product = null;
	private static Pricebook2 pricebook = null;


	private static  Opportunity opprtunity = null;

	static final String RC_HOSPITAL = '病院';
	static final String RC_OPP = '引合';
	static final String RC_SENRYAKUKASHITSUBUNRUI = '戦略科室分類 消化科';
	static final String RC_BYOUIN = '病院';
	static final String RC_SHINRYOUKA = '診療科 その他';
	static final String RC_HANBAOITEN = '販売店';
	static final String RC_KEIYAKU = '契約';

	static {
		product = new Product2( Name = 'テスト商品');
		insert product;
		system.debug('##product.Id=[' + product.Id + ']' );

		pricebook = ControllerUtil.getStandardPricebook();
		system.debug('##pricebook.Id=[' + pricebook.Id + ']' );
	}

	private static String quoteNo = 'textQutote01';
	public static String trade = '内貿';
	public static String CurrencyIso = 'CNY';

	private static Boolean isUnitPrice = true;
	private static Boolean isOfferAmount = true;
	private static Boolean isTotalPrice = true;
	private static Boolean isDiscountRate = true;
	private static Boolean isDiscountAmount = true;
	private static Boolean isTradingPrice = true;
	private static Boolean isContractDetail = true;

	private static Date offerExpireDate = Date.today();
	private static String clientName = 'test client';
	private static String offerComment = 'test comment';
	private static Date offerPrintDate = Date.today();
	private static String agentName = 'test agent name';

	private static PricebookEntry buildPB( String input) {
		PricebookEntry entry = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product.Id);

		entry.UnitPrice = 0;
		entry.IsActive = true;
		entry.UseStandardPrice = false;
		entry.CurrencyIsoCode = input;
		insert entry;
		return entry;
	}

	private static Opportunity buildOppInstance( String inputTrade, String CurrencyIsoCode) {
		Opportunity target = new Opportunity( Name = 'aiueo', StageName = 'contact', CloseDate = Date.today());
		target.Trade__c = inputTrade;
		target.owner_not_automatically_update__c = true;
		target.CurrencyIsoCode = CurrencyIsoCode;
		target.Wholesale_Price__c = 9000;
		return target;
	}

	private static QuoteLineItem insertQuoteLineItem( Quote input, Pricebookentry entry) {
		QuoteLineItem target = new QuoteLineItem();
		target.Name__c = 'テスト商品';
		target.QuoteId = input.Id;
		target.Quantity = 1;
		target.Quantity__c = 1;
		target.Cost_Subtotal__c = 0;
		target.Cost__c = 200;
//        target.TotalPrice = 100;
		target.UnitPrice = 10;
		target.ListPrice__c  = 10;
		target.PricebookEntryId = entry.Id;
		insert target;
		return target;
	}
	
    /**
	@isTest static void test_method_one() {
		String userId = UserInfo.getUserId();
		User u1 = [SELECT Id, Quote_Correct__c, Quote_Special_Operation__c, Cost_Referable__c FROM User WHERE Id = :userId];
		u1.Quote_Correct__c = false;
		u1.Quote_Special_Operation__c = true;
		u1.Cost_Referable__c = true;
		update u1;

		// PricebookEntry
		PricebookEntry entryUSD = buildPB( 'USD');
		PricebookEntry entryCNY = buildPB( 'CNY');

		// 引合作成
		Opportunity opp = buildOppInstance( trade, CurrencyIso);
		opp.Trade__c = trade;
		opp.owner_not_automatically_update__c = true;
		opp.Sales_Root__c = '販売店';
		opp.Pricebook2Id = pricebook.id;
		insert opp;

		//見積データ作成
		Quote quote = new Quote( Name = 'テスト見積');
		quote.OpportunityId = opp.Id;
		quote.Pricebook2Id = pricebook.id;
		quote.Quote_No__c = quoteNo;

		quote.Unit_Price__c = isUnitPrice;
		quote.Offer_Amount__c = isOfferAmount;
		quote.TOTAL__c = isTotalPrice;
		quote.Discount__c = isDiscountRate;
		quote.Pricing__c = isDiscountAmount;
		quote.Preferential_Trading_Price__c = isTradingPrice;
		quote.Contract__c = isContractDetail;
		quote.Quote_Comment__c = offerComment;
		quote.OCM_Agent1_Price__c = 12345;
		quote.Estimation_List_Price__c = 23456;
		insert quote;
		quote = [SELECT Id, OpportunityId, Quote_no__c, Quote_No_Auto__c, CurrencyIsoCode FROM Quote WHERE Id = :quote.id];
		System.assertEquals( CurrencyIso, quote.CurrencyIsoCode);

		// 見積品目作成
		QuoteLineItem item01 = insertQuoteLineItem( quote, entryCNY);
		QuoteLineItem item02 = insertQuoteLineItem( quote, entryCNY);

		//見積データ検索
		opprtunity = [SElECT Id, Opportunity_no__c, CurrencyIsoCode FROM Opportunity WHERE Id = :opp.id];
		OpportunityLineItem oli = new OpportunityLineItem();
		oli.Quantity = 1;
		//oli.Quantity__c = 1;
		oli.UnitPrice = 0;
		oli.ListPrice__c  = 10;
		oli.OpportunityId = opp.id;

		oli.PricebookEntryId = entryCNY.Id;
		insert oli;
		System.Test.startTest();
		quote.AgencyDiscount__c = null;
		update quote;
	}*/

	@isTest static void test_method_two() {
		// Implement test code
	}

}