FxGsonTest.java 文件源码

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

项目:fx-gson 作者:
@Theory
public void testCustomObservableTreeMapInt(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    Map<Integer, CustomObject> mapEmpty = new TreeMap<>();
    Map<Integer, CustomObject> mapOne = new TreeMap<>();
    mapOne.put(1, one);
    Map<Integer, CustomObject> mapTwo = new TreeMap<>();
    mapTwo.put(1, one);
    mapTwo.put(2, two);

    ObservableMap<Integer, CustomObject> mapEmptyObs = FXCollections.observableMap(mapEmpty);
    ObservableMap<Integer, CustomObject> mapOneObs = FXCollections.observableMap(mapOne);
    ObservableMap<Integer, CustomObject> mapTwoObs = FXCollections.observableMap(mapTwo);

    Function<WithObsMapInt, ObservableMap<Integer, CustomObject>> getter = o -> o.map;
    BiConsumer<WithObsMapInt, ObservableMap<Integer, CustomObject>> setter = (o, m) -> o.map = m;

    testValue(WithObsMapInt.class, null, "{\"map\":null}", getter, setter, gson);
    testValue(WithObsMapInt.class, mapEmptyObs, "{\"map\":{}}", getter, setter, gson);
    testValue(WithObsMapInt.class, mapOneObs, "{\"map\":{\"1\":{\"name\":\"myObj1\"}}}", getter, setter, gson);
    testValue(WithObsMapInt.class, mapTwoObs, "{\"map\":{\"1\":{\"name\":\"myObj1\"},\"2\":{\"name\":\"myObj2\"}}}",
            getter, setter, gson);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号