blob: fb3a3955551494e634ca8ac6701e35b8710d7628 (
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
|
package com.vaadin.v7.tests.data.converter;
import static org.junit.Assert.assertEquals;
import java.math.BigDecimal;
import java.util.Locale;
import org.junit.Test;
import com.vaadin.v7.data.util.converter.StringToBigDecimalConverter;
public class StringToBigDecimalConverterTest {
StringToBigDecimalConverter converter = new StringToBigDecimalConverter();
@Test
public void testNullConversion() {
assertEquals(null,
converter.convertToModel(null, BigDecimal.class, null));
}
@Test
public void testEmptyStringConversion() {
assertEquals(null,
converter.convertToModel("", BigDecimal.class, null));
}
@Test
public void testValueParsing() {
BigDecimal converted = converter.convertToModel("10", BigDecimal.class,
null);
BigDecimal expected = new BigDecimal(10);
assertEquals(expected, converted);
}
@Test
public void testValueFormatting() {
BigDecimal bd = new BigDecimal(12.5);
String expected = "12,5";
String converted = converter.convertToPresentation(bd, String.class,
Locale.GERMAN);
assertEquals(expected, converted);
}
}
|