下面是我的 DTO 课程。
public class AbstractDTO extends BaseDTO {
private Integer createdBy;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DATE_FORMAT)
@NotNull(message = "createdDate may not be null")
private LocalDateTime createdDate;
private Integer lastModifiedBy;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DATE_FORMAT)
private LocalDateTime lastModifiedDate;
private Boolean isActive;
// getter & setters
}
Run Code Online (Sandbox Code Playgroud)
在这里,我试图将 createdDate 字段注释为 @NotNull 但它不起作用。它允许在请求正文中并且在邮递员中执行服务后没有收到任何错误。
我尝试了以下选项,但没有运气。
1)尝试添加maven依赖。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
2) 尝试将 DTO 类注释为 @Validated
3) 尝试使用 @NotNull 注释 createdDate 字段 @Valid 但仍然没有运气。
请帮我解决这个问题。
我正在探索 keycloak,我想构建一个基于用户手机号码的应用程序,短信 OTP 应该去用户进行身份验证。我找不到任何地方。
我需要帮助为下面的方法编写模拟测试用例。
public void getCouponAndNotifyAsync(String countryId, String channelId,
String storeNumber, String clientId, NotificationRequest notificationRequest)
throws FirestoreException, TurneroServiceException {
CompletableFuture.runAsync(() -> getCouponAndNotify(countryId, channelId,
storeNumber, clientId, notificationRequest));
}
Run Code Online (Sandbox Code Playgroud)
其中 getCouponAndNotify() 是一个 void 方法。
尝试了下面但它不起作用
@Test
public void getCouponAndNotifyAsync() throws Exception {
//doNothing().when(turneroService).getCouponAndNotify(COUNTRYID, CHANNELID, STORENUMBER, CLIENTID, new NotificationRequest("ext_rborse@falabella.cl", "all"));
CompletableFuture<Void> runAsync = CompletableFuture
.runAsync(() -> doNothing().when(turneroService).getCouponAndNotify(COUNTRYID, CHANNELID, STORENUMBER, CLIENTID, new NotificationRequest("ext_rborse@falabella.cl", "all")));
assertTrue(runAsync.isDone());
}
Run Code Online (Sandbox Code Playgroud)
更新了测试用例但仍然不起作用。
@Test
public void getCouponAndNotifyAsync() throws Exception {
//doNothing().when(turneroService).getCouponAndNotify(COUNTRYID, CHANNELID, STORENUMBER, CLIENTID, new NotificationRequest("ext_rborse@falabella.cl", "all"));
CompletableFuture<Void> runAsync = CompletableFuture
.runAsync(() …Run Code Online (Sandbox Code Playgroud) 我无法在网络浏览器上打开 H2 控制台。我的 jhipster 应用程序在 8088 端口上运行。在服务器日志中,我发现 H2 数据库在端口 18088 上可用。
下面尝试过。 http://localhost:18088/h2-console
以下是 application-dev.yml 中的详细信息。
devtools:
restart:
enabled: true
additional-exclude: .h2.server.properties
livereload:
enabled: false # we use Webpack dev server + BrowserSync for livereload
jackson:
serialization:
indent-output: true
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:h2:mem:jhipstersampleapplication;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
username: jhipsterSampleApplication
password:
hikari:
poolName: Hikari
auto-commit: false
h2:
console:
enabled: true
jpa:
database-platform: io.github.jhipster.domain.util.FixedH2Dialect
database: H2
show-sql: true
properties:
hibernate.id.new_generator_mappings: true
hibernate.connection.provider_disables_autocommit: true
hibernate.cache.use_second_level_cache: true
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: false
Run Code Online (Sandbox Code Playgroud)
这个你能帮我吗。