diff --git a/src/main/Main.java b/src/main/Main.java index 7ac2177..1610b15 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -13,7 +13,7 @@ new TestPUTCactus("f", "f"), new TestDELETECactus("qF9bgKYZmw8P") }; TestYouTube[] youtube = { new TestGETYouTube(token), new TestPOSTYouTube(token), new TestPUTYouTube(token), new TestDELETEYouTube(token, "PLCwNa5MZdBSrIn-8nc9gDckf2kzXejtL_") }; - youtube[3].start(); + cactus[1].start(); } } diff --git a/src/restfulchecker/RestChecker.java b/src/restfulchecker/RestChecker.java index b63ea79..7ae31bd 100644 --- a/src/restfulchecker/RestChecker.java +++ b/src/restfulchecker/RestChecker.java @@ -138,12 +138,13 @@ private void judgeMethod() { ArrayList identically = new ArrayList<>(); + boolean isResponse = true; + for (int res : responses) { + if (res / 100 != 2) + isResponse = false; + } for (int i = 0; i < results.size(); i++) { - boolean isResponse = false; - if (responses.get(i) / 100 == 2 || (responses.get(i) == 404 && type == Method.DELETE)) { - isResponse = results.get(i).equals(beforeResults.get(i)); - } - identically.add(isResponse); + identically.add(results.get(i).equals(beforeResults.get(i))); } boolean isSafety = identically.get(0); boolean isIdempotency = false; @@ -153,15 +154,23 @@ if (isSafety && isIdempotency) { judgeResult = "GET"; } else if (!isSafety && isIdempotency) { - judgeResult = "PUT or DELETE"; + if(!isResponse && type == Method.POST){ + judgeResult = "POST"; + }else { + judgeResult = "PUT or DELETE"; + } } else { judgeResult = "POST"; } if (judgeResult.indexOf(method) != -1) { System.out.println("OK"); - if (isRemove) + if (isRemove) { System.out.println("This is Quasi " + judgeResult); - } else { + } + if(!isResponse && type == Method.POST){ + System.out.println("This is POST Only Exactry"); + } + }else { System.out.println("WARNING!! Perhaps:" + judgeResult); } } @@ -202,7 +211,7 @@ public String jsonRemove(String JsonString, RemoveJsonParam param) { try { JsonNode json = new ObjectMapper().readTree(JsonString); - if(json == null) { + if (json == null) { return ""; } if (json.getClass() != ArrayNode.class) {