-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/test/java/com/seoultech/synergybe/domain/common/idgenerator/IdGeneratorUUIDTest.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,33 @@ | ||
package com.seoultech.synergybe.domain.common.idgenerator; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@SpringBootTest | ||
public class IdGeneratorUUIDTest { | ||
@Autowired | ||
IdGenerator idGenerator; | ||
|
||
@Test | ||
void generateUUID() { | ||
// List<String> list = new ArrayList<>(); | ||
|
||
for (int i = 0; i < 100; i++) { | ||
String postId = idGenerator.generateId(IdPrefix.POST); | ||
System.out.println("postId : " + i + " 번째 : "+ postId); | ||
// list.add(postId); | ||
} | ||
|
||
|
||
|
||
// assertThat() | ||
} | ||
|
||
|
||
} |
67 changes: 67 additions & 0 deletions
67
src/test/java/com/seoultech/synergybe/domain/post/PostGeneratorTest.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.seoultech.synergybe.domain.post; | ||
|
||
import com.seoultech.synergybe.domain.common.CustomPasswordEncoder; | ||
import com.seoultech.synergybe.domain.common.idgenerator.IdGenerator; | ||
import com.seoultech.synergybe.domain.common.idgenerator.IdPrefix; | ||
import com.seoultech.synergybe.domain.post.implement.PostFactory; | ||
import com.seoultech.synergybe.domain.post.implement.PostManager; | ||
import com.seoultech.synergybe.domain.user.User; | ||
import com.seoultech.synergybe.domain.user.repository.UserRepository; | ||
import com.seoultech.synergybe.domain.user.service.UserService; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@SpringBootTest | ||
public class PostGeneratorTest { | ||
private static final int TEST_COUNT = 10000; | ||
|
||
@Autowired | ||
CustomPasswordEncoder passwordEncoder; | ||
|
||
@Autowired | ||
IdGenerator idGenerator; | ||
|
||
@Autowired | ||
PostManager postManager; | ||
|
||
@Autowired | ||
UserRepository userRepository; | ||
|
||
|
||
@Test | ||
void generatePost() { | ||
User user = User.builder() | ||
.id("user-id") | ||
.password("3e4r5t6y6y7u") | ||
.passwordEncoder(passwordEncoder) | ||
.email("email@email.com") | ||
.name("jonghun") | ||
.major("cs") | ||
.build(); | ||
userRepository.save(user); | ||
|
||
assertThat("email@email.com").isEqualTo(user.getEmail().getEmail()); | ||
|
||
List<Post> postList = new ArrayList<>(); | ||
|
||
|
||
for (int i = 0; i < 10000; i++) { | ||
String postId = idGenerator.generateId(IdPrefix.POST); | ||
Post post = Post.builder() | ||
.id(postId) | ||
.user(user) | ||
.title("title") | ||
.content("content") | ||
.build(); | ||
postList.add(post); | ||
|
||
} | ||
postManager.saveAll(postList); | ||
} | ||
} |