小编Pra*_*eep的帖子

为什么我们不能使用Mockito为Parameterized Constructor创建间谍

我的代码中只有参数化构造函数,我需要通过它注入.

我想间谍参数化构造函数注入模拟对象作为我的junit的依赖项.

public RegDao(){
 //original object instantiation here
Notification ....
EntryService .....
}

public RegDao(Notification notification , EntryService entry) {
 // initialize here
}

we have something like below : 
RegDao dao = Mockito.spy(RegDao.class);
Run Code Online (Sandbox Code Playgroud)

但是我们有什么东西可以在构造函数中注入模拟对象并窥探它吗?

java junit4 mockito

11
推荐指数
1
解决办法
8939
查看次数

反应选择不更新初始选择时选择的值

您可以找到下面的示例来查看我的问题: codesandox example

如果我设置对象的 name 属性,它就可以正常工作。但它在我的应用程序的其他示例中不起作用:

  setRegion(item.name);
Run Code Online (Sandbox Code Playgroud)

应用示例:

我的usestate看起来像这样:

 const [department, setDepartment] = useState("");
Run Code Online (Sandbox Code Playgroud)

这是我的应用示例:

                      <div className="sui-search-box">
                        <div className="department">
                            <label>
                              Department:
                              <Select id="depart" value={department} onChange={selectedValue => 
                                {
                                setDepartment(selectedValue.value);
                                setFilter("department", selectedValue.value, "any")
                              }}
                              options = {
                                results.map((depart, index) => {
                                  return {
                                    label: depart.name,
                                    value:depart.name,
                                    key:index
                                  }
                                })
                              }
                              />
                              {department}
                              </label> 
                          </div>
                     </div>
Run Code Online (Sandbox Code Playgroud)

设置状态的正确方法是什么以及为什么我当前的沙箱未正确绑定?

reactjs react-select

6
推荐指数
1
解决办法
2万
查看次数

CompletableFuture.runAsync 是否有线程限制

我有一个 Rest api,它在其中调用异步调用,如下所示

 CompletableFuture.runAsync(() -> {
                        // method call or code to be async.
                     try {
                            logger.info("======Before Async method call======with studySchemaEventId: "+enrollmentStudySchemaEventId);
                            this.performSimulation(studyId, enrollmentStudySchemaEventId, cloneOfFile, simulationRunInfo, totalAccrual);
                            logger.info("======After Async method call======with studySchemaEventId: "+enrollmentStudySchemaEventId);
                        } catch (SimulationException e) {
                            logger.error("Error running Async call for performSimulation()", e);
                        }
                    });
Run Code Online (Sandbox Code Playgroud)

当我调用 Rest api 时,它正确执行了异步调用。但我有一个情况,我调用 Rest Api 4 次,它执行了 3 次异步调用,而对于第四次 Api 调用,我没有看到异步方法被调用。

runAsync() 调用有任何限制吗?或者为什么在 3 次调用后不调用 Async 方法?

这是 Rest API 调用:

    @POST
    @Path("/trigger")
    @Consumes(MediaType.MULTIPART_FORM_DATA)  
    @ApiOperation(value = "Trigger Simulation",  tags = "Study Event …
Run Code Online (Sandbox Code Playgroud)

java multithreading asynchronous threadpool completable-future

3
推荐指数
1
解决办法
6341
查看次数

使用eclipse juno和java 8加载maven工件时出错

我已经安装了Eclipse Juno并集成了Maven,但是当我尝试创建Maven项目时,它显示错误,Retrieving archetypes: GC overhead limit exceeded.在我安装Juno之前,我安装了Kepler并使用了相同的Maven,它运行良好.

java eclipse maven

2
推荐指数
1
解决办法
1708
查看次数