Skip to content

Commit

Permalink
added test for team
Browse files Browse the repository at this point in the history
  • Loading branch information
miguel-merlin committed Nov 23, 2024
1 parent bba6fdf commit 254394f
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jacocoTestReport {
violationRules {
rule {
limit {
minimum = 0.10
minimum = 0.05
}
}
}
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/sitblueprint/admin/dtos/MemberSummaryDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.sitblueprint.admin.dtos;

import com.sitblueprint.admin.model.users.Role;
import java.time.LocalDate;
import java.util.Set;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class MemberSummaryDTO {
private Long id;
private String name;
private String username;
private String email;
private boolean isActive;
private LocalDate dateJoined;
private Set<Role> roles;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sitblueprint.admin.dtos.member;
package com.sitblueprint.admin.dtos;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sitblueprint.admin.dtos.member;
package com.sitblueprint.admin.dtos;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sitblueprint.admin.dtos.member;

import com.sitblueprint.admin.dtos.TeamSummaryDTO;
import com.sitblueprint.admin.model.users.Member;
import com.sitblueprint.admin.model.users.Role;
import java.time.LocalDate;
Expand All @@ -24,7 +25,7 @@ public class MemberDTO {
private boolean isActive;
private LocalDate dateJoined;
private Set<RoleDTO> roles;
TeamSummaryDTO team;
private TeamSummaryDTO team;

public Member toEntity() {
return Member.builder().id(this.id).name(this.name).username(this.username).email(this.email)
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/com/sitblueprint/admin/dtos/team/TeamDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.sitblueprint.admin.dtos.team;

import com.sitblueprint.admin.dtos.MemberSummaryDTO;
import com.sitblueprint.admin.dtos.OrganizationSummaryDTO;
import com.sitblueprint.admin.model.users.Team;
import java.time.LocalDate;
import java.util.Set;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class TeamDTO {
private Long id;
private String name;
private OrganizationSummaryDTO organizationSummaryDTO;
private MemberSummaryDTO teamLead;
private MemberSummaryDTO projectManager;
private MemberSummaryDTO designer;
private LocalDate dateCreated;
private Set<MemberSummaryDTO> members;

public Team toEntity() {
return Team.builder()
.id(this.id)
.name(this.name)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ public class Attendance {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
private User user;
private Member user;
}
4 changes: 2 additions & 2 deletions src/main/java/com/sitblueprint/admin/model/users/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.sitblueprint.admin.dtos.member.MemberDTO;
import com.sitblueprint.admin.dtos.member.OrganizationSummaryDTO;
import com.sitblueprint.admin.dtos.OrganizationSummaryDTO;
import com.sitblueprint.admin.dtos.member.RoleDTO;
import com.sitblueprint.admin.dtos.member.TeamSummaryDTO;
import com.sitblueprint.admin.dtos.TeamSummaryDTO;
import jakarta.persistence.*;
import java.time.LocalDate;
import java.util.Collection;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/sitblueprint/admin/model/users/Team.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@Getter
@NoArgsConstructor
@AllArgsConstructor
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@Builder
public class Team {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@
public class TeamServiceImpl implements TeamService {
private final TeamRepository teamRepository;
private final AttendanceRepository attendanceRepository;
private final MemberRepository memberRepository;

public TeamServiceImpl(TeamRepository teamRepository, AttendanceRepository attendanceRepository,
MemberRepository memberRepository) {
public TeamServiceImpl(TeamRepository teamRepository, AttendanceRepository attendanceRepository) {
this.teamRepository = teamRepository;
this.attendanceRepository = attendanceRepository;
this.memberRepository = memberRepository;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class MemberServiceTest {
@Mock
private TokenService tokenService;

private MemberServiceImpl memberService;
private MemberService memberService;
private Member testMember;
private MemberDTO testMemberDTO;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.sitblueprint.admin.service.users;

import com.sitblueprint.admin.model.users.Team;
import com.sitblueprint.admin.repository.users.AttendanceRepository;
import com.sitblueprint.admin.repository.users.TeamRepository;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
public class TeamServiceTest {
@Mock
TeamRepository teamRepository;

@Mock
AttendanceRepository attendanceRepository;

private TeamService teamService;
private Team testTeam;
}

0 comments on commit 254394f

Please sign in to comment.