Skip to content

Commit

Permalink
fix: remove JavaFaker library
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-touret committed Jan 31, 2024
1 parent fee0bb7 commit ce8fe44
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ project(':rest-number') {
implementation 'org.springframework.boot:spring-boot-starter-aop'
implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:${springdocVersion}"
implementation 'com.fasterxml.jackson.core:jackson-annotations'
implementation "com.github.javafaker:javafaker:${javaFakerVersion}"
implementation "org.yaml:snakeyaml:${snakeYamlVersion}"
implementation "org.mapstruct:mapstruct:${mapstructVersion}"
annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}"

Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ mapstructVersion=1.5.5.Final
springdocVersion=2.3.0
#springAuthServerVersion=1.0.0
javaFakerVersion=1.0.2
snakeYamlVersion=1.33
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package info.touret.bookstore.spring.number.service;

import com.github.javafaker.Faker;
import info.touret.bookstore.spring.number.exception.ISBNExecutionException;
import info.touret.bookstore.spring.number.generated.dto.BookNumbersDto;
import io.github.resilience4j.timelimiter.annotation.TimeLimiter;
Expand All @@ -10,9 +9,11 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.random.RandomGeneratorFactory;

@Service
public class BookNumbersService {
Expand Down Expand Up @@ -54,13 +55,14 @@ public BookNumbersDto createBookNumbers() {
throw new ISBNExecutionException(e);
}

Faker faker = new Faker();
var randomGenerator = RandomGeneratorFactory.getDefault().create();
var random = Random.from(randomGenerator);
BookNumbersDto bookNumbers = new BookNumbersDto();
bookNumbers.setIsbn10(faker.code().isbn10(separator));
bookNumbers.setIsbn13(faker.code().isbn13(separator));
bookNumbers.setAsin(faker.code().asin());
bookNumbers.setEan8(faker.code().ean8());
bookNumbers.setEan13(faker.code().ean13());
bookNumbers.setIsbn10(String.valueOf(random.nextLong(1_000_000_000,9_999_999_999L)));
bookNumbers.setIsbn13(String.valueOf(random.nextLong(1000_000_000_000L,9999_999_999_999L)));
bookNumbers.setAsin(String.valueOf(random.nextLong(1_000_000_000,9_999_999_999L)));
bookNumbers.setEan8(String.valueOf(random.nextLong(1_000_000_0,9_999_999_9L)));
bookNumbers.setEan13(String.valueOf(random.nextLong(1000_000_000_000L,9999_999_999_999L)));
return bookNumbers;
}

Expand Down

0 comments on commit ce8fe44

Please sign in to comment.