blob: 6cac48df97acc6101562834e6eb6e93b3f480f7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package com.vaadin.tests.data.converter;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.vaadin.data.ValueContext;
import com.vaadin.data.converter.StringToFloatConverter;
public class StringToFloatConverterTest extends AbstractStringConverterTest {
@Override
protected StringToFloatConverter getConverter() {
return new StringToFloatConverter(getErrorMessage());
}
@Override
@Test
public void testNullConversion() {
assertValue(null,
getConverter().convertToModel(null, new ValueContext()));
}
@Override
@Test
public void testEmptyStringConversion() {
assertValue(null,
getConverter().convertToModel("", new ValueContext()));
}
@Test
public void testValueConversion() {
assertValue(Float.valueOf(10),
getConverter().convertToModel("10", new ValueContext()));
}
@Test
public void customEmptyValue() {
StringToFloatConverter converter = new StringToFloatConverter(
(float) 0.0, getErrorMessage());
assertValue((float) 0.0,
converter.convertToModel("", new ValueContext()));
assertEquals("0", converter.convertToPresentation((float) 0.0,
new ValueContext()));
}
}
|