jmockit

    @Tested(要被注入的对象也是测试对象)

    private ImportHintValidationServiceImpl importHintValidationServiceImpl;


    @Injectable(向测试对象注入)
    private TradeClient tradeClient;


    @Injectable
    private IUserInfoHelper iUserInfoHelper;


    /**
     * Test method for
     * {@link com.baidu.rigel.ipangu.hint.entrance.impl.ImportHintValidationServiceImpl#validateHints(com.baidu.rigel.ipangu.hint.entrance.vo.HintLogVo, java.util.List, java.lang.Long)}
     * .
     */


    @Test
    public void testValidateHints() {

        new MockUp<IUserInfoHelper>() {
            @Mock(静态方法注入)
            public Long getUnitPosId() {
                return 56665L;
            }
        };


        new NonStrictExpectations() {(录制被注入对象返回)
            {
                tradeClient.getAllLevel1Ids(anyLong);
                List<Long> abc = new ArrayList<Long>();
                abc.add(1L);
                abc.add(2L);
                result = abc;


                tradeClient.getAllLevel2(2L);
                result = null;
            }
        };


        hintInfo1.setSrcType("1");
        hintInfo1.setCustomerType((byte) 0);
        hintInfo1.setSiteType((byte) 1);
        HintIntentionVo intention1 = new HintIntentionVo();
        intention1.setHintIntentionDegree(3L);
        List<HintIntentionVo> intentionList = new ArrayList<HintIntentionVo>();
        intentionList.add(intention1);
        hintInfo1.setIntentionList(intentionList);
        List<HintInfo> hintInfoList = new ArrayList<HintInfo>();
        hintInfoList.add(hintInfo1);


        importHintValidationServiceImpl.validateHints(hintLog, hintInfoList, 1L);(用被注入对象调用对应测试方法)

//加入断言


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值