-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] MemberController Logic Complete
- Loading branch information
1 parent
d95bede
commit 87502cc
Showing
7 changed files
with
87 additions
and
26 deletions.
There are no files selected for viewing
9 changes: 6 additions & 3 deletions
9
backend/src/main/java/com/twtw/backend/config/database/QuerydslConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
package com.twtw.backend.config.database; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
|
||
import jakarta.persistence.EntityManager; | ||
|
||
import jakarta.persistence.PersistenceContext; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class QuerydslConfig { | ||
@PersistenceContext | ||
private EntityManager entityManager; | ||
|
||
@Bean | ||
public JPAQueryFactory jpaQueryFactory(final EntityManager entityManager) { | ||
public JPAQueryFactory jpaQueryFactory() { | ||
return new JPAQueryFactory(entityManager); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
backend/src/test/java/com/twtw/backend/group/GroupTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.twtw.backend.group; | ||
|
||
import com.twtw.backend.config.database.QuerydslConfig; | ||
import com.twtw.backend.domain.group.entity.Group; | ||
import com.twtw.backend.domain.group.entity.GroupMember; | ||
import com.twtw.backend.domain.group.repository.GroupMemberRepository; | ||
import com.twtw.backend.domain.group.repository.GroupRepository; | ||
import com.twtw.backend.domain.member.entity.AuthType; | ||
import com.twtw.backend.domain.member.entity.Member; | ||
import com.twtw.backend.domain.member.entity.OAuth2Info; | ||
import com.twtw.backend.domain.member.repository.MemberRepository; | ||
import jakarta.persistence.EntityNotFoundException; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
|
||
@DataJpaTest | ||
@ActiveProfiles("test") | ||
@Import(QuerydslConfig.class) | ||
public class GroupTest { | ||
@Autowired | ||
private GroupRepository groupRepository; | ||
|
||
@Autowired | ||
private GroupMemberRepository groupMemberRepository; | ||
|
||
@Autowired | ||
private MemberRepository memberRepository; | ||
|
||
@BeforeEach | ||
public void beforeEach(){ | ||
Member member = new Member("jinjooone","22222"); | ||
OAuth2Info info = new OAuth2Info("ADMIN",AuthType.KAKAO); | ||
member.updateOAuth(info); | ||
|
||
memberRepository.save(member); | ||
|
||
Group group = new Group("AAA","1111"); | ||
groupRepository.save(group); | ||
} | ||
|
||
@Test | ||
@Transactional | ||
void saveGroup(){ | ||
Member member = memberRepository.findByOAuthIdAndAuthType("ADMIN",AuthType.KAKAO).orElseThrow(EntityNotFoundException::new); | ||
Group group = new Group("HDJ","1111"); | ||
GroupMember groupMember = new GroupMember(group,member); | ||
Group regroup = groupRepository.save(group); | ||
} | ||
|
||
@Test | ||
@Transactional | ||
void joinGroup(){ | ||
|
||
} | ||
|
||
} |