📄 mappingutilstest.java
字号:
/*
* Copyright 2005-2007 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 net.sf.dozer.util.mapping;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.SortedSet;
import net.sf.dozer.util.mapping.fieldmap.ClassMap;
import net.sf.dozer.util.mapping.fieldmap.FieldMap;
import net.sf.dozer.util.mapping.fieldmap.Mappings;
import net.sf.dozer.util.mapping.util.MappingFileReader;
import net.sf.dozer.util.mapping.util.MappingUtils;
import net.sf.dozer.util.mapping.util.MappingsParser;
/**
* @author tierney.matt
*/
public class MappingUtilsTest extends DozerTestBase {
MappingUtils mappingUtils = new MappingUtils();
public void testIsBlankOrNull() throws Exception {
assertTrue(mappingUtils.isBlankOrNull(null));
assertTrue(mappingUtils.isBlankOrNull(""));
assertTrue(mappingUtils.isBlankOrNull(" "));
}
public void testOverridenFields() throws Exception {
MappingFileReader fileReader = new MappingFileReader("overridemapping.xml");
Mappings mappings = fileReader.read();
MappingsParser mappingsParser = new MappingsParser();
mappingsParser.parseMappings(mappings);
// validate class mappings
Iterator iter = mappings.getMapping().iterator();
while (iter.hasNext()) {
ClassMap classMap = (ClassMap) iter.next();
if (classMap.getSourceClass().getName().equals("net.sf.dozer.util.mapping.vo.FurtherTestObject")) {
assertTrue(classMap.getStopOnErrors());
}
if (classMap.getSourceClass().getName().equals("net.sf.dozer.util.mapping.vo.SuperSuperSuperClass")) {
assertTrue(classMap.getWildcard());
}
if (classMap.getSourceClass().getName().equals("net.sf.dozer.util.mapping.vo.TestObject")) {
assertTrue(!((FieldMap) classMap.getFieldMaps().get(0)).getCopyByReference());
}
}
}
public void testGetClassWithoutPackage() throws Exception {
String result = mappingUtils.getClassNameWithoutPackage(String.class);
assertNotNull("result should not be null", result);
assertEquals("invalid result value", "String", result);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -