Skip to content

Commit

Permalink
test: RoadmapNodes 테스트코드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Ohjintaek committed Jan 21, 2024
1 parent bdccbbc commit 5cf8113
Showing 1 changed file with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import org.junit.jupiter.api.Test;

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

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertAll;

class RoadmapNodesTest {

Expand All @@ -23,7 +25,45 @@ class RoadmapNodesTest {
.hasMessage("한 로드맵에 같은 이름의 노드가 존재할 수 없습니다.");
}

// todo: RoadmapNodes 도메인 테스트 추가하기
@Test
void 로드맵_노드_아이디로_노드를_반환한다() {
// given
final RoadmapNode node1 = new RoadmapNode(1L, "title1", "content1");
final RoadmapNode node2 = new RoadmapNode(2L, "title2", "content2");
final RoadmapNodes roadmapNodes = new RoadmapNodes(List.of(node1, node2));

// when
final long findNodeId = 1;
final long notExistId = 3;
final Optional<RoadmapNode> foundNode1 = roadmapNodes.findById(findNodeId);
final Optional<RoadmapNode> foundNode2 = roadmapNodes.findById(notExistId);

// then
assertAll(
() -> assertThat(node1).isEqualTo(foundNode1.get()),
() -> assertThat(foundNode2).isEmpty()
);
}

@Test
void 로드맵_노드_제목으로_노드를_반환한다() {
// given
final RoadmapNode node1 = new RoadmapNode(1L, "title1", "content1");
final RoadmapNode node2 = new RoadmapNode(2L, "title2", "content2");
final RoadmapNodes roadmapNodes = new RoadmapNodes(List.of(node1, node2));

// when
final String findNodeTitle = "title1";
final String notExistTitle = "nothing";
final Optional<RoadmapNode> foundNode1 = roadmapNodes.findByTitle(findNodeTitle);
final Optional<RoadmapNode> foundNode2 = roadmapNodes.findByTitle(notExistTitle);

// then
assertAll(
() -> assertThat(node1).isEqualTo(foundNode1.get()),
() -> assertThat(foundNode2).isEmpty()
);
}

@Test
void 로드맵_노드를_한다() {
Expand Down

0 comments on commit 5cf8113

Please sign in to comment.