package com.opensymphony.xwork2.conversion.impl;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.SimpleFooAction;
import com.opensymphony.xwork2.XWorkTestCase;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public class NumberConverterTest extends XWorkTestCase {
public void testStringToNumberConversionPL() throws Exception {
// given
NumberConverter converter = new NumberConverter();
Map<String, Object> context = new HashMap<>();
context.put(ActionContext.LOCALE, new Locale("pl", "PL"));
SimpleFooAction foo = new SimpleFooAction();
// when
Object value = converter.convertValue(context, foo, null, "id", "1234", Integer.class);
// then
assertEquals(1234, value);
}
public void testStringToNumberConversionUS() throws Exception {
// given
NumberConverter converter = new NumberConverter();
Map<String, Object> context = new HashMap<>();
context.put(ActionContext.LOCALE, new Locale("en", "US"));
SimpleFooAction foo = new SimpleFooAction();
// when
Object value = converter.convertValue(context, foo, null, "id", ",1234", Integer.class);
// then
assertEquals(1234, value);
}
}