Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/mainline-merge.yml
  • Loading branch information
mechakdotdev committed Nov 23, 2024
2 parents 129d063 + 6f8c6a4 commit ca791ad
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Merge Dev into Main
name: Mainline merge

on:
workflow_dispatch:
Expand Down Expand Up @@ -36,4 +36,4 @@ jobs:
git checkout main
git pull origin main
git merge --no-ff origin/development -m "GitHub Action: Merge development branch into main"
git push --force origin main
git push origin main
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Continuous Integration
name: TaskManager CI

on:
push:
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/taskmanager/dto/TaskDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import lombok.*;

import java.util.Date;
import java.time.LocalDate;
import java.util.List;

@Data
Expand All @@ -13,6 +13,6 @@ public class TaskDTO {
private List<Long> labelIds;
private String title;
private Integer priority;
private Date dueDate;
private LocalDate dueDate;
private String description;
}
6 changes: 3 additions & 3 deletions src/main/java/taskmanager/entity/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import jakarta.persistence.*;
import lombok.*;

import java.util.Date;
import java.time.LocalDate;
import java.util.List;

@Entity
Expand All @@ -23,7 +23,7 @@ public class Task {

@OneToMany(fetch = FetchType.LAZY, mappedBy = "task")
@NonNull
private List<Label> label;
private List<Label> labels;

@NonNull
private String title;
Expand All @@ -32,7 +32,7 @@ public class Task {
private Integer priority;

@NonNull
private Date dueDate;
private LocalDate dueDate;

@NonNull
private String description;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/taskmanager/mapper/TaskMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static TaskDTO toDto(Task task) {
return new TaskDTO(
task.getId(),
task.getProject().getId(),
task.getLabel().stream().map(Label::getId).collect(Collectors.toList()),
task.getLabels().stream().map(Label::getId).collect(Collectors.toList()),
task.getTitle(),
task.getPriority(),
task.getDueDate(),
Expand Down
109 changes: 109 additions & 0 deletions src/test/java/taskmanager/mapper/TaskMapperTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package taskmanager.mapper;

import org.junit.jupiter.api.Test;

import taskmanager.dto.TaskDTO;
import taskmanager.entity.Label;
import taskmanager.entity.Project;
import taskmanager.entity.Task;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

import static org.junit.jupiter.api.Assertions.*;

class TaskMapperTests {

@Test
void Should_MapTaskEntityToDto() {
// Arrange
Task task = getTask();
List<Long> taskLabelIds = getLabelIds(task.getLabels());

// Act
TaskDTO taskDTO = TaskMapper.toDto(task);

// Assert
assertNotNull(taskDTO);
assertEquals(task.getId(), taskDTO.getId());
assertEquals(task.getProject().getId(), taskDTO.getProjectId());
assertEquals(taskLabelIds, taskDTO.getLabelIds());
assertEquals(task.getTitle(), taskDTO.getTitle());
assertEquals(task.getPriority(), taskDTO.getPriority());
assertEquals(task.getDueDate(), taskDTO.getDueDate());
assertEquals(task.getDescription(), taskDTO.getDescription());
}

@Test
void Should_MapTaskDtoToTaskEntity() {
// Arrange
var project = new Project();
project.setId(23456L);

List<Label> labels = getLabelList(List.of(34567L, 45678L));
TaskDTO taskDto = getTaskDto(project, labels);

// Act
Task taskEntity = TaskMapper.toEntity(taskDto, project, labels);

// Assert
assertNotNull(taskEntity);
assertEquals(taskDto.getId(), taskEntity.getId());
assertEquals(project, taskEntity.getProject());
assertEquals(labels, taskEntity.getLabels());
assertEquals(taskDto.getTitle(), taskEntity.getTitle());
assertEquals(taskDto.getPriority(), taskEntity.getPriority());
assertEquals(taskDto.getDueDate(), taskEntity.getDueDate());
assertEquals(taskDto.getDescription(), taskEntity.getDescription());
}

private static List<Label> getLabelList(List<Long> labelIds) {
List<Label> labels = new ArrayList<>();

for (Long labelId : labelIds) {
var label = new Label();
label.setId(labelId);
labels.add(label);
}

return labels;
}

private static Task getTask() {
var project = new Project();
project.setId(12345L);

List<Label> labels = getLabelList(List.of(34567L, 45678L));

Task task = new Task(
project,
labels,
"Sample Task One",
5,
LocalDate.of(2024, 1, 1),
"This is the first sample task."
);
task.setId(10L);

return task;
}

private static TaskDTO getTaskDto(Project project, List<Label> labels) {
List<Long> labelIds = getLabelIds(labels);

return new TaskDTO(
12345L,
project.getId(),
labelIds,
"Sample Task Two",
5,
LocalDate.of(2024, 1, 1),
"This is the second sample task."
);
}

private static List<Long> getLabelIds(List<Label> labels) {
return labels.stream().map(Label::getId).toList();
}
}

0 comments on commit ca791ad

Please sign in to comment.