mirror of
https://github.com/valitydev/file-storage.git
synced 2024-11-06 00:35:22 +00:00
parent
558c4d81af
commit
7d4e97ea75
8
pom.xml
8
pom.xml
@ -106,16 +106,10 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.benas</groupId>
|
||||
<artifactId>random-beans</artifactId>
|
||||
<version>3.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
<artifactId>testcontainers-annotations</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.2.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -35,7 +35,7 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import static com.rbkmoney.file.storage.msgpack.Value.*;
|
||||
import static com.rbkmoney.file.storage.util.PrimitiveGeneratorUtil.*;
|
||||
import static com.rbkmoney.testcontainers.annotations.util.ValuesGenerator.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
|
@ -1,73 +0,0 @@
|
||||
package com.rbkmoney.file.storage.util;
|
||||
|
||||
import com.rbkmoney.geck.common.util.TypeUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.testcontainers.shaded.org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
|
||||
import static com.rbkmoney.file.storage.util.RandomBeans.random;
|
||||
import static java.time.LocalDateTime.now;
|
||||
import static java.time.ZoneId.systemDefault;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public abstract class PrimitiveGeneratorUtil {
|
||||
|
||||
private final LocalDateTime fromTime = LocalDateTime.now().minusHours(3);
|
||||
private final LocalDateTime toTime = LocalDateTime.now().minusHours(1);
|
||||
private final LocalDateTime inFromToPeriodTime = LocalDateTime.now().minusHours(2);
|
||||
|
||||
public static String generateDate() {
|
||||
return TypeUtil.temporalToString(LocalDateTime.now());
|
||||
}
|
||||
|
||||
public static Long generateLong() {
|
||||
return random(Long.class);
|
||||
}
|
||||
|
||||
public static Integer generateInt() {
|
||||
return random(Integer.class);
|
||||
}
|
||||
|
||||
public static String generateString() {
|
||||
return random(String.class);
|
||||
}
|
||||
|
||||
public static LocalDateTime generateLocalDateTime() {
|
||||
return random(LocalDateTime.class);
|
||||
}
|
||||
|
||||
public static Instant generateCurrentTimePlusDay() {
|
||||
return now().plusDays(1).toInstant(getZoneOffset());
|
||||
}
|
||||
|
||||
public static ZoneOffset getZoneOffset() {
|
||||
return systemDefault().getRules().getOffset(now());
|
||||
}
|
||||
|
||||
public static String getContent(InputStream content) throws IOException {
|
||||
return IOUtils.toString(content, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public LocalDateTime getFromTime() {
|
||||
return fromTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getToTime() {
|
||||
return toTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getInFromToPeriodTime() {
|
||||
return inFromToPeriodTime;
|
||||
}
|
||||
|
||||
public static Instant generateCurrentTimePlusSecond() {
|
||||
return LocalDateTime.now().plusSeconds(1).toInstant(getZoneOffset());
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.rbkmoney.file.storage.util;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static io.github.benas.randombeans.EnhancedRandomBuilder.aNewEnhancedRandom;
|
||||
|
||||
public class RandomBeans {
|
||||
|
||||
public static <T> T random(Class<T> type, String... excludedFields) {
|
||||
return aNewEnhancedRandom().nextObject(type, excludedFields);
|
||||
}
|
||||
|
||||
public static <T> Stream<T> randomStreamOf(int amount, Class<T> type, String... excludedFields) {
|
||||
return aNewEnhancedRandom().objects(type, amount, excludedFields);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user