분석 결과를 기반으로 Spring 전환 체크리스트 작성 #2
9 changed files with 565 additions and 0 deletions
3
.forge/E2E-MINIMAX-DEV-001-attempt-1-run-09b17eb7479a.md
Normal file
3
.forge/E2E-MINIMAX-DEV-001-attempt-1-run-09b17eb7479a.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# E2E-MINIMAX-DEV-001-attempt-1-run-09b17eb7479a
|
||||
|
||||
Forge 이슈 작업 브랜치 `forge/E2E-MINIMAX-DEV-001-attempt-1-run-09b17eb7479a`.
|
||||
111
docs/spring-migration-checklist.md
Normal file
111
docs/spring-migration-checklist.md
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
# Spring Boot 전환 구현 체크리스트
|
||||
|
||||
## 1. 프로젝트 구조 분석
|
||||
|
||||
### 1.1 현재 구조 파악
|
||||
- [ ] 기존 프로젝트 타입 확인 (Plain Java, Maven, Gradle)
|
||||
- [ ] 의존성 목록 정리
|
||||
- [ ] 주요 설정 파일 식별 (application.properties, config.xml)
|
||||
- [ ] 데이터소스 및 ORM 설정 확인
|
||||
- [ ] 보안 설정 현황 파악
|
||||
|
||||
### 1.2 Spring Boot 호환성 평가
|
||||
- [ ] Java 버전 호환성 확인 (Java 17+ 권장)
|
||||
- [ ] Spring Boot 3.x 호환 의존성 확인
|
||||
- [ ] Jakarta EE 마이그레이션 필요성 평가
|
||||
|
||||
---
|
||||
|
||||
## 2. 빌드 설정 전환
|
||||
|
||||
### 2.1 Maven → Spring Boot
|
||||
- [ ] `pom.xml` → Spring Boot Parent 적용
|
||||
- [ ] Spring Boot Starter 의존성 추가
|
||||
- [ ] 빌드 플러그인 설정 (`spring-boot-maven-plugin`)
|
||||
- [ ] 의존성 버전 관리 Parent로 이관
|
||||
|
||||
### 2.2 의존성 전환 매핑
|
||||
|
||||
| 기존 의존성 | Spring Boot Starter |
|
||||
|------------|---------------------|
|
||||
| spring-web + spring-webmvc | spring-boot-starter-web |
|
||||
| spring-data-jpa + hibernate | spring-boot-starter-data-jpa |
|
||||
| spring-security | spring-boot-starter-security |
|
||||
| spring-test | spring-boot-starter-test |
|
||||
| jackson-databind | Jackson (기본 내장) |
|
||||
| log4j/slf4j | spring-boot-starter-logging |
|
||||
|
||||
---
|
||||
|
||||
## 3. 설정 파일 마이그레이션
|
||||
|
||||
### 3.1 application.properties → application.yml
|
||||
- [ ] 기존 properties를 YAML 형식으로 변환
|
||||
- [ ] profile별 설정 파일 분리 (dev, prod, test)
|
||||
- [ ] 환경별 변수 설정 검증
|
||||
|
||||
### 3.2 XML 설정 → Java Config
|
||||
- [ ] `web.xml` → `WebApplicationInitializer`
|
||||
- [ ] `spring-context.xml` → `@Configuration` 클래스
|
||||
- [ ] `dispatcher-servlet.xml` → `application.yml` + Java Config
|
||||
- [ ] DataSource 설정 → `@Bean` 또는 `application.yml`
|
||||
|
||||
---
|
||||
|
||||
## 4. 코드 변환
|
||||
|
||||
### 4.1 메인 클래스
|
||||
- [ ] `@SpringBootApplication` 어노테이션 추가
|
||||
- [ ] `SpringApplication.run()` 진입점 생성
|
||||
|
||||
### 4.2 REST 컨트롤러
|
||||
- [ ] `@RestController` 적용 (기존 `@Controller` + `@ResponseBody`)
|
||||
- [ ] `@RequestMapping` → `@GetMapping`, `@PostMapping` 등
|
||||
- [ ] `ResponseEntity` 반환 타입 사용
|
||||
|
||||
### 4.3 서비스/리포지토리
|
||||
- [ ] `@Service`, `@Repository` 어노테이션 적용
|
||||
- [ ] JPA 리포지토리 인터페이스로 변환
|
||||
- [ ] `@Transactional` 전파 전략 확인
|
||||
|
||||
### 4.4 예외 처리
|
||||
- [ ] `@ControllerAdvice` 전역 예외 처리 구현
|
||||
- [ ] 커스텀 예외 클래스 정의
|
||||
- [ ] HTTP 상태 코드 매핑
|
||||
|
||||
---
|
||||
|
||||
## 5. 테스트 전환
|
||||
|
||||
- [ ] `@SpringBootTest` 적용
|
||||
- [ ] `@WebMvcTest`, `@DataJpaTest` 활용
|
||||
- [ ] MockMvc를 통한 API 테스트
|
||||
- [ ] 테스트 프로필 설정
|
||||
|
||||
---
|
||||
|
||||
## 6. 검증 체크리스트
|
||||
|
||||
### 6.1 빌드 검증
|
||||
- [ ] `mvn clean package` 성공
|
||||
- [ ] BootJar 생성 확인
|
||||
- [ ] 의존성 충돌 없음
|
||||
|
||||
### 6.2 실행 검증
|
||||
- [ ] 애플리케이션 정상 기동
|
||||
- [ ] `/actuator/health` 엔드포인트 응답
|
||||
- [ ] 로그 출력 정상
|
||||
|
||||
### 6.3 기능 검증
|
||||
- [ ] REST API 엔드포인트 동작 확인
|
||||
- [ ] 데이터베이스 연결/쿼리 정상
|
||||
- [ ] 세션/인증 동작 확인
|
||||
- [ ] 예외 처리 정상 동작
|
||||
|
||||
---
|
||||
|
||||
## 7. 마이그레이션 후 처리
|
||||
|
||||
- [ ] 기존 XML 설정 파일 아카이브
|
||||
- [ ] 마이그레이션 문서 업데이트
|
||||
- [ ] 팀 교육 및 가이드 작성
|
||||
74
docs/spring-migration-verification.md
Normal file
74
docs/spring-migration-verification.md
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
# Spring Boot 전환 검증 항목
|
||||
|
||||
## 1. 빌드 검증
|
||||
|
||||
| 검증 항목 | 기대 결과 | 검증 방법 |
|
||||
|---------|----------|----------|
|
||||
| Maven 빌드 성공 | BUILD SUCCESS | `mvn clean install` |
|
||||
| BootJar 생성 | `target/*.jar` 존재 | 파일 확인 |
|
||||
| 의존성 트리 정상 | 충돌 없음 | `mvn dependency:tree` |
|
||||
| 테스트 빌드 통과 | 모든 테스트 성공 | `mvn test` |
|
||||
|
||||
## 2. 애플리케이션 기동 검증
|
||||
|
||||
| 검증 항목 | 기대 결과 | 검증 방법 |
|
||||
|---------|----------|----------|
|
||||
| BootJar 실행 | 에러 없이 기동 | `java -jar app.jar` |
|
||||
| 포트 바인딩 | 설정된 포트 사용 | 로그 확인 |
|
||||
| Context 로딩 | 모든 Bean 초기화 | 로그 확인 |
|
||||
| Health Check | UP 상태 | `curl localhost:port/actuator/health` |
|
||||
|
||||
## 3. 기능 검증 체크리스트
|
||||
|
||||
### 3.1 웹 계층
|
||||
- [ ] `GET /api/**` 요청/응답 정상
|
||||
- [ ] `POST /api/**` 요청/응답 정상
|
||||
- [ ] `PUT /api/**` 요청/응답 정상
|
||||
- [ ] `DELETE /api/**` 요청/응답 정상
|
||||
- [ ] 파라미터 바인딩 정상
|
||||
- [ ] Validation 에러 응답 정상
|
||||
|
||||
### 3.2 데이터 계층
|
||||
- [ ] JPA Repository CRUD 동작
|
||||
- [ ] 트랜잭션 커밋/롤백 정상
|
||||
- [ ] 페이징/정렬 동작
|
||||
|
||||
### 3.3 보안 계층
|
||||
- [ ] 인증 필요 엔드포인트 접근 차단
|
||||
- [ ] 인증 성공 시 토큰/세션 발급
|
||||
- [ ] 인가 규칙 정상 동작
|
||||
|
||||
### 3.4 예외 처리
|
||||
- [ ] 400 Bad Request 응답 정상
|
||||
- [ ] 401 Unauthorized 응답 정상
|
||||
- [ ] 404 Not Found 응답 정상
|
||||
- [ ] 500 Internal Server Error 응답 정상
|
||||
|
||||
## 4. 설정 검증
|
||||
|
||||
| 검증 항목 | 기대 결과 |
|
||||
|---------|----------|
|
||||
| application.yml 로딩 | 모든 프로퍼티 정상 인식 |
|
||||
| Profile별 설정 분리 | `-Dspring.profiles.active=prod` 동작 |
|
||||
| 환경 변수 주입 | `${VAR_NAME}` 대체 정상 |
|
||||
|
||||
## 5. 회귀 테스트 결과
|
||||
|
||||
| 구분 | 테스트 수 | 성공 수 | 실패 수 |
|
||||
|-----|----------|--------|--------|
|
||||
| 단위 테스트 | - | - | - |
|
||||
| 통합 테스트 | - | - | - |
|
||||
|
||||
## 검증 결과 기록
|
||||
|
||||
### 검증 환경
|
||||
- Java 버전:
|
||||
- Spring Boot 버전:
|
||||
- 빌드 도구:
|
||||
- 검증 일시:
|
||||
|
||||
### 검증자:
|
||||
|
||||
### 특이사항:
|
||||
|
||||
### 미해결 항목:
|
||||
101
spring-migration/pom.xml
Normal file
101
spring-migration/pom.xml
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.2.5</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>spring-migration-sample</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Spring Boot Migration Sample</name>
|
||||
<description>Spring Boot 전환 샘플 프로젝트</description>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.example.migration;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* Spring Boot Migration 메인 애플리케이션
|
||||
*
|
||||
* @SpringBootApplication은 다음을 포함:
|
||||
* - @Configuration: Bean 정의용
|
||||
* - @EnableAutoConfiguration: Spring Boot 자동 설정
|
||||
* - @ComponentScan: 컴포넌트 스캔
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class SpringMigrationApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringMigrationApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.example.migration.controller;
|
||||
|
||||
import com.example.migration.dto.ApiResponse;
|
||||
import com.example.migration.dto.SampleRequest;
|
||||
import com.example.migration.dto.SampleResponse;
|
||||
import com.example.migration.exception.ResourceNotFoundException;
|
||||
import com.example.migration.service.SampleService;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 샘플 REST 컨트롤러 - Spring Boot 전환 후 @RestController 사용 예시
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/samples")
|
||||
@RequiredArgsConstructor
|
||||
public class SampleController {
|
||||
|
||||
private final SampleService sampleService;
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<ApiResponse<List<SampleResponse>>> getAllSamples() {
|
||||
List<SampleResponse> samples = sampleService.getAllSamples();
|
||||
return ResponseEntity.ok(ApiResponse.success(samples));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<ApiResponse<SampleResponse>> getSampleById(@PathVariable Long id) {
|
||||
SampleResponse response = sampleService.getSampleById(id);
|
||||
return ResponseEntity.ok(ApiResponse.success(response));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<ApiResponse<SampleResponse>> createSample(
|
||||
@Valid @RequestBody SampleRequest request) {
|
||||
SampleResponse response = sampleService.createSample(request);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(ApiResponse.success(response));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<ApiResponse<SampleResponse>> updateSample(
|
||||
@PathVariable Long id,
|
||||
@Valid @RequestBody SampleRequest request) {
|
||||
SampleResponse response = sampleService.updateSample(id, request);
|
||||
return ResponseEntity.ok(ApiResponse.success(response));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<ApiResponse<Void>> deleteSample(@PathVariable Long id) {
|
||||
sampleService.deleteSample(id);
|
||||
return ResponseEntity.ok(ApiResponse.success(null));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package com.example.migration.service;
|
||||
|
||||
import com.example.migration.dto.SampleRequest;
|
||||
import com.example.migration.dto.SampleResponse;
|
||||
import com.example.migration.entity.SampleEntity;
|
||||
import com.example.migration.exception.ResourceNotFoundException;
|
||||
import com.example.migration.repository.SampleRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 샘플 서비스 - @Service 어노테이션으로 컴포넌트 스캔 대상
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Transactional(readOnly = true)
|
||||
public class SampleService {
|
||||
|
||||
private final SampleRepository sampleRepository;
|
||||
|
||||
public List<SampleResponse> getAllSamples() {
|
||||
return sampleRepository.findAll().stream()
|
||||
.map(this::toResponse)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public SampleResponse getSampleById(Long id) {
|
||||
SampleEntity entity = sampleRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Sample", id));
|
||||
return toResponse(entity);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public SampleResponse createSample(SampleRequest request) {
|
||||
SampleEntity entity = SampleEntity.builder()
|
||||
.name(request.name())
|
||||
.description(request.description())
|
||||
.build();
|
||||
SampleEntity saved = sampleRepository.save(entity);
|
||||
return toResponse(saved);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public SampleResponse updateSample(Long id, SampleRequest request) {
|
||||
SampleEntity entity = sampleRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException("Sample", id));
|
||||
entity.setName(request.name());
|
||||
entity.setDescription(request.description());
|
||||
return toResponse(sampleRepository.save(entity));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteSample(Long id) {
|
||||
if (!sampleRepository.existsById(id)) {
|
||||
throw new ResourceNotFoundException("Sample", id);
|
||||
}
|
||||
sampleRepository.deleteById(id);
|
||||
}
|
||||
|
||||
private SampleResponse toResponse(SampleEntity entity) {
|
||||
return new SampleResponse(entity.getId(), entity.getName(), entity.getDescription());
|
||||
}
|
||||
}
|
||||
75
spring-migration/src/main/resources/application.yml
Normal file
75
spring-migration/src/main/resources/application.yml
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
# Spring Boot Application Configuration
|
||||
# Spring Boot 전환 후 application.properties → application.yml 변환 예시
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: spring-migration-sample
|
||||
|
||||
# H2 Database Configuration (Development)
|
||||
datasource:
|
||||
url: jdbc:h2:mem:sampledb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
|
||||
driver-class-name: org.h2.Driver
|
||||
username: sa
|
||||
password:
|
||||
|
||||
# JPA/Hibernate Configuration
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: create-drop
|
||||
show-sql: true
|
||||
properties:
|
||||
hibernate:
|
||||
format_sql: true
|
||||
dialect: org.hibernate.dialect.H2Dialect
|
||||
|
||||
# H2 Console (Development only)
|
||||
h2:
|
||||
console:
|
||||
enabled: true
|
||||
path: /h2-console
|
||||
|
||||
# Server Configuration
|
||||
server:
|
||||
port: 8080
|
||||
servlet:
|
||||
context-path: /
|
||||
|
||||
# Actuator Configuration
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health,info,metrics
|
||||
endpoint:
|
||||
health:
|
||||
show-details: when_authorized
|
||||
|
||||
# Logging Configuration
|
||||
logging:
|
||||
level:
|
||||
root: INFO
|
||||
com.example.migration: DEBUG
|
||||
org.springframework.web: DEBUG
|
||||
org.hibernate.SQL: DEBUG
|
||||
|
||||
---
|
||||
# Production Profile
|
||||
spring:
|
||||
config:
|
||||
activate:
|
||||
on-profile: prod
|
||||
datasource:
|
||||
url: jdbc:h2:file:./data/sampledb;DB_CLOSE_DELAY=-1
|
||||
username: ${DB_USERNAME:sa}
|
||||
password: ${DB_PASSWORD:}
|
||||
jpa:
|
||||
hdl-auto: validate
|
||||
show-sql: false
|
||||
h2:
|
||||
console:
|
||||
enabled: false
|
||||
|
||||
logging:
|
||||
level:
|
||||
root: WARN
|
||||
com.example.migration: INFO
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.example.migration;
|
||||
|
||||
import com.example.migration.controller.SampleController;
|
||||
import com.example.migration.service.SampleService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.security.test.context.support.WithMockUser;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* Spring Boot Application 및 Controller 테스트
|
||||
*/
|
||||
@WebMvcTest(SampleController.class)
|
||||
class SpringMigrationApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
private SampleService sampleService;
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
// Application Context 로드 테스트
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithMockUser
|
||||
void getAllSamples_ReturnsListOfSamples() throws Exception {
|
||||
when(sampleService.getAllSamples()).thenReturn(List.of(
|
||||
new com.example.migration.dto.SampleResponse(1L, "Test 1", "Description 1"),
|
||||
new com.example.migration.dto.SampleResponse(2L, "Test 2", "Description 2")
|
||||
));
|
||||
|
||||
mockMvc.perform(get("/api/samples"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.success").value(true))
|
||||
.andExpect(jsonPath("$.data").isArray())
|
||||
.andExpect(jsonPath("$.data.length()").value(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSamples_WithoutAuth_ReturnsUnauthorized() throws Exception {
|
||||
mockMvc.perform(get("/api/samples"))
|
||||
.andExpect(status().isUnauthorized());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue