测试case @Author JingWei @create 2022/3/3
| 17 | */ |
| 18 | |
| 19 | public class ShowCase { |
| 20 | public static void main(String[] args) { |
| 21 | List<Pair<String, String>> caseList = getCaseList(); |
| 22 | for (int index = 0; index < caseList.size(); index++) { |
| 23 | List<String> noiseList = Lists.newArrayList(); |
| 24 | List<String> noiseList1 = Lists.newArrayList("msg", "cost"); |
| 25 | List<String> noiseList2 = Lists.newArrayList("msg", "cost", "a.b"); |
| 26 | noiseList.addAll(noiseList1); |
| 27 | noiseList.addAll(noiseList2); |
| 28 | System.out.println("*************************"); |
| 29 | System.out.println("case[" + index + "] result is "); |
| 30 | LinkedList<String> specialPath = new LinkedList<>(); |
| 31 | //第一种diff方法 详细使用方法见README.md文件 |
| 32 | List<Result> diff1 = new Diff().diff(caseList.get(index).getLeft(), caseList.get(index).getRight()); |
| 33 | //第二种diff方法 详细使用方法见README.md文件 |
| 34 | List<Result> diff2 = new Diff().withNoisePahList(noiseList).withSpecialPath(specialPath).withAlgorithmEnum(AlgorithmEnum.DEFAULT).diff(caseList.get(index).getLeft(), caseList.get(index).getRight()); |
| 35 | System.out.println("left is : " + caseList.get(index).getLeft()); |
| 36 | System.out.println("right is : " + caseList.get(index).getRight()); |
| 37 | System.out.println("result is : " + new Gson().toJson(diff1)); |
| 38 | System.out.println("result is : " + new Gson().toJson(diff2)); |
| 39 | |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | |
| 44 | private static List<Pair<String, String>> getCaseList() { |
| 45 | List<Pair<String, String>> caseList = Lists.newArrayList(); |
| 46 | |
| 47 | Pair<String, String> case0 = Pair.of( |
| 48 | " {}", |
| 49 | "{}" |
| 50 | ); |
| 51 | |
| 52 | Pair<String, String> case1 = Pair.of( |
| 53 | " {\"coord1nates\": [[100.0, 1.0],[100.0, 1.0],[100.0, 1.0]]}", |
| 54 | "{\"coord1nates\": [[100.0, 0.0],[100.0, 1.0],[100.0, 1.0]]}" |
| 55 | ); |
| 56 | |
| 57 | Pair<String, String> case2 = Pair.of( |
| 58 | "{\"code\":5,\"test\":7,\"data\":{}, \"data1\":5, \"data2\":{\"data\":5}}", |
| 59 | "{\"code\":6,\"test\":8,\"data\":7, \"data1\":null, \"data2\":5}" |
| 60 | ); |
| 61 | |
| 62 | Pair<String, String> case3 = Pair.of( |
| 63 | " {\"coord1nates\": [ 8.0, 2.0, 1.0, 1.0, 1.0 ],\"coord1nates1\": 8.0}", |
| 64 | "{\"coord1nates\": [ 8.0, 4.0, 3.0, 2.0, 5.0 ],\"coord1nates1\": 8.0}" |
| 65 | ); |
| 66 | |
| 67 | Pair<String, String> case4 = Pair.of( |
| 68 | " {\"coord1nates\": 1, code : {\"coord1nates\": 3}}", |
| 69 | " {\"coord1nates\": 2, code : {\"coord1nates\": 4}}" |
| 70 | ); |
| 71 | |
| 72 | |
| 73 | Pair<String, String> case5 = Pair.of( |
| 74 | "[{\"coord1nate\": [ 2.0, 2.0, 1.0, 1.0 ],\"A\":2 }] ", |
| 75 | "[{\"coord1nates\": [ 4.0, 2.0, 1.0, 2.0 ],\"A\":2}] " |
| 76 | ); |
nothing calls this directly
no outgoing calls
no test coverage detected