-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #452 from medizininformatik-initiative/451-more-lo…
…gs-for-transfer-observability More Logs for CDA Transfer
- Loading branch information
Showing
4 changed files
with
61 additions
and
7 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package care.smith.fts.util; | ||
|
||
import static com.aventrix.jnanoid.jnanoid.NanoIdUtils.DEFAULT_ALPHABET; | ||
import static com.aventrix.jnanoid.jnanoid.NanoIdUtils.DEFAULT_NUMBER_GENERATOR; | ||
import static com.aventrix.jnanoid.jnanoid.NanoIdUtils.randomNanoId; | ||
|
||
public interface NanoIdUtils { | ||
|
||
static String nanoId(int size) { | ||
return randomNanoId(DEFAULT_NUMBER_GENERATOR, DEFAULT_ALPHABET, size); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
util/src/test/java/care/smith/fts/util/NanoIdUtilsTest.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,34 @@ | ||
package care.smith.fts.util; | ||
|
||
import static care.smith.fts.util.NanoIdUtils.nanoId; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType; | ||
|
||
import java.util.stream.IntStream; | ||
import java.util.stream.Stream; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
class NanoIdUtilsTest { | ||
private static Stream<Arguments> significantSizes() { | ||
return IntStream.rangeClosed(1, 21).mapToObj(Arguments::of); | ||
} | ||
|
||
@ParameterizedTest(name = "size of {0}") | ||
@MethodSource("significantSizes") | ||
public void idHasSpecifiedSize(int size) { | ||
assertThat(nanoId(size)).hasSize(size); | ||
} | ||
|
||
@Test | ||
public void zeroSizeNotAllowed() { | ||
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> nanoId(0)); | ||
} | ||
|
||
@Test | ||
public void negativeSizeNotAllowed() { | ||
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> nanoId(-1)); | ||
} | ||
} |