LegacyTypeConverterUnitTestCase.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:wildfly-core 作者:
@Test
public void testSimpleTypeObject() throws Exception {
    ModelNode description = createDescription(ModelType.OBJECT, ModelType.LONG);
    TypeConverter converter = getConverter(description);

    assertMapType(assertCast(TabularType.class, converter.getOpenType()), SimpleType.STRING, SimpleType.LONG);

    ModelNode node = new ModelNode();
    node.get("one").set(1L);
    node.get("two").set(2L);

    TabularData tabularData = assertCast(TabularData.class, converter.fromModelNode(node));
    Assert.assertEquals(2, tabularData.size());
    Assert.assertEquals((long) 1, tabularData.get(new Object[] {"one"}).get("value"));
    Assert.assertEquals((long) 2, tabularData.get(new Object[] {"two"}).get("value"));

    Assert.assertEquals(node, converter.toModelNode(tabularData));

    //Allow plain map as well? Yeah why not!
    Map<String, Long> map = new HashMap<String, Long>();
    map.put("one", 1L);
    map.put("two", 2L);
    Assert.assertEquals(node, converter.toModelNode(map));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号