mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Allow format() for types UUID to handle string input
This commit is contained in:
@@ -35,6 +35,11 @@ abstract class ScalarTypeUUIDBase extends ScalarTypeBase<UUID> implements Scalar
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(Object value) {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatValue(UUID value) {
|
||||
return value.toString();
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package io.ebeaninternal.server.type;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ScalarTypeUUIDBaseTest {
|
||||
|
||||
private final ScalarTypeUUIDBase type = new ScalarTypeUUIDNative();
|
||||
private final UUID uuid = UUID.randomUUID();
|
||||
|
||||
@Test
|
||||
public void format_as_uuid() {
|
||||
assertThat(type.format(uuid)).isEqualTo(uuid.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void format_as_String() {
|
||||
assertThat(type.format(uuid.toString())).isEqualTo(uuid.toString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user