Skip to content

Commit

Permalink
[DDING-000] VodProcessingJob 필드 수정 (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
5uhwann authored Jan 9, 2025
1 parent af4c6be commit 07ad473
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ public record CreatePendingVodProcessingJobRequest(
@UUID
String convertJobId,
@NotNull(message = "userId는 필수입니다.")
String userId
String userId,
@NotNull(message = "파일Id는 빌수입니다.")
@UUID
String fileId
) {

public CreatePendingVodProcessingJobCommand toCommand() {
return new CreatePendingVodProcessingJobCommand(convertJobId, userId);
return new CreatePendingVodProcessingJobCommand(convertJobId, userId, fileId);
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ddingdong.ddingdongBE.domain.vodprocessing.entity;

import ddingdong.ddingdongBE.common.BaseEntity;
import ddingdong.ddingdongBE.domain.filemetadata.entity.FileMetaData;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
Expand Down Expand Up @@ -29,6 +30,10 @@ public class VodProcessingJob extends BaseEntity {
@JoinColumn(name = "notification_id")
private VodProcessingNotification vodProcessingNotification;

@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "file_meta_data_id")
private FileMetaData fileMetaData;

@Column(nullable = false)
private String convertJobId;

Expand All @@ -39,10 +44,11 @@ public class VodProcessingJob extends BaseEntity {
private ConvertJobStatus convertJobStatus;

@Builder
private VodProcessingJob(Long id, VodProcessingNotification vodProcessingNotification, String convertJobId,
String userId, ConvertJobStatus convertJobStatus) {
private VodProcessingJob(Long id, VodProcessingNotification vodProcessingNotification, FileMetaData fileMetaData,
String convertJobId, String userId, ConvertJobStatus convertJobStatus) {
this.id = id;
this.vodProcessingNotification = vodProcessingNotification;
this.fileMetaData = fileMetaData;
this.convertJobId = convertJobId;
this.userId = userId;
this.convertJobStatus = convertJobStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ddingdong.ddingdongBE.domain.vodprocessing.service;

import ddingdong.ddingdongBE.domain.filemetadata.entity.FileMetaData;
import ddingdong.ddingdongBE.domain.filemetadata.service.FileMetaDataService;
import ddingdong.ddingdongBE.domain.vodprocessing.entity.VodProcessingJob;
import ddingdong.ddingdongBE.domain.vodprocessing.service.dto.command.CreatePendingVodProcessingJobCommand;
import ddingdong.ddingdongBE.domain.vodprocessing.service.dto.command.UpdateVodProcessingJobStatusCommand;
Expand All @@ -13,11 +15,13 @@
public class FacadeVodProcessingJobServiceImpl implements FacadeVodProcessingJobService {

private final VodProcessingJobService vodProcessingJobService;
private final FileMetaDataService fileMetaDataService;

@Override
@Transactional
public Long create(CreatePendingVodProcessingJobCommand command) {
return vodProcessingJobService.save(command.toPendingVodProcessingJob());
FileMetaData fileMetaData = fileMetaDataService.getById(command.fileId());
return vodProcessingJobService.save(command.toPendingVodProcessingJob(fileMetaData));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package ddingdong.ddingdongBE.domain.vodprocessing.service.dto.command;

import ddingdong.ddingdongBE.domain.filemetadata.entity.FileMetaData;
import ddingdong.ddingdongBE.domain.vodprocessing.entity.ConvertJobStatus;
import ddingdong.ddingdongBE.domain.vodprocessing.entity.VodProcessingJob;

public record CreatePendingVodProcessingJobCommand(
String convertJobId,
String userId
String userId,
String fileId
) {

public VodProcessingJob toPendingVodProcessingJob() {
public VodProcessingJob toPendingVodProcessingJob(FileMetaData fileMetaData) {
return VodProcessingJob.builder()
.convertJobId(convertJobId)
.fileMetaData(fileMetaData)
.userId(userId)
.convertJobStatus(ConvertJobStatus.PENDING)
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ALTER TABLE vod_processing_job
ADD file_meta_data_id BINARY(16) NULL;

ALTER TABLE vod_processing_job
ADD CONSTRAINT UK_VOD_PROCESSING_JOB_FILE_META_DATA UNIQUE (file_meta_data_id);

ALTER TABLE vod_processing_job
ADD CONSTRAINT FK_VOD_PROCESSING_JOB_FILE_META_DATA_FILE_META_DATA_ID FOREIGN KEY (file_meta_data_id) REFERENCES file_meta_data (id);
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import static ddingdong.ddingdongBE.domain.vodprocessing.entity.ConvertJobStatus.PENDING;
import static org.assertj.core.api.Assertions.assertThat;

import com.github.f4b6a3.uuid.UuidCreator;
import ddingdong.ddingdongBE.common.support.TestContainerSupport;
import ddingdong.ddingdongBE.domain.filemetadata.entity.FileMetaData;
import ddingdong.ddingdongBE.domain.filemetadata.repository.FileMetaDataRepository;
import ddingdong.ddingdongBE.domain.vodprocessing.entity.VodProcessingJob;
import ddingdong.ddingdongBE.domain.vodprocessing.repository.VodProcessingJobRepository;
import ddingdong.ddingdongBE.domain.vodprocessing.service.dto.command.CreatePendingVodProcessingJobCommand;
import ddingdong.ddingdongBE.domain.vodprocessing.service.dto.command.UpdateVodProcessingJobStatusCommand;
import java.util.Optional;
import java.util.UUID;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -22,33 +26,41 @@ class FacadeGeneralVodProcessingJobServiceTest extends TestContainerSupport {
private FacadeVodProcessingJobService facadeVodProcessingJobService;
@Autowired
private VodProcessingJobRepository vodProcessingJobRepository;
@Autowired
private FileMetaDataRepository fileMetaDataRepository;

@DisplayName("VodProcessingJob 생성: PENDING")
@Test
void createPendingVodProcessingJob() {
//given
UUID fileId = UuidCreator.getTimeBased();
FileMetaData fileMetaData = FileMetaData.createPending(fileId, "test", "test");
FileMetaData savedFileMetaData = fileMetaDataRepository.save(fileMetaData);

String convertJobId = "testId";
String userId = "testId";
CreatePendingVodProcessingJobCommand command = new CreatePendingVodProcessingJobCommand(
convertJobId, userId);

CreatePendingVodProcessingJobCommand command =
new CreatePendingVodProcessingJobCommand(convertJobId, userId, savedFileMetaData.getId().toString());
//when
Long createdPendingVodProcessingJobId = facadeVodProcessingJobService.create(command);

//then
Optional<VodProcessingJob> result = vodProcessingJobRepository.findById(createdPendingVodProcessingJobId);
assertThat(result).isPresent();
assertThat(result.get())
.extracting(VodProcessingJob::getConvertJobId, VodProcessingJob::getUserId,
.extracting(
VodProcessingJob::getConvertJobId,
VodProcessingJob::getUserId,
VodProcessingJob::getConvertJobStatus)
.containsExactly(convertJobId, userId, PENDING);
assertThat(result.get().getFileMetaData().getId()).isEqualTo(fileId);
}

@DisplayName("CodProcessingJob 상태를 변경한다.")
@Test
void updateVodProcessingJobStatus() {
//given
VodProcessingJob savedVodProcessingJob = vodProcessingJobRepository.save(VodProcessingJob.builder()
vodProcessingJobRepository.save(VodProcessingJob.builder()
.convertJobStatus(PENDING)
.userId("1")
.convertJobId("test")
Expand Down

0 comments on commit 07ad473

Please sign in to comment.