diff --git a/src/test/java/org/codelibs/fess/it/admin/dict/DictCrudTestBase.java b/src/test/java/org/codelibs/fess/it/admin/dict/DictCrudTestBase.java index e92d4cba7..574c7da31 100644 --- a/src/test/java/org/codelibs/fess/it/admin/dict/DictCrudTestBase.java +++ b/src/test/java/org/codelibs/fess/it/admin/dict/DictCrudTestBase.java @@ -61,4 +61,9 @@ public abstract class DictCrudTestBase extends CrudTestBase { assertTrue(false); } + + @Override + protected String getJsonPath() { + return "response." + LIST_ENDPOINT_SUFFIX + ".findAll {it." + getKeyProperty() + ".startsWith(\"" + getNamePrefix() + "\")}"; + } } diff --git a/src/test/java/org/codelibs/fess/it/admin/dict/KuromojiTests.java b/src/test/java/org/codelibs/fess/it/admin/dict/KuromojiTests.java new file mode 100644 index 000000000..6e8944cca --- /dev/null +++ b/src/test/java/org/codelibs/fess/it/admin/dict/KuromojiTests.java @@ -0,0 +1,109 @@ +/* + * Copyright 2012-2017 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.it.admin.dict; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.List; +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import io.restassured.path.json.JsonPath; + +@Tag("it") +public class KuromojiTests extends DictCrudTestBase { + + private static final String NAME_PREFIX = "kuromojiTest_"; + private static final String API_PATH = "/api/admin/dict/kuromoji"; + private static final String LIST_ENDPOINT_SUFFIX = "settings"; + private static final String ITEM_ENDPOINT_SUFFIX = "setting"; + private static final String DICT_TYPE = "kuromoji"; + + private static final String KEY_PROPERTY = "token"; + + @Override + protected String getNamePrefix() { + return NAME_PREFIX; + } + + @Override + protected String getApiPath() { + return API_PATH; + } + + @Override + protected String getKeyProperty() { + return KEY_PROPERTY; + } + + @Override + protected String getListEndpointSuffix() { + return LIST_ENDPOINT_SUFFIX + "/" + dictId; + } + + @Override + protected String getItemEndpointSuffix() { + return ITEM_ENDPOINT_SUFFIX + "/" + dictId; + } + + @Override + protected String getDictType() { + return DICT_TYPE; + } + + @Override + protected Map createTestParam(int id) { + final Map requestBody = new HashMap<>(); + final String keyProp = NAME_PREFIX + id; + requestBody.put(KEY_PROPERTY, keyProp); + requestBody.put("segmentation", "segment"); + requestBody.put("reading", "reading"); + requestBody.put("pos", "pos"); + return requestBody; + } + + @Override + protected Map getUpdateMap() { + final Map updateMap = new HashMap<>(); + updateMap.put(KEY_PROPERTY, "new_token"); + updateMap.put("segmentation", "new_segment"); + updateMap.put("reading", "new_reading"); + updateMap.put("pos", "new_pos"); + return updateMap; + } + + @Override + protected void testRead() { + final Map searchBody = new HashMap<>(); + String response = checkGetMethod(searchBody, getListEndpointSuffix()).asString(); + final int total = JsonPath.from(response).getInt("response.total"); + final List> dicts = JsonPath.from(response).getList("response.settings"); + final int status = JsonPath.from(response).getInt("response.status"); + assertEquals(total, dicts.size()); + assertEquals(0, status); + } + + @Test + void crudTest() { + testCreate(); + testRead(); + testUpdate(); + testDelete(); + } +} diff --git a/src/test/java/org/codelibs/fess/it/admin/dict/MappingTests.java b/src/test/java/org/codelibs/fess/it/admin/dict/MappingTests.java new file mode 100644 index 000000000..22c4ab554 --- /dev/null +++ b/src/test/java/org/codelibs/fess/it/admin/dict/MappingTests.java @@ -0,0 +1,105 @@ +/* + * Copyright 2012-2017 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.it.admin.dict; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.List; +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import io.restassured.path.json.JsonPath; + +@Tag("it") +public class MappingTests extends DictCrudTestBase { + + private static final String NAME_PREFIX = "mappingTest_"; + private static final String API_PATH = "/api/admin/dict/mapping"; + private static final String LIST_ENDPOINT_SUFFIX = "settings"; + private static final String ITEM_ENDPOINT_SUFFIX = "setting"; + private static final String DICT_TYPE = "mapping"; + + private static final String KEY_PROPERTY = "inputs"; + + @Override + protected String getNamePrefix() { + return NAME_PREFIX; + } + + @Override + protected String getApiPath() { + return API_PATH; + } + + @Override + protected String getKeyProperty() { + return KEY_PROPERTY; + } + + @Override + protected String getListEndpointSuffix() { + return LIST_ENDPOINT_SUFFIX + "/" + dictId; + } + + @Override + protected String getItemEndpointSuffix() { + return ITEM_ENDPOINT_SUFFIX + "/" + dictId; + } + + @Override + protected String getDictType() { + return DICT_TYPE; + } + + @Override + protected Map createTestParam(int id) { + final Map requestBody = new HashMap<>(); + final String keyProp = NAME_PREFIX + id; + requestBody.put(KEY_PROPERTY, keyProp); + requestBody.put("output", "output"); + return requestBody; + } + + @Override + protected Map getUpdateMap() { + final Map updateMap = new HashMap<>(); + updateMap.put(KEY_PROPERTY, "new_inputs"); + updateMap.put("output", "new_output"); + return updateMap; + } + + @Override + protected void testRead() { + final Map searchBody = new HashMap<>(); + String response = checkGetMethod(searchBody, getListEndpointSuffix()).asString(); + final int total = JsonPath.from(response).getInt("response.total"); + final List> dicts = JsonPath.from(response).getList("response.settings"); + final int status = JsonPath.from(response).getInt("response.status"); + assertEquals(total, dicts.size()); + assertEquals(0, status); + } + + @Test + void crudTest() { + testCreate(); + testRead(); + testUpdate(); + testDelete(); + } +} diff --git a/src/test/java/org/codelibs/fess/it/admin/dict/ProtwordsTests.java b/src/test/java/org/codelibs/fess/it/admin/dict/ProtwordsTests.java new file mode 100644 index 000000000..702c1ab0a --- /dev/null +++ b/src/test/java/org/codelibs/fess/it/admin/dict/ProtwordsTests.java @@ -0,0 +1,103 @@ +/* + * Copyright 2012-2017 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.it.admin.dict; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.List; +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import io.restassured.path.json.JsonPath; + +@Tag("it") +public class ProtwordsTests extends DictCrudTestBase { + + private static final String NAME_PREFIX = "protwordsTest_"; + private static final String API_PATH = "/api/admin/dict/protwords"; + private static final String LIST_ENDPOINT_SUFFIX = "settings"; + private static final String ITEM_ENDPOINT_SUFFIX = "setting"; + private static final String DICT_TYPE = "protwords"; + + private static final String KEY_PROPERTY = "input"; + + @Override + protected String getNamePrefix() { + return NAME_PREFIX; + } + + @Override + protected String getApiPath() { + return API_PATH; + } + + @Override + protected String getKeyProperty() { + return KEY_PROPERTY; + } + + @Override + protected String getListEndpointSuffix() { + return LIST_ENDPOINT_SUFFIX + "/" + dictId; + } + + @Override + protected String getItemEndpointSuffix() { + return ITEM_ENDPOINT_SUFFIX + "/" + dictId; + } + + @Override + protected String getDictType() { + return DICT_TYPE; + } + + @Override + protected Map createTestParam(int id) { + final Map requestBody = new HashMap<>(); + final String keyProp = NAME_PREFIX + id; + requestBody.put(KEY_PROPERTY, keyProp); + return requestBody; + } + + @Override + protected Map getUpdateMap() { + final Map updateMap = new HashMap<>(); + updateMap.put(KEY_PROPERTY, "new_input"); + return updateMap; + } + + @Override + protected void testRead() { + final Map searchBody = new HashMap<>(); + String response = checkGetMethod(searchBody, getListEndpointSuffix()).asString(); + final int total = JsonPath.from(response).getInt("response.total"); + final List> dicts = JsonPath.from(response).getList("response.settings"); + final int status = JsonPath.from(response).getInt("response.status"); + assertEquals(total, dicts.size()); + assertEquals(0, status); + } + + @Test + void crudTest() { + testCreate(); + testRead(); + testUpdate(); + testDelete(); + } +} diff --git a/src/test/java/org/codelibs/fess/it/admin/dict/SeunjeonTests.java b/src/test/java/org/codelibs/fess/it/admin/dict/SeunjeonTests.java new file mode 100644 index 000000000..bca93058e --- /dev/null +++ b/src/test/java/org/codelibs/fess/it/admin/dict/SeunjeonTests.java @@ -0,0 +1,103 @@ +/* + * Copyright 2012-2017 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.it.admin.dict; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.List; +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import io.restassured.path.json.JsonPath; + +@Tag("it") +public class SeunjeonTests extends DictCrudTestBase { + + private static final String NAME_PREFIX = "seunjeonTest_"; + private static final String API_PATH = "/api/admin/dict/seunjeon"; + private static final String LIST_ENDPOINT_SUFFIX = "settings"; + private static final String ITEM_ENDPOINT_SUFFIX = "setting"; + private static final String DICT_TYPE = "seunjeon"; + + private static final String KEY_PROPERTY = "inputs"; + + @Override + protected String getNamePrefix() { + return NAME_PREFIX; + } + + @Override + protected String getApiPath() { + return API_PATH; + } + + @Override + protected String getKeyProperty() { + return KEY_PROPERTY; + } + + @Override + protected String getListEndpointSuffix() { + return LIST_ENDPOINT_SUFFIX + "/" + dictId; + } + + @Override + protected String getItemEndpointSuffix() { + return ITEM_ENDPOINT_SUFFIX + "/" + dictId; + } + + @Override + protected String getDictType() { + return DICT_TYPE; + } + + @Override + protected Map createTestParam(int id) { + final Map requestBody = new HashMap<>(); + final String keyProp = NAME_PREFIX + id; + requestBody.put(KEY_PROPERTY, keyProp); + return requestBody; + } + + @Override + protected Map getUpdateMap() { + final Map updateMap = new HashMap<>(); + updateMap.put(KEY_PROPERTY, "new_inputs"); + return updateMap; + } + + @Override + protected void testRead() { + final Map searchBody = new HashMap<>(); + String response = checkGetMethod(searchBody, getListEndpointSuffix()).asString(); + final int total = JsonPath.from(response).getInt("response.total"); + final List> dicts = JsonPath.from(response).getList("response.settings"); + final int status = JsonPath.from(response).getInt("response.status"); + assertEquals(total, dicts.size()); + assertEquals(0, status); + } + + @Test + void crudTest() { + testCreate(); + testRead(); + testUpdate(); + testDelete(); + } +} diff --git a/src/test/java/org/codelibs/fess/it/admin/dict/SynonymTests.java b/src/test/java/org/codelibs/fess/it/admin/dict/SynonymTests.java new file mode 100644 index 000000000..85c7a3669 --- /dev/null +++ b/src/test/java/org/codelibs/fess/it/admin/dict/SynonymTests.java @@ -0,0 +1,105 @@ +/* + * Copyright 2012-2017 CodeLibs Project and the Others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.codelibs.fess.it.admin.dict; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.List; +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import io.restassured.path.json.JsonPath; + +@Tag("it") +public class SynonymTests extends DictCrudTestBase { + + private static final String NAME_PREFIX = "synonymTest_"; + private static final String API_PATH = "/api/admin/dict/synonym"; + private static final String LIST_ENDPOINT_SUFFIX = "settings"; + private static final String ITEM_ENDPOINT_SUFFIX = "setting"; + private static final String DICT_TYPE = "synonym"; + + private static final String KEY_PROPERTY = "inputs"; + + @Override + protected String getNamePrefix() { + return NAME_PREFIX; + } + + @Override + protected String getApiPath() { + return API_PATH; + } + + @Override + protected String getKeyProperty() { + return KEY_PROPERTY; + } + + @Override + protected String getListEndpointSuffix() { + return LIST_ENDPOINT_SUFFIX + "/" + dictId; + } + + @Override + protected String getItemEndpointSuffix() { + return ITEM_ENDPOINT_SUFFIX + "/" + dictId; + } + + @Override + protected String getDictType() { + return DICT_TYPE; + } + + @Override + protected Map createTestParam(int id) { + final Map requestBody = new HashMap<>(); + final String keyProp = NAME_PREFIX + id; + requestBody.put(KEY_PROPERTY, keyProp); + requestBody.put("outputs", "output"); + return requestBody; + } + + @Override + protected Map getUpdateMap() { + final Map updateMap = new HashMap<>(); + updateMap.put(KEY_PROPERTY, "new_inputs"); + updateMap.put("outputs", "new_outputs"); + return updateMap; + } + + @Override + protected void testRead() { + final Map searchBody = new HashMap<>(); + String response = checkGetMethod(searchBody, getListEndpointSuffix()).asString(); + final int total = JsonPath.from(response).getInt("response.total"); + final List> dicts = JsonPath.from(response).getList("response.settings"); + final int status = JsonPath.from(response).getInt("response.status"); + assertEquals(total, dicts.size()); + assertEquals(0, status); + } + + @Test + void crudTest() { + testCreate(); + testRead(); + testUpdate(); + testDelete(); + } +}