重构底层框架
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package com.patbond.patbond.common.user;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public class CreateUserRequest {
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.patbond.patbond.common.user;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
public class VerifyPasswordRequest {
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.patbond.patbond.common.response;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class ApiResponseTest {
|
||||
|
||||
@Test
|
||||
void successWrapsDataWithCodeZero() {
|
||||
ApiResponse<String> response = ApiResponse.success("payload");
|
||||
|
||||
assertThat(response.getCode()).isZero();
|
||||
assertThat(response.getMessage()).isEqualTo("success");
|
||||
assertThat(response.getData()).isEqualTo("payload");
|
||||
assertThat(response.isSuccess()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void failureCarriesCodeAndMessageWithoutData() {
|
||||
ApiResponse<Object> response = ApiResponse.failure(409, "用户名已存在");
|
||||
|
||||
assertThat(response.getCode()).isEqualTo(409);
|
||||
assertThat(response.getMessage()).isEqualTo("用户名已存在");
|
||||
assertThat(response.getData()).isNull();
|
||||
assertThat(response.isSuccess()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultInstanceIsNotSuccess() {
|
||||
assertThat(new ApiResponse<String>().isSuccess()).isFalse();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user