如何使用Mockito测试这种方法?

时间:2018-06-13 10:26:02

标签: mockito

public double getMinCBQta(long enteCod, long artCod) throws FailureException {
    logger.debug("getMinCBqta() - ENTER");

    double minCBQta = 0;

    final TypedQuery<Double> query = em.createQuery("select NVL(Min(c.qtaCapienza),0) " + "from CapienzaBanco c "
        + "where c.id.enteCod = :ENTECOD AND c.id.artCod = :ARTCOD "
        + "AND c.id.nrPromo = 0 AND c.id.annoPromo = 0 AND c.qtaCapienza!= 0 ", Double.class);

    try {

        query.setParameter(CommonConstants.ENTECOD, enteCod);
        query.setParameter(CommonConstants.ARTCOD, artCod);

        minCBQta = query.getSingleResult();

    } catch (final NoResultException ne) {

        logger.warn("getMinCBQta :No result received from CAPIENZA_BANCO with enetCod " + enteCod + "artCod: " + artCod);

    } catch (final Exception e) {
        logger.error("getMinCBQta : Error Retriving data from CAPIENZA_BANCO  " + e.getMessage());
        throw new FailureException("getMinCBQta : Error Retriving data from CAPIENZA_BANCO " + e);
    }

    logger.debug("getMinCBqta()" + " EXIT");

    return minCBQta;
}

0 个答案:

没有答案