Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.mtvs.devlinkbackend.channel.dto.request;

import com.mtvs.devlinkbackend.channel.entity.Position;
import lombok.*;

import java.util.List;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Data
public class ChannelRegistRequestDTO {
private List<PositionType> positionTypes;
}
public class TileInfoRegistDTO {
private Position position;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.mtvs.devlinkbackend.channel.dto.response;

import com.mtvs.devlinkbackend.channel.entity.TileInfo;
import lombok.*;

import java.util.List;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class TileInfoListResponseDTO {
private List<TileInfo> data;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class Channel {
@Id
private String channelId;

private String channelName;

@CreatedDate
private LocalDateTime createdAt;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.mtvs.devlinkbackend.channel.entity;

import lombok.Data;

@Data
public class Position {
private float x;
private float y;
private float z;

public Position(float x, float y, float z) {
this.x = x;
this.y = y;
this.z = z;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.mtvs.devlinkbackend.channel.entity;

import jakarta.persistence.Id;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

@NoArgsConstructor
@Document
@Data
public class TileInfo {
@Id
private String tileId;

@Indexed
private String channelId;

@NotNull
@Field
private Position position;

public TileInfo(String channelId, Position position) {
this.channelId = channelId;
this.position = position;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.mtvs.devlinkbackend.channel.repository;

import com.mtvs.devlinkbackend.channel.entity.TileInfo;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface TileInfoRepository extends MongoRepository<TileInfo, String> {
void deleteAllByChannelId(String channelId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.mtvs.devlinkbackend.channel.repository;

import com.mtvs.devlinkbackend.channel.entity.TileInfo;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface TileInfoViewRepository extends MongoRepository<TileInfo, String> {
List<TileInfo> findAllByChannelId(String channelId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.mtvs.devlinkbackend.channel.service;

import com.mtvs.devlinkbackend.channel.dto.request.TileInfoRegistDTO;
import com.mtvs.devlinkbackend.channel.entity.TileInfo;
import com.mtvs.devlinkbackend.channel.repository.TileInfoRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class TileInfoService {


private final TileInfoRepository tileInfoRepository;

public TileInfoService(TileInfoRepository tileInfoRepository) {
this.tileInfoRepository = tileInfoRepository;
}

@Transactional
public TileInfoRegistDTO insertTileInfoByChannelId(TileInfoRegistDTO tileInfoRegistDTO, String channelId) {
TileInfo tileInfo = tileInfoRepository.save(new TileInfo(
channelId,
tileInfoRegistDTO.getPosition()
));

return tileInfoRegistDTO;
}

@Transactional
public void deleteTileInfoByChannelId(String channelId) {
tileInfoRepository.deleteAllByChannelId(channelId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.mtvs.devlinkbackend.channel.service;

import com.mtvs.devlinkbackend.channel.dto.response.TileInfoListResponseDTO;
import com.mtvs.devlinkbackend.channel.entity.TileInfo;
import com.mtvs.devlinkbackend.channel.repository.TileInfoViewRepository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TileInfoViewService {

private final TileInfoViewRepository tileInfoViewRepository;

public TileInfoViewService(TileInfoViewRepository tileInfoViewRepository) {
this.tileInfoViewRepository = tileInfoViewRepository;
}

public TileInfoListResponseDTO findTileInfoListByChannelId(String channelId) {
List<TileInfo> tileInfoList = tileInfoViewRepository.findAllByChannelId(channelId);
return new TileInfoListResponseDTO(tileInfoList);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class EvaluationCRUDTest {

@BeforeEach
void setUp() {
Dev dev = epicDevViewService.findAllDevsWithPagination(0).getData().get(0);
Dev dev = epicDevViewService.findAllDevsWithPagination(0).getData().get(0).getDevInfo();

skillCategoryInfo = new SkillCategoryInfo();
skillCategoryInfo.setEvaluationIdList(new ArrayList<>());
Expand All @@ -55,11 +55,11 @@ void registerEvaluation_shouldSaveEvaluation() {
// Given
EvaluationRegistRequestDTO request = new EvaluationRegistRequestDTO(
skillCategoryInfo.getCategoryInfoId(),
new Evaluation(1L,2L, "Good Job", 80, skillCategoryInfo)
new Evaluation(1L, "Good Job", 80, skillCategoryInfo)
);

// When
EvaluationSingleResponseDTO response = evaluationService.registerEvaluation(request,2L);
EvaluationSingleResponseDTO response = evaluationService.registerEvaluation(request,"");

// Then
assertThat(response).isNotNull();
Expand All @@ -70,13 +70,12 @@ void registerEvaluation_shouldSaveEvaluation() {
@Test
void updateEvaluation_shouldUpdateEvaluation() {
// Given
Evaluation existingEvaluation = new Evaluation(1L,2L, "Initial Cause", 70, skillCategoryInfo);
Evaluation existingEvaluation = new Evaluation(1L, "Initial Cause", 70, skillCategoryInfo);
evaluationRepository.save(existingEvaluation);

EvaluationUpdateRequestDTO updateRequest = new EvaluationUpdateRequestDTO(
existingEvaluation.getEvaluationId(),
existingEvaluation.getEstimatorId(),
existingEvaluation.getEstimatederId(),
existingEvaluation.getUserId(),
"Updated Cause",
85
);
Expand All @@ -93,7 +92,7 @@ void updateEvaluation_shouldUpdateEvaluation() {
@Test
void deleteById_shouldDeleteEvaluation() {
// Given
Evaluation evaluation = new Evaluation(1L, 2L,"To be deleted", 70, skillCategoryInfo);
Evaluation evaluation = new Evaluation(1L, "To be deleted", 70, skillCategoryInfo);
evaluationRepository.save(evaluation);

// When
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void applyMemberToGuildTest() {
GuildMemberModifyRequestDTO memberRequestDTO = new GuildMemberModifyRequestDTO(
responseDTO.getData().getGuildId(),
responseDTO.getData().getMasterUserId(),
List.of(new Member("Guild", 1L, 2L, "motive", AcceptStatus.PENDING))
List.of(new Member("Guild", 1L, 2L, "motive", 3L , AcceptStatus.PENDING))
);

var modifiedGuildDTO = guildService.applyMemberToGuild(memberRequestDTO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ public void testDeleteAll() {
public void testAcceptSupplyByMemberId() {
// given
Long memberId = 1L;
String accountId = "";
Member member = new Member();
when(memberRepository.findById(memberId)).thenReturn(Optional.of(member));

// when
MemberStatusResponseDTO responseDTO = memberService.acceptSupplyByMemberId(memberId);
MemberStatusResponseDTO responseDTO = memberService.acceptSupplyByMemberId(memberId, accountId);

// then
assertNotNull(responseDTO);
Expand All @@ -83,11 +84,12 @@ public void testAcceptSupplyByMemberId() {
public void testRejectSupplyByMemberId() {
// given
Long memberId = 1L;
String accountId = "";
Member member = new Member();
when(memberRepository.findById(memberId)).thenReturn(Optional.of(member));

// when
MemberStatusResponseDTO responseDTO = memberService.rejectSupplyByMemberId(memberId);
MemberStatusResponseDTO responseDTO = memberService.rejectSupplyByMemberId(memberId, accountId);

// then
assertNotNull(responseDTO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ void registProjectTest() {
// Given
ProjectRegistRequestDTO requestDTO = new ProjectRegistRequestDTO(1L, "Test Title", "Test Content", 1000, "in-progress", "both", null, null, null);
Project project = new Project(1L, "Test Title", "Test Content", "both", "in-progress", null, null, null, 1000);
String accountId = "";

when(projectRepository.save(ArgumentMatchers.any(Project.class))).thenReturn(project);

// When
ProjectSingleResponseDTO response = projectService.registProject(requestDTO);
ProjectSingleResponseDTO response = projectService.registProject(requestDTO, accountId);

// Then
assertThat(response).isNotNull();
Expand Down
84 changes: 84 additions & 0 deletions src/test/java/com/mtvs/devlinkbackend/crud/TileInfoCRDTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.mtvs.devlinkbackend.crud;

import com.mtvs.devlinkbackend.channel.dto.request.TileInfoRegistDTO;
import com.mtvs.devlinkbackend.channel.dto.response.TileInfoListResponseDTO;
import com.mtvs.devlinkbackend.channel.entity.Position;
import com.mtvs.devlinkbackend.channel.entity.TileInfo;
import com.mtvs.devlinkbackend.channel.repository.TileInfoRepository;
import com.mtvs.devlinkbackend.channel.repository.TileInfoViewRepository;
import com.mtvs.devlinkbackend.channel.service.TileInfoService;
import com.mtvs.devlinkbackend.channel.service.TileInfoViewService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest
@Transactional
class TileInfoCRDTest {

@Autowired
private TileInfoService tileInfoService;

@Autowired
private TileInfoRepository tileInfoRepository;
@Autowired
private TileInfoViewService tileInfoViewService;
@Autowired
private TileInfoViewRepository tileInfoViewRepository;

@Test
void testInsertTileInfoByChannelId() {
// Given
String channelId = "channel123";
TileInfoRegistDTO requestDTO = new TileInfoRegistDTO(new Position(10, 20, 30));

// When
tileInfoService.insertTileInfoByChannelId(requestDTO, channelId);

// Then
Optional<TileInfo> tileInfoOptional = tileInfoViewRepository.findAllByChannelId(channelId).stream().findFirst();
assertThat(tileInfoOptional).isPresent();
TileInfo tileInfo = tileInfoOptional.get();
assertThat(tileInfo.getChannelId()).isEqualTo(channelId);
assertThat(tileInfo.getPosition().getX()).isEqualTo(10);
assertThat(tileInfo.getPosition().getY()).isEqualTo(20);
assertThat(tileInfo.getPosition().getZ()).isEqualTo(30);
}

@Test
void testFindTileInfoListByChannelId() {
// Given
String channelId = "channel789";
tileInfoRepository.save(new TileInfo(channelId, new Position(10, 20, 30)));
tileInfoRepository.save(new TileInfo(channelId, new Position(40, 50, 60)));

// When
TileInfoListResponseDTO responseDTO = tileInfoViewService.findTileInfoListByChannelId(channelId);

// Then
List<TileInfo> tileInfoList = responseDTO.getData();
assertThat(tileInfoList).hasSize(2);
assertThat(tileInfoList.get(0).getChannelId()).isEqualTo(channelId);
assertThat(tileInfoList.get(1).getPosition().getX()).isEqualTo(40);
}

@Test
void testDeleteTileInfoByChannelId() {
// Given
String channelId = "channel456";
TileInfo tileInfo = tileInfoRepository.save(new TileInfo(channelId, new Position(15, 25, 35)));

// When
tileInfoService.deleteTileInfoByChannelId(channelId);

// Then
boolean exists = tileInfoViewRepository.findAllByChannelId(channelId).isEmpty();
assertThat(exists).isTrue();
}
}