如何在 Completablefuture 上添加断言<boolean> Junit Mockito

问题描述 投票:0回答:0

我有一个名为 **asynEvaluaEstadoSiniestro ** 的服务,它返回 true 或 false,以及一些在我的测试中被模拟的存储库。

@Service
@Slf4j
public class AsynEvaluaEstadoSiniestroImpl implements AsynEvaluaEstadoSiniestro {

  @Async("myExecutor")
  public CompletableFuture<Boolean> getEvaluacionEstadoSiniestro(DocumentRequest request) throws BusinessException {
  //do some persistances operations in repositories and return fooResult as true or false;|

  return CompletableFuture.completedFuture(fooResult);
  }
}
@InjectMocks
AsynEvaluaEstadoSiniestroImpl asynEvaluaEstadoSiniestro;

@Test
@DisplayName("Async process (1)")
void insertarSolicitudTest() throws BusinessException {
   //some when repositories functions needed for testing

CompletableFuture<Boolean> cf = asynEvaluaEstadoSiniestro.getEvaluacionEstadoSiniestro(documentRequest());
        cf.isDone();
}

当我执行 sonaqube coverity 它说:
为此测试用例添加至少一个断言

如何向这个测试添加断言???

希望能给这个测试加一个断言

java asynchronous junit mockito
© www.soinside.com 2019 - 2024. All rights reserved.