[#6] cover the models module with junit tests

Signed-off-by: Ori Bruk <o.bruk@yadro.com>
This commit is contained in:
Ori Bruk 2024-08-21 11:12:33 +03:00
parent 5f1d89d407
commit 441d3129dc
34 changed files with 1240 additions and 37 deletions

View file

@ -7,13 +7,15 @@ import static java.util.Objects.isNull;
public class UuidExtension {
private static final int UUID_BYTE_ARRAY_LENGTH = 16;
private static final String ERROR_WRONG_UUID_SIZE = "Uuid byte array length must be " + UUID_BYTE_ARRAY_LENGTH;
private static final String ERROR_UUID_MISSING = "Uuid is not present";
private UuidExtension() {
}
public static UUID asUuid(byte[] bytes) {
if (isNull(bytes) || bytes.length != UUID_BYTE_ARRAY_LENGTH) {
throw new IllegalArgumentException("Uuid byte array length must be " + UUID_BYTE_ARRAY_LENGTH);
throw new IllegalArgumentException(ERROR_WRONG_UUID_SIZE);
}
ByteBuffer bb = ByteBuffer.wrap(bytes);
@ -24,7 +26,7 @@ public class UuidExtension {
public static byte[] asBytes(UUID uuid) {
if (isNull(uuid)) {
throw new IllegalArgumentException("Uuid is not present");
throw new IllegalArgumentException(ERROR_UUID_MISSING);
}
ByteBuffer bb = ByteBuffer.allocate(UUID_BYTE_ARRAY_LENGTH);