blob: 459702beaf477c9e95266ab623056e27a87d6c0e (
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
|
package com.vaadin.tests.data.converter;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.vaadin.data.Converter;
import com.vaadin.data.Result;
import com.vaadin.data.ValueContext;
public abstract class AbstractStringConverterTest
extends AbstractConverterTest {
@Override
protected abstract Converter<String, ?> getConverter();
@Test
public void testEmptyStringConversion() {
assertValue("Null value was converted incorrectly", null,
getConverter().convertToModel("", new ValueContext()));
}
@Test
public void testErrorMessage() {
Result<?> result = getConverter().convertToModel("abc",
new ValueContext());
assertTrue(result.isError());
assertEquals(getErrorMessage(), result.getMessage().get());
}
@Override
protected String getErrorMessage() {
return "conversion failed";
}
}
|