Skip to content

Commit

Permalink
feat-be: 프로세스 삭제 (#38)
Browse files Browse the repository at this point in the history
* Create draft PR for #37

* feat: 프로세스 삭제
---------

Co-authored-by: cutehumanS2 <oddpinkjadeite@gmail.com>
Co-authored-by: 김형호 <140397285+HyungHoKim00@users.noreply.github.com>
Co-authored-by: Kwoun Ki Ho <73146678+Chocochip101@users.noreply.github.com>
  • Loading branch information
4 people authored and Dobby-Kim committed Jul 22, 2024
1 parent 00407ed commit d37430c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@ public ResponseEntity<Void> create(@RequestParam(name = "dashboard_id") Long das
processService.create(dashboardId, request);
return ResponseEntity.status(HttpStatus.CREATED).build();
}

@DeleteMapping("/{process_id}")
public ResponseEntity<Void> delete(@PathVariable(name = "process_id") Long processId) {
processService.delete(processId);
return ResponseEntity.noContent().build();
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/cruru/process/service/ProcessService.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,9 @@ public void create(long dashboardId, ProcessCreateRequest request) {
dashboardRepository.findById(dashboardId).orElseThrow())
);
}

@Transactional
public void delete(long processId) {
processRepository.deleteById(processId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,12 @@ void create() {
.when().post("/api/v1/processes?dashboard_id=" + dashboard.getId())
.then().log().all().statusCode(201);
}

@DisplayName("프로세스 삭제 성공 시, 204를 응답한다.")
@Test
void delete() {
RestAssured.given().log().all()
.when().delete("/api/v1/processes/" + process.getId())
.then().log().all().statusCode(204);
}
}
32 changes: 28 additions & 4 deletions src/test/java/com/cruru/process/service/ProcessServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import com.cruru.process.controller.dto.ProcessesResponse;
import com.cruru.process.domain.Process;
import com.cruru.process.domain.repository.ProcessRepository;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -26,17 +25,26 @@
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
class ProcessServiceTest {

@PersistenceContext
EntityManager em;
@Autowired
private DashboardRepository dashboardRepository;

@Autowired
private ProcessRepository processRepository;

@Autowired
private ApplicantRepository applicantRepository;

@Autowired
private ProcessService processService;

@BeforeEach
void setUp() {
applicantRepository.deleteAll();
processRepository.deleteAll();
dashboardRepository.deleteAll();
}


@DisplayName("ID에 해당하는 대시보드의 프로세스 목록과 지원자 정보를 조회한다.")
@Test
void findByDashboardId() {
Expand Down Expand Up @@ -93,4 +101,20 @@ void create() {
assertThat(allByDashboardId).hasSize(3);
assertThat(allByDashboardId.get(1).getName()).isEqualTo("면접");
}

@DisplayName("프로세스를 삭제한다.")
@Test
void delete() {
// given
Dashboard dashboard = new Dashboard("name", null);
dashboard = dashboardRepository.save(dashboard);
Process process1 = new Process(0, "name", "description", dashboard);
process1 = processRepository.save(process1);

// when
processService.delete(process1.getId());

// then
assertThat(processRepository.findAll()).hasSize(0);
}
}

0 comments on commit d37430c

Please sign in to comment.