新利18luck体育登录

publicstaticMapmerge(Mapsrc,Mapdest)单测ItemUtilTest.javapackagecc.lovesq.study.test.datastructure;?importorg.junit.Test;?importjava.util.Arrays;importjava.util.Map;?importcc.lovesq.study.test.CommonForTest;importzzz.study.utils.ItemUtil;importzzz.study.utils.JsonUtil;importzzz.study.utils.NewMapUtil;?/**?*Createdbyshuqinon17/11/10.?*/publicclassItemUtilTestextendsCommonForTest{??StringnewItemInfoStr="{\n"?????????????+"??\"item:s_id:18006666\":\"1024\",\n"?????????????+"??\"item:s_id:18008888\":\"1024\",\n"?????????????+"??\"item:g_id:18006666\":\"6666\",\n"?????????????+"??\"item:g_id:18008888\":\"8888\",\n"?????????????+"??\"item:num:18008888\":\"8\",\n"?????????????+"??\"item:num:18006666\":\"6\",\n"?????????????+"??\"item:item_core_id:18006666\":\"9876666\",\n"?????????????+"??\"item:item_core_id:18008888\":\"9878888\",\n"?????????????+"??\"item:order_no:18006666\":\"E20171013174712025\",\n"?????????????+"??\"item:order_no:18008888\":\"E20171013174712025\",\n"?????????????+"??\"item:id:18008888\":\"18008888\",\n"?????????????+"??\"item:id:18006666\":\"18006666\",\n"?????????????+"??\"item_core:num:9878888\":\"8\",\n"?????????????+"??\"item_core:num:9876666\":\"6\",\n"?????????????+"??\"item_core:id:9876666\":\"9876666\",\n"?????????????+"??\"item_core:id:9878888\":\"9878888\",\n"?????????????+"??\"item_price:item_id:1000\":\"9876666\",\n"?????????????+"??\"item_price:item_id:2000\":\"9878888\",\n"?????????????+"??\"item_price:price:1000\":\"100\",\n"?????????????+"??\"item_price:price:2000\":\"200\",\n"?????????????+"??\"item_price:id:2000\":\"2000\",\n"?????????????+"??\"item_price:id:1000\":\"1000\",\n"?????????????+"??\"item_price_change_log:id:1111\":\"1111\",\n"?????????????+"??\"item_price_change_log:id:2222\":\"2222\",\n"?????????????+"??\"item_price_change_log:item_id:1111\":\"9876666\",\n"?????????????+"??\"item_price_change_log:item_id:2222\":\"9878888\",\n"?????????????+"??\"item_price_change_log:detail:1111\":\"haha1111\",\n"?????????????+"??\"item_price_change_log:detail:2222\":\"haha2222\",\n"?????????????+"??\"item_price_change_log:id:3333\":\"3333\",\n"?????????????+"??\"item_price_change_log:id:4444\":\"4444\",\n"?????????????+"??\"item_price_change_log:item_id:3333\":\"9876666\",\n"?????????????+"??\"item_price_change_log:item_id:4444\":\"9878888\",\n"?????????????+"??\"item_price_change_log:detail:3333\":\"haha3333\",\n"?????????????+"??\"item_price_change_log:detail:4444\":\"haha4444\"\n"?????????????+"}";??@Test?publicvoidtestBuildItemIndexMapForNew(){??MapitemInfoMap=JsonUtil.readMap(newItemInfoStr);??Map>itemIndexMap=ItemUtil????.buildItemIndexMap(NewMapUtil.transMap(itemInfoMap));???System.out.println(itemIndexMap);???eq("18006666",itemIndexMap.get("item:18006666").get("item:id"));??eq("6666",itemIndexMap.get("item:18006666").get("item:g_id"));??eq("1024",itemIndexMap.get("item:18006666").get("item:s_id"));??eq("E20171013174712025",itemIndexMap.get("item:18006666").get("item:order_no"));??eq("9876666",itemIndexMap.get("item:18006666").get("item:item_core_id"));???eq("18008888",itemIndexMap.get("item:18008888").get("item:id"));??eq("8888",itemIndexMap.get("item:18008888").get("item:g_id"));??eq("1024",itemIndexMap.get("item:18008888").get("item:s_id"));??eq("E20171013174712025",itemIndexMap.get("item:18008888").get("item:order_no"));??eq("9878888",itemIndexMap.get("item:18008888").get("item:item_core_id"));???eq("9876666",itemIndexMap.get("item_core:9876666").get("item_core:id"));??eq("6",itemIndexMap.get("item_core:9876666").get("item_core:num"));???eq("9878888",itemIndexMap.get("item_core:9878888").get("item_core:id"));??eq("8",itemIndexMap.get("item_core:9878888").get("item_core:num"));???eq("9876666",itemIndexMap.get("item_price:1000").get("item_price:item_id"));??eq("1000",itemIndexMap.get("item_price:1000").get("item_price:id"));??eq("100",itemIndexMap.get("item_price:1000").get("item_price:price"));???eq("9878888",itemIndexMap.get("item_price:2000").get("item_price:item_id"));??eq("2000",itemIndexMap.get("item_price:2000").get("item_price:id"));??eq("200",itemIndexMap.get("item_price:2000").get("item_price:price"));???eq("9876666",itemIndexMap.get("item_price_change_log:1111").get("item_price_change_log:item_id"));??eq("haha1111",itemIndexMap.get("item_price_change_log:1111").get("item_price_change_log:detail"));??eq("9878888",itemIndexMap.get("item_price_change_log:2222").get("item_price_change_log:item_id"));??eq("haha2222",itemIndexMap.get("item_price_change_log:2222").get("item_price_change_log:detail"));???eq("9876666",itemIndexMap.get("item_price_change_log:3333").get("item_price_change_log:item_id"));??eq("haha3333",itemIndexMap.get("item_price_change_log:3333").get("item_price_change_log:detail"));??eq("9878888",itemIndexMap.get("item_price_change_log:4444").get("item_price_change_log:item_id"));??eq("haha4444",itemIndexMap.get("item_price_change_log:4444").get("item_price_change_log:detail"));?}??@Test?publicvoidtestBuildFinalOrderItemMapForNew(){??MapitemInfoMap=JsonUtil.readMap(newItemInfoStr);??Map>finalOrderItemMap=ItemUtil????.buildFinalOrderItemMap(NewMapUtil.transMap(itemInfoMap));??System.out.println(finalOrderItemMap);???eq("18006666",finalOrderItemMap.get("1024_E20171013174712025_18006666").get("item:id"));??eq("6666",finalOrderItemMap.get("1024_E20171013174712025_18006666").get("item:g_id"));??eq("1024",finalOrderItemMap.get("1024_E20171013174712025_18006666").get("item:s_id"));??eq("E20171013174712025",finalOrderItemMap.get("1024_E20171013174712025_18006666").get("item:order_no"));??eq("9876666",finalOrderItemMap.get("1024_E20171013174712025_18006666").get("item_core:id"));??eq("6",finalOrderItemMap.get("1024_E20171013174712025_18006666").get("item_core:num"));??eq("9876666",finalOrderItemMap.get("1024_E20171013174712025_18006666").get("item_price:item_id"));??eq("100",finalOrderItemMap.get("1024_E20171013174712025_18006666").get("item_price:price"));???eq("18008888",finalOrderItemMap.get("1024_E20171013174712025_18008888").get("item:id"));??eq("8888",finalOrderItemMap.get("1024_E20171013174712025_18008888").get("item:g_id"));??eq("1024",finalOrderItemMap.get("1024_E20171013174712025_18008888").get("item:s_id"));??eq("E20171013174712025",finalOrderItemMap.get("1024_E20171013174712025_18008888").get("item:order_no"));??eq("9878888",finalOrderItemMap.get("1024_E20171013174712025_18008888").get("item_core:id"));??eq("8",finalOrderItemMap.get("1024_E20171013174712025_18008888").get("item_core:num"));??eq("9878888",finalOrderItemMap.get("1024_E20171013174712025_18008888").get("item_price:item_id"));??eq("200",finalOrderItemMap.get("1024_E20171013174712025_18008888").get("item_price:price"));???eq(Arrays.asList("haha3333","haha1111"),finalOrderItemMap.get("1024_E20171013174712025_18006666").get("item_price_change_log:detail"));??eq(Arrays.asList("haha2222","haha4444"),finalOrderItemMap.get("1024_E20171013174712025_18008888").get("item_price_change_log:detail"));?}?}CommonForTest.javapackagecc.lovesq.study.test;?importorg.junit.Assert;?importjava.util.List;?importstaticorg.junit.Assert.assertEquals;?/**?*Createdbyshuqinon17/11/10.?*/publicclassCommonForTest{??publicstaticfinalStringNOT_THROW_EXCEPTION="NotThrowException";??publicvoideq(Objectexpected,Objectactual){??assertEquals(expected,actual);?}??publicvoideq(T[]expected,T[]actual){??Assert.assertArrayEquals(expected,actual);?}??publicvoideq(ListexpectedList,ListactualList){??if(expectedList==null&&actualList==null){???return;??}??assertEquals(expectedList.size(),actualList.size());??for(inti=0;i???assertEquals(expectedList.get(i),actualList.get(i));??}?}??publicvoidfail(Stringmessage){??Assert.fail(message);?}?}packagezzz.study.utils;?importorg.codehaus.jackson.map.DeserializationConfig;importorg.codehaus.jackson.map.ObjectMapper;importorg.codehaus.jackson.map.annotate.JsonSerialize;?importjava.text.SimpleDateFormat;importjava.util.HashMap;importjava.util.Map;?publicclassJsonUtil{??privatestaticfinalObjectMapperMAPPER=newObjectMapper();??static{??//为保持对象版本兼容性,忽略未知的属性??MAPPER.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);??//序列化的时候,跳过null值??MAPPER.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);??//date类型转化??SimpleDateFormatfmt=newSimpleDateFormat("yyyy-MM-ddHH:mm:ss");??MAPPER.setDateFormat(fmt);?}??/**??*将一个json字符串解码为java对象??*??*注意:如果传入的字符串为null,那么返回的对象也为null??*??*@paramjsonjson字符串??*@paramcls?对象类型??*@return解析后的java对象??*@throwsRuntimeException若解析json过程中发生了异常??*/?publicstaticTtoObject(Stringjson,Classcls){??if(json==null){???returnnull;??}??try{???returnMAPPER.readValue(json,cls);??}catch(Exceptione){???returnnull;??}?}??/**??*读取JSON字符串为MAP??*/?@SuppressWarnings("unchecked")?publicstaticMapreadMap(Stringjson){??returntoObject(json,HashMap.class);?}?}看完本文有收获?请转发分享给更多人关注「ImportNew」,提升Java技能杂谈?GC{###}(点击上方公众号,可快速关注)来源:占小狼,www.jianshu.com/p/2750c7c202ef上周有幸给部门的小伙伴分享了一些JVM相关的知识,在整个做PPT的过程中,也是对一个领域的碎片知识的整理,本文将针对虚拟机GC相关的一些内容进行整理,本文不会涉及到G1收集器。这个属于Google公司秘密的GoogleX臭鼬项目下(译者:指秘密的创新项目)的试验,将16,000个处理器用于对YouTube视频进行无人干摄的学习,来得出如何识别一只猫的方法。JBN:喜欢的车?韦静莹:悍马。这其中隐含了创建一个新的znode和更新一个已存在的znode的实现方法的不同。羊群效应虽然这个算法是正确的,但是还是有一些问题。