-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
71 failed to execute goal generatetests while trying to generate cont…
…racts from an openapi yaml document (#73)
- Loading branch information
1 parent
b2b785b
commit 777a99d
Showing
8 changed files
with
461 additions
and
158 deletions.
There are no files selected for viewing
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
236 changes: 165 additions & 71 deletions
236
src/main/java/net/coru/multiapi/converter/asyncapi/AsyncApiContractConverter.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
44 changes: 44 additions & 0 deletions
44
src/main/java/net/coru/multiapi/converter/utils/RandomGenerator.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,44 @@ | ||
package net.coru.multiapi.converter.utils; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.ZoneOffset; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import org.apache.commons.lang3.RandomUtils; | ||
|
||
public final class RandomGenerator { | ||
|
||
private RandomGenerator() { | ||
} | ||
|
||
public static String getRandomDateTime() { | ||
return getRandomLocalDateTime().format(DateTimeFormatter.ISO_DATE_TIME); | ||
} | ||
|
||
public static String getRandomDate() { | ||
return getRandomLocalDateTime().format(DateTimeFormatter.ISO_DATE); | ||
} | ||
|
||
public static String getRandomTime() { | ||
return getRandomLocalDateTime().format(DateTimeFormatter.ISO_TIME); | ||
} | ||
|
||
public static String getRandomDateTimeOffset() { | ||
return getRandomLocalDateTime().format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); | ||
} | ||
|
||
private static LocalDateTime getRandomLocalDateTime() { | ||
final long minDay = LocalDateTime.of(1900, 1, 1, 0, 0).toEpochSecond(ZoneOffset.UTC); | ||
final long maxDay = LocalDateTime.of(2100, 1, 1, 0, 0).toEpochSecond(ZoneOffset.UTC); | ||
final long randomSeconds = minDay + RandomUtils.nextLong(0, maxDay - minDay); | ||
|
||
return LocalDateTime.ofEpochSecond(randomSeconds, RandomUtils.nextInt(0, 1_000_000_000 - 1), ZoneOffset.UTC); | ||
|
||
} | ||
|
||
public static String randomEnumValue(final JsonNode jsonNode) { | ||
final String[] enumValues = jsonNode.get("enum").asText().split(","); | ||
return enumValues[RandomUtils.nextInt(0, enumValues.length - 1)]; | ||
} | ||
} |
Oops, something went wrong.