use of org.whole.lang.testentities.factories.TestEntitiesEntityFactory in project whole by wholeplatform.
the class DataTypeUtilsTest method testLongData.
@Test
public void testLongData() {
TestEntitiesEntityFactory ef = TestEntitiesEntityFactory.instance;
IEntity e = ef.createLongTestEntity(123l);
assertGenericParseUnparseRoundtrip(e, "486432");
assertEquals("123", DataTypeUtils.getAsPresentationString(e));
assertEquals("123", DataTypeUtils.getAsPersistenceString(e));
DataTypeUtils.setFromPresentationString(e, "3324");
assertEquals(3324l, e.wLongValue());
DataTypeUtils.setFromPersistenceString(e, "532");
assertEquals(532l, e.wLongValue());
DataTypeUtils.setFromPresentationString(e, String.valueOf(Long.MIN_VALUE));
assertEquals(Long.MIN_VALUE, e.wLongValue());
DataTypeUtils.setFromPresentationString(e, String.valueOf(Long.MAX_VALUE));
assertEquals(Long.MAX_VALUE, e.wLongValue());
e = DataTypeUtils.createFromPresentationString(TestEntitiesEntityDescriptorEnum.LongTestEntity, "3324");
assertEquals(3324l, e.wLongValue());
e = DataTypeUtils.createFromPersistenceString(TestEntitiesEntityDescriptorEnum.LongTestEntity, "983");
assertEquals(983l, e.wLongValue());
final EntityDescriptor<?> ed = e.wGetEntityDescriptor();
IDataTypeParser parser = DataTypeUtils.getDataTypeParser(ed, DataTypeParsers.PRESENTATION);
try {
parser.parseLong(ed, "string");
fail();
} catch (IllegalArgumentException iae) {
}
try {
parser.parseLong(ed, "2.0f");
fail();
} catch (IllegalArgumentException iae) {
}
try {
parser.parseLong(ed, "-10000000000000000000");
fail();
} catch (IllegalArgumentException iae) {
}
}
use of org.whole.lang.testentities.factories.TestEntitiesEntityFactory in project whole by wholeplatform.
the class DataTypeUtilsTest method testEnumData.
@Test
public void testEnumData() {
TestEntitiesEntityFactory ef = TestEntitiesEntityFactory.instance;
IEntity e = ef.createEnumTestEntity(EnumTestEntityEnum.four);
assertGenericParseUnparseRoundtrip(e, "three");
assertEquals("four", DataTypeUtils.getAsPresentationString(e));
assertEquals("four", DataTypeUtils.getAsPersistenceString(e));
DataTypeUtils.setFromPresentationString(e, "One");
assertEquals(EnumTestEntityEnum.one, e.wEnumValue());
DataTypeUtils.setFromPersistenceString(e, "four");
assertEquals(EnumTestEntityEnum.four, e.wEnumValue());
e = DataTypeUtils.createFromPresentationString(TestEntitiesEntityDescriptorEnum.EnumTestEntity, "TWO");
assertEquals(EnumTestEntityEnum.two, e.wEnumValue());
e = DataTypeUtils.createFromPersistenceString(TestEntitiesEntityDescriptorEnum.EnumTestEntity, "five");
assertEquals(EnumTestEntityEnum.five, e.wEnumValue());
final EntityDescriptor<?> ed = e.wGetEntityDescriptor();
IDataTypeParser parser = DataTypeUtils.getDataTypeParser(ed, DataTypeParsers.PRESENTATION);
try {
parser.parseEnumValue(ed, "string");
fail();
} catch (IllegalArgumentException iae) {
}
}
use of org.whole.lang.testentities.factories.TestEntitiesEntityFactory in project whole by wholeplatform.
the class DataTypeUtilsTest method testStringData.
@Test
public void testStringData() {
TestEntitiesEntityFactory ef = TestEntitiesEntityFactory.instance;
IEntity e = ef.createStringTestEntity("abc");
assertGenericParseUnparseRoundtrip(e, "blabla");
assertEquals("abc", DataTypeUtils.getAsPresentationString(e));
assertEquals("abc", DataTypeUtils.getAsPersistenceString(e));
DataTypeUtils.setFromPresentationString(e, "def");
assertEquals("def", e.wStringValue());
DataTypeUtils.setFromPersistenceString(e, "ghi");
assertEquals("ghi", e.wStringValue());
e = DataTypeUtils.createFromPresentationString(TestEntitiesEntityDescriptorEnum.StringTestEntity, "def");
assertEquals("def", e.wStringValue());
e = DataTypeUtils.createFromPersistenceString(TestEntitiesEntityDescriptorEnum.StringTestEntity, "ghi");
assertEquals("ghi", e.wStringValue());
}
use of org.whole.lang.testentities.factories.TestEntitiesEntityFactory in project whole by wholeplatform.
the class DataTypeUtilsTest method testCharData.
@Test
public void testCharData() {
TestEntitiesEntityFactory ef = TestEntitiesEntityFactory.instance;
IEntity e = ef.createCharTestEntity('a');
assertGenericParseUnparseRoundtrip(e, "x");
assertEquals("a", DataTypeUtils.getAsPresentationString(e));
assertEquals("a", DataTypeUtils.getAsPersistenceString(e));
DataTypeUtils.setFromPresentationString(e, "b");
assertEquals('b', e.wCharValue());
DataTypeUtils.setFromPersistenceString(e, "c");
assertEquals('c', e.wCharValue());
DataTypeUtils.setFromPresentationString(e, String.valueOf(Character.MIN_VALUE));
assertEquals(Character.MIN_VALUE, e.wCharValue());
DataTypeUtils.setFromPresentationString(e, String.valueOf(Character.MAX_VALUE));
assertEquals(Character.MAX_VALUE, e.wCharValue());
e = DataTypeUtils.createFromPresentationString(TestEntitiesEntityDescriptorEnum.CharTestEntity, "d");
assertEquals('d', e.wCharValue());
e = DataTypeUtils.createFromPersistenceString(TestEntitiesEntityDescriptorEnum.CharTestEntity, "e");
assertEquals('e', e.wCharValue());
final EntityDescriptor<?> ed = e.wGetEntityDescriptor();
IDataTypeParser parser = DataTypeUtils.getDataTypeParser(ed, DataTypeParsers.PRESENTATION);
try {
parser.parseChar(ed, "string");
fail();
} catch (IllegalArgumentException iae) {
}
try {
parser.parseChar(ed, "200");
fail();
} catch (IllegalArgumentException iae) {
}
}
Aggregations