/*
* Copyright 2005-2006 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package org.strecks.bind.internal;
import java.util.Map;
import org.strecks.bind.handler.BindHandler;
import org.strecks.bind.handler.BindSelectHandler;
import org.strecks.bind.handler.BindSimpleHandler;
import org.strecks.converter.DatePatternConverter;
import org.strecks.converter.SafeBeanUtilsConverter;
import org.strecks.converter.internal.impl.BeanWithExplicitConverters;
import org.testng.annotations.Test;
/**
* @author Phil Zoio
*/
public class TestReadBindablesWithConverter
{
@Test
public void testReadBindables()
{
BeanWithExplicitConverters bean = new BeanWithExplicitConverters();
BindAnnotationReader bindablesReader = new BindAnnotationReader();
BindConvertInfo bindConvertInfo = bindablesReader.readBindables(bean);
Map<String, BindHandler> bindables = bindConvertInfo.getBindMap();
BindHandler bh1 = bindables.get("startDate");
assert null != bh1;
BindSimpleHandler handler1 = (BindSimpleHandler) bh1;
assert handler1.getConverter() instanceof DatePatternConverter;
assert handler1.getConverterClass().equals(DatePatternConverter.class);
BindHandler bh2 = bindables.get("selectedStartDate");
assert null != bh2;
BindSelectHandler selectHandler1 = (BindSelectHandler) bh2;
assert selectHandler1.getConverter() instanceof DatePatternConverter;
assert selectHandler1.getConverterClass().equals(DatePatternConverter.class);
BindHandler bh3 = bindables.get("startDateWithout");
assert null != bh3;
BindSimpleHandler handler2 = (BindSimpleHandler) bh3;
assert handler2.getConverter() != null;
assert handler2.getConverterClass().equals(SafeBeanUtilsConverter.class);
BindHandler bh4 = bindables.get("selectedStartDateWithout");
assert null != bh4;
BindSelectHandler selectHandler2 = (BindSelectHandler) bh4;
assert selectHandler2.getConverter() instanceof SafeBeanUtilsConverter;
assert selectHandler2.getConverterClass().equals(SafeBeanUtilsConverter.class);
}
}