-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
๐จ test: OrganizationRepository ํ
์คํธ ์ฝ๋ ์์ฑ
- Loading branch information
Showing
2 changed files
with
106 additions
and
66 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
api/src/test/java/com/sponus/sponusbe/organization/OrganizationRepositoryTest.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,36 @@ | ||
package com.sponus.sponusbe.organization; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
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 com.sponus.coredomain.domain.organization.Organization; | ||
import com.sponus.coredomain.domain.organization.enums.OrganizationStatus; | ||
import com.sponus.coredomain.domain.organization.enums.OrganizationType; | ||
import com.sponus.coredomain.domain.organization.repository.OrganizationRepository; | ||
|
||
@Transactional | ||
@SpringBootTest | ||
public class OrganizationRepositoryTest { | ||
|
||
@Autowired | ||
OrganizationRepository organizationRepository; | ||
|
||
@Test | ||
void saveTest() { | ||
Organization entity = Organization.builder() | ||
.email("[email protected]") | ||
.name("test") | ||
.password("test1234#") | ||
.organizationType(OrganizationType.COMPANY) | ||
.organizationStatus(OrganizationStatus.ACTIVE) | ||
.build(); | ||
|
||
Organization savedEntity = organizationRepository.save(entity); | ||
|
||
Assertions.assertEquals(entity.getEmail(), savedEntity.getEmail()); | ||
} | ||
|
||
} |
136 changes: 70 additions & 66 deletions
136
api/src/test/java/com/sponus/sponusbe/organization/OrganizationServiceTest.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,66 +1,70 @@ | ||
package com.sponus.sponusbe.organization; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
|
||
import com.sponus.sponusbe.domain.organization.service.OrganizationService; | ||
|
||
@SpringBootTest | ||
@AutoConfigureMockMvc | ||
// @TestMethodOrder(MethodOrderer.OrderAnnotation.class) | ||
class OrganizationServiceTest { | ||
|
||
@Autowired | ||
MockMvc mockMvc; | ||
|
||
@Autowired | ||
OrganizationService organizationService; | ||
|
||
@Test | ||
void beanTest() { | ||
Assertions.assertNotNull(organizationService); | ||
} | ||
|
||
// @Order(1) | ||
// @Test | ||
// void joinTest() { | ||
// | ||
// // given | ||
// OrganizationJoinRequest request = new OrganizationJoinRequest("" | ||
// + "์คํฌ๋์ค ํ ์คํธ", "[email protected]", "password1234", OrganizationType.COMPANY, null); | ||
// | ||
// // when | ||
// OrganizationJoinResponse response = organizationService.join(request); | ||
// | ||
// // then | ||
// Assertions.assertEquals(request.name(), response.name()); | ||
// System.out.println("[*] ํ์๊ฐ์ ํ ์คํธ: " + response); | ||
// } | ||
// | ||
// @Order(2) | ||
// @Test | ||
// void loginTest() throws Exception { | ||
// | ||
// // given | ||
// String jsonRequest = "{" | ||
// + "\"email\": \"[email protected]\", " | ||
// + "\"password\": \"password1234\", " | ||
// + "\"fcmToken\": \"fcmTokenFcmTokenFcmTokenFcmTokenFcmTokenFcmTokenFcmTokenFcmTokenFcmTokenFcmTokenFcmTokenFcmToken\"" | ||
// + "}"; | ||
// | ||
// // when | ||
// MvcResult response = mockMvc.perform( | ||
// MockMvcRequestBuilders.post("/api/v1/organizations/login") | ||
// .contentType(MediaType.APPLICATION_JSON) | ||
// .content(jsonRequest)) // JSON ํ์์ ๋ฐ์ดํฐ๋ฅผ ๋ณธ๋ฌธ์ ์ถ๊ฐ | ||
// .andReturn(); | ||
// | ||
// // then | ||
// Assertions.assertEquals(HttpStatus.CREATED.value(), response.getResponse().getStatus()); | ||
// System.out.println("[*] ๋ก๊ทธ์ธ ํ ์คํธ: " + response.getResponse().getContentAsString()); | ||
// } | ||
} | ||
// package com.sponus.sponusbe.organization; | ||
// | ||
// import org.junit.jupiter.api.Assertions; | ||
// import org.junit.jupiter.api.MethodOrderer; | ||
// import org.junit.jupiter.api.Order; | ||
// import org.junit.jupiter.api.Test; | ||
// import org.junit.jupiter.api.TestMethodOrder; | ||
// import org.springframework.beans.factory.annotation.Autowired; | ||
// import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
// import org.springframework.boot.test.context.SpringBootTest; | ||
// import org.springframework.http.HttpStatus; | ||
// import org.springframework.http.MediaType; | ||
// import org.springframework.test.web.servlet.MockMvc; | ||
// import org.springframework.test.web.servlet.MvcResult; | ||
// import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; | ||
// | ||
// import com.sponus.coredomain.domain.organization.enums.OrganizationType; | ||
// import com.sponus.sponusbe.domain.organization.dto.OrganizationJoinRequest; | ||
// import com.sponus.sponusbe.domain.organization.dto.OrganizationJoinResponse; | ||
// import com.sponus.sponusbe.domain.organization.service.OrganizationService; | ||
// | ||
// @SpringBootTest | ||
// @AutoConfigureMockMvc | ||
// @TestMethodOrder(MethodOrderer.OrderAnnotation.class) | ||
// class OrganizationServiceTest { | ||
// | ||
// @Autowired | ||
// MockMvc mockMvc; | ||
// | ||
// OrganizationService organizationService; | ||
// | ||
// @Order(1) | ||
// @Test | ||
// void joinTest() { | ||
// | ||
// // given | ||
// OrganizationJoinRequest request = new OrganizationJoinRequest("" | ||
// + "์คํฌ๋์ค ํ ์คํธ", "[email protected]", "password1234", OrganizationType.COMPANY, null); | ||
// | ||
// // when | ||
// OrganizationJoinResponse response = organizationService.join(request); | ||
// | ||
// // then | ||
// Assertions.assertEquals(request.name(), response.name()); | ||
// System.out.println("[*] ํ์๊ฐ์ ํ ์คํธ: " + response); | ||
// } | ||
// | ||
// @Order(2) | ||
// @Test | ||
// void loginTest() throws Exception { | ||
// | ||
// // given | ||
// String jsonRequest = "{" | ||
// + "\"email\": \"[email protected]\", " | ||
// + "\"password\": \"password1234\", " | ||
// + "\"fcmToken\": \"fcmTokenFcmTokenFcmTokenFcmTokenFcmTokenFcmTokenFcmTokenFcmTokenFcmTokenFcmTokenFcmTokenFcmToken\"" | ||
// + "}"; | ||
// | ||
// // when | ||
// MvcResult response = mockMvc.perform( | ||
// MockMvcRequestBuilders.post("/api/v1/organizations/login") | ||
// .contentType(MediaType.APPLICATION_JSON) | ||
// .content(jsonRequest)) // JSON ํ์์ ๋ฐ์ดํฐ๋ฅผ ๋ณธ๋ฌธ์ ์ถ๊ฐ | ||
// .andReturn(); | ||
// | ||
// // then | ||
// Assertions.assertEquals(HttpStatus.CREATED.value(), response.getResponse().getStatus()); | ||
// System.out.println("[*] ๋ก๊ทธ์ธ ํ ์คํธ: " + response.getResponse().getContentAsString()); | ||
// } | ||
// } |