Skip to content

Commit

Permalink
#117 test: 객체 ID 생성기 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
rivkode committed Sep 3, 2024
1 parent 115f626 commit 28c60a8
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class TokenGeneratorUUIDTest {
@Autowired
TokenGenerator tokenGenerator;

@DisplayName("객체 ID 1만개 생성시 1초 이내로 실행된다.")
@Test
void generateLongId() {
List<Long> longList = new ArrayList<>();
Expand All @@ -27,18 +28,18 @@ void generateLongId() {

for (int i = 0; i < 10000; i++) {
Long longId = idGenerator.generateId();
System.out.println("longId : " + i + " 번째 : "+ longId);
longList.add(longId);

}

// test end
long endTime = System.currentTimeMillis();
System.out.println("longId Total execution time: " + (endTime - startTime) + " milliseconds");
long elapsedTime = endTime - startTime;

assertThat(longList.size()).isEqualTo(10000);
// test end
assertThat(longList).hasSize(10000);
assertThat(elapsedTime).isLessThanOrEqualTo(1000);
}

@DisplayName("대체키 ID 1만개 생성시 3초 이내로 실행된다.")
@Test
void generateStringId() {
List<String> stringList = new ArrayList<>();
Expand All @@ -48,16 +49,14 @@ void generateStringId() {

for (int i = 0; i < 10000; i++) {
String stringId = tokenGenerator.generateToken(IdPrefix.POST);
System.out.println("stringId : " + i + " 번째 : "+ stringId);
stringList.add(stringId);
}

// test end
long endTime = System.currentTimeMillis();
System.out.println("stringId Total execution time: " + (endTime - startTime) + " milliseconds");
long elapsedTime = endTime - startTime;

assertThat(stringList.size()).isEqualTo(10000);
assertThat(stringList).hasSize(10000);
assertThat(elapsedTime).isLessThanOrEqualTo(3000);
}


}

0 comments on commit 28c60a8

Please sign in to comment.