春季启动时单元测试@Async

时间:2018-05-25 10:54:13

标签: java spring spring-boot junit mockito

我有一个返回自定义对象未来的方法,如下所示

@Async
public Future<Map<ObjectId, Field>> execute(final List<GlobalValidation> globalUniqueValidations,
        final Map<ObjectId, ValidationField> evalFieldValueMap, final Map<ObjectId, Field> inputFieldValuesMap) {

    LOGGER.debug("Triggering unique validations");

    if (CollectionUtils.isEmpty(globalUniqueValidations)) {
        return new AsyncResult<Map<ObjectId, Field>>(inputFieldValuesMap);
    }

    for (final GlobalValidation globalValidation : globalUniqueValidations) {
        executeUniqueValidationPerCollection(globalValidation, evalFieldValueMap, inputFieldValuesMap);
    }

    return new AsyncResult<Map<ObjectId, Field>>(inputFieldValuesMap);
}

请帮助我了解如何编写单元测试用例以使用MockitoJUnitRunner返回AsyncResult<Map<ObjectId, Field>>对象类型

0 个答案:

没有答案