Browse Source

refactoring: CrawlerLogTests

Keiichi Watanabe 8 years ago
parent
commit
764f7d8a09

+ 1 - 0
src/test/java/org/codelibs/fess/it/CrudTestBase.java

@@ -151,6 +151,7 @@ public abstract class CrudTestBase extends ITBase {
             }
             }
 
 
             checkPostMethod(requestBody, getItemEndpointSuffix()).then().body("response.status", equalTo(0));
             checkPostMethod(requestBody, getItemEndpointSuffix()).then().body("response.status", equalTo(0));
+            refresh();
         }
         }
 
 
         checkUpdate();
         checkUpdate();

+ 18 - 10
src/test/java/org/codelibs/fess/it/admin/CrawlerLogTests.java

@@ -41,7 +41,7 @@ import io.restassured.path.json.JsonPath;
 import io.restassured.response.Response;
 import io.restassured.response.Response;
 
 
 /**
 /**
- * Integration Tests for
+ * Integration Tests which need an execution of crawler
  * - /api/admin/joblog
  * - /api/admin/joblog
  * - /api/admin/crawlinginfo
  * - /api/admin/crawlinginfo
  * - /api/admin/failureurl
  * - /api/admin/failureurl
@@ -65,7 +65,7 @@ public class CrawlerLogTests extends ITBase {
             createWebConfig();
             createWebConfig();
             logger.info("WebConfig is created");
             logger.info("WebConfig is created");
             refresh();
             refresh();
-            webConfigId = getWebConfigId();
+            webConfigId = getWebConfigIds().get(0);
 
 
             createJob();
             createJob();
             logger.info("Job is created");
             logger.info("Job is created");
@@ -74,6 +74,7 @@ public class CrawlerLogTests extends ITBase {
             startJob();
             startJob();
 
 
             waitJob();
             waitJob();
+            refresh();
         } catch (InterruptedException e) {
         } catch (InterruptedException e) {
             e.printStackTrace();
             e.printStackTrace();
             assertTrue(false);
             assertTrue(false);
@@ -82,6 +83,7 @@ public class CrawlerLogTests extends ITBase {
 
 
     @BeforeEach
     @BeforeEach
     protected void init() {
     protected void init() {
+        refresh();
     }
     }
 
 
     @AfterEach
     @AfterEach
@@ -108,9 +110,15 @@ public class CrawlerLogTests extends ITBase {
         final Map<String, Object> requestBody = new HashMap<>();
         final Map<String, Object> requestBody = new HashMap<>();
         requestBody.put("q", "Example Domain");
         requestBody.put("q", "Example Domain");
         checkMethodBase(requestBody).delete("/api/admin/searchlist/query");
         checkMethodBase(requestBody).delete("/api/admin/searchlist/query");
+        refresh();
 
 
-        deleteMethod("/api/admin/scheduler/setting/" + getSchedulerId());
-        deleteMethod("/api/admin/webconfig/setting/" + webConfigId);
+        for (String sId : getSchedulerIds()) {
+            deleteMethod("/api/admin/scheduler/setting/" + sId);
+        }
+
+        for (String wId : getWebConfigIds()) {
+            deleteMethod("/api/admin/webconfig/setting/" + wId);
+        }
 
 
         deleteTestToken();
         deleteTestToken();
     }
     }
@@ -177,7 +185,7 @@ public class CrawlerLogTests extends ITBase {
     private static void startJob() {
     private static void startJob() {
         for (int i = 0; i < 30; i++) {
         for (int i = 0; i < 30; i++) {
             final Map<String, Object> requestBody = new HashMap<>();
             final Map<String, Object> requestBody = new HashMap<>();
-            final String schedulerId = getSchedulerId();
+            final String schedulerId = getSchedulerIds().get(0);
             final Response response = checkMethodBase(requestBody).post("/api/admin/scheduler/" + schedulerId + "/start");
             final Response response = checkMethodBase(requestBody).post("/api/admin/scheduler/" + schedulerId + "/start");
             if (response.getBody().jsonPath().getInt("response.status") == 0) {
             if (response.getBody().jsonPath().getInt("response.status") == 0) {
                 logger.info("Start scheduler \"" + schedulerId + "\"");
                 logger.info("Start scheduler \"" + schedulerId + "\"");
@@ -341,7 +349,7 @@ public class CrawlerLogTests extends ITBase {
         requestBody.put("q", "Example Domain");
         requestBody.put("q", "Example Domain");
 
 
         final String response = checkMethodBase(requestBody).get("/api/admin/searchlist/docs").asString();
         final String response = checkMethodBase(requestBody).get("/api/admin/searchlist/docs").asString();
-        final List<Map<String, Object>> results = JsonPath.from(response).getList("response.result");
+        final List<Map<String, Object>> results = JsonPath.from(response).getList("response.docs");
         return results;
         return results;
     }
     }
 
 
@@ -365,16 +373,16 @@ public class CrawlerLogTests extends ITBase {
         return "response.settings.findAll {it.name.startsWith(\"" + NAME_PREFIX + "\")}";
         return "response.settings.findAll {it.name.startsWith(\"" + NAME_PREFIX + "\")}";
     }
     }
 
 
-    private static String getWebConfigId() {
+    private static List<String> getWebConfigIds() {
         final String response = getJsonResponse("/api/admin/webconfig/settings");
         final String response = getJsonResponse("/api/admin/webconfig/settings");
         final List<String> idList = JsonPath.from(response).getList(getResponsePath() + ".id");
         final List<String> idList = JsonPath.from(response).getList(getResponsePath() + ".id");
-        return idList.get(0);
+        return idList;
     }
     }
 
 
-    private static String getSchedulerId() {
+    private static List<String> getSchedulerIds() {
         final String response = getJsonResponse("/api/admin/scheduler/settings");
         final String response = getJsonResponse("/api/admin/scheduler/settings");
         final List<String> idList = JsonPath.from(response).getList(getResponsePath() + ".id");
         final List<String> idList = JsonPath.from(response).getList(getResponsePath() + ".id");
-        return idList.get(0);
+        return idList;
     }
     }
 
 
     private static Map<String, Object> getSchedulerItem() {
     private static Map<String, Object> getSchedulerItem() {

+ 1 - 1
src/test/java/org/codelibs/fess/it/admin/dict/MappingTests.java

@@ -74,7 +74,7 @@ public class MappingTests extends DictCrudTestBase {
     @Override
     @Override
     protected Map<String, Object> getUpdateMap() {
     protected Map<String, Object> getUpdateMap() {
         final Map<String, Object> updateMap = new HashMap<>();
         final Map<String, Object> updateMap = new HashMap<>();
-        updateMap.put(KEY_PROPERTY, "new_inputs");
+        updateMap.put(KEY_PROPERTY, "new_inputs_mapping");
         updateMap.put("output", "new_output");
         updateMap.put("output", "new_output");
         return updateMap;
         return updateMap;
     }
     }

+ 1 - 1
src/test/java/org/codelibs/fess/it/admin/dict/ProtwordsTests.java

@@ -73,7 +73,7 @@ public class ProtwordsTests extends DictCrudTestBase {
     @Override
     @Override
     protected Map<String, Object> getUpdateMap() {
     protected Map<String, Object> getUpdateMap() {
         final Map<String, Object> updateMap = new HashMap<>();
         final Map<String, Object> updateMap = new HashMap<>();
-        updateMap.put(KEY_PROPERTY, "new_input");
+        updateMap.put(KEY_PROPERTY, "new_input_protwords");
         return updateMap;
         return updateMap;
     }
     }
 
 

+ 1 - 1
src/test/java/org/codelibs/fess/it/admin/dict/SeunjeonTests.java

@@ -73,7 +73,7 @@ public class SeunjeonTests extends DictCrudTestBase {
     @Override
     @Override
     protected Map<String, Object> getUpdateMap() {
     protected Map<String, Object> getUpdateMap() {
         final Map<String, Object> updateMap = new HashMap<>();
         final Map<String, Object> updateMap = new HashMap<>();
-        updateMap.put(KEY_PROPERTY, "new_inputs");
+        updateMap.put(KEY_PROPERTY, "new_inputs_Seunjeon");
         return updateMap;
         return updateMap;
     }
     }
 
 

+ 1 - 1
src/test/java/org/codelibs/fess/it/admin/dict/SynonymTests.java

@@ -74,7 +74,7 @@ public class SynonymTests extends DictCrudTestBase {
     @Override
     @Override
     protected Map<String, Object> getUpdateMap() {
     protected Map<String, Object> getUpdateMap() {
         final Map<String, Object> updateMap = new HashMap<>();
         final Map<String, Object> updateMap = new HashMap<>();
-        updateMap.put(KEY_PROPERTY, "new_inputs");
+        updateMap.put(KEY_PROPERTY, "new_inputs_Synonym");
         updateMap.put("outputs", "new_outputs");
         updateMap.put("outputs", "new_outputs");
         return updateMap;
         return updateMap;
     }
     }