小编use*_*026的帖子

如何模拟返回`Mono<Void>`的方法

如何模拟返回的方法Mono<Void>

我有这个返回的方法 Mono<Void>

public Mono<Void> deleteMethod(Post post) {

        return statusRepository.delete(post);
    }
Run Code Online (Sandbox Code Playgroud)

在我的测试课中,我想做这样的事情

given(statusRepository.delete(any(Post.class))).willReturn(Mono.empty());
Run Code Online (Sandbox Code Playgroud)

有没有更好的方法来做到这一点?

有人能帮我吗?

谢谢。

java unit-testing mockito reactive-programming spring-webflux

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

Angular 2自定义验证器,用于检查何时需要两个字段之一

我正在尝试实现自定义验证器功能来检查是否输入了电话号码(家庭电话和移动电话).我想在两个字段上显示错误消息,当它们被触摸并且没有有效值时,由于某种原因我的代码没有按预期工作.请帮帮我这篇文章.-谢谢!这是stackblitz链接https://stackblitz.com/edit/angular-ve5ctu

createFormGroup() {
   this.myForm = this.fb.group({
     mobile : new FormControl('', [this.atLeastOnePhoneRequired]),
     homePhone : new FormControl('', [this.atLeastOnePhoneRequired])
   });
}

atLeastOnePhoneRequired(control : AbstractControl) : {[s:string ]: boolean} {
  const group = control.parent;
  if (group) {
    if(group.controls['mobile'].value || group.controls['homePhone'].value) {
      return;
    }
  }
  let errorObj = {'error': false};
  return errorObj;
}
Run Code Online (Sandbox Code Playgroud)

angular-validation angular angular-reactive-forms

4
推荐指数
1
解决办法
2679
查看次数

异常启动过滤器struts2 java.lang.ClassNotFoundException:org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

当我尝试部署到tomcat时,我刚刚开始学习struts2我遇到了以下错误

Exception starting filter struts2
java.lang.ClassNotFoundException:org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
Run Code Online (Sandbox Code Playgroud)

我经历了几个其他帖子,但我无法解决问题,请帮助我..非常感谢!

/ 这是我正在使用的web.xml文件 /

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Struts2Start</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)

/ Struts.xml /

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
   <package name="default" extends="struts-default">
    <action name="getTutorial" class="com.javabrains.struts.action.TutorialAction">
      <result name="success">/success.jsp</result>
      <result name="error">/error.jsp</result>
    </action>
   </package>
</struts>
Run Code Online (Sandbox Code Playgroud)

/ console /

SEVERE: Exception starting filter struts2
java.lang.ClassNotFoundException:     org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) …
Run Code Online (Sandbox Code Playgroud)

struts2

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