commit
686c199b1b
8 changed files with 21 additions and 92 deletions
|
@ -31,7 +31,6 @@ import org.codelibs.fess.app.web.api.ApiResult;
|
|||
import org.codelibs.fess.app.web.api.admin.FessApiAdminAction;
|
||||
import org.codelibs.fess.dict.mapping.CharMappingFile;
|
||||
import org.codelibs.fess.dict.mapping.CharMappingItem;
|
||||
import org.dbflute.optional.OptionalThing;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.response.JsonResponse;
|
||||
import org.lastaflute.web.response.StreamResponse;
|
||||
|
@ -41,15 +40,12 @@ public class ApiAdminDictMappingAction extends FessApiAdminAction {
|
|||
@Resource
|
||||
private CharMappingService charMappingService;
|
||||
|
||||
// GET /api/admin/dict/mapping/settings/{dictId}/{id}
|
||||
// GET /api/admin/dict/mapping/settings/{dictId}
|
||||
@Execute
|
||||
public JsonResponse<ApiResult> get$settings(final String dictId, final OptionalThing<Integer> page, final SearchBody body) {
|
||||
public JsonResponse<ApiResult> get$settings(final String dictId, final SearchBody body) {
|
||||
body.dictId = dictId;
|
||||
validateApi(body, messages -> {});
|
||||
final CharMappingPager pager = copyBeanToNewBean(body, CharMappingPager.class);
|
||||
page.ifPresent(p -> {
|
||||
pager.setCurrentPageNumber(p);
|
||||
});
|
||||
return asJson(new ApiResult.ApiConfigsResponse<EditBody>()
|
||||
.settings(
|
||||
charMappingService.getCharMappingList(body.dictId, pager).stream()
|
||||
|
|
|
@ -40,6 +40,7 @@ import io.restassured.specification.RequestSpecification;
|
|||
public abstract class CrudTestBase extends ITBase {
|
||||
|
||||
protected static final int NUM = 20;
|
||||
protected static final int SEARCH_ALL_NUM = 1000;
|
||||
|
||||
// ================
|
||||
// Abstract Methods
|
||||
|
@ -73,7 +74,7 @@ public abstract class CrudTestBase extends ITBase {
|
|||
@AfterEach
|
||||
protected void tearDown() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 10);
|
||||
searchBody.put("size", SEARCH_ALL_NUM);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
checkDeleteMethod(getItemEndpointSuffix() + "/" + id);
|
||||
|
@ -98,14 +99,14 @@ public abstract class CrudTestBase extends ITBase {
|
|||
|
||||
// Test: number of settings.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
searchBody.put("size", SEARCH_ALL_NUM);
|
||||
checkGetMethod(searchBody, getListEndpointSuffix()).then().body(getJsonPath() + ".size()", equalTo(NUM));
|
||||
}
|
||||
|
||||
protected void testRead() {
|
||||
// Test: get settings api.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
searchBody.put("size", SEARCH_ALL_NUM);
|
||||
List<String> nameList = getPropList(searchBody, getKeyProperty());
|
||||
|
||||
assertEquals(NUM, nameList.size());
|
||||
|
@ -136,7 +137,7 @@ public abstract class CrudTestBase extends ITBase {
|
|||
final Set<String> keySet = createTestParam(0).keySet();
|
||||
final Map<String, Object> updateMap = getUpdateMap();
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
searchBody.put("size", SEARCH_ALL_NUM);
|
||||
List<Map<String, Object>> settings = getItemList(searchBody);
|
||||
|
||||
for (Map<String, Object> setting : settings) {
|
||||
|
@ -160,7 +161,7 @@ public abstract class CrudTestBase extends ITBase {
|
|||
protected void checkUpdate() {
|
||||
final Map<String, Object> updateMap = getUpdateMap();
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
searchBody.put("size", SEARCH_ALL_NUM);
|
||||
for (Map.Entry<String, Object> entry : updateMap.entrySet()) {
|
||||
List<String> updatedList = getPropList(searchBody, entry.getKey());
|
||||
for (String val : updatedList) {
|
||||
|
@ -171,7 +172,7 @@ public abstract class CrudTestBase extends ITBase {
|
|||
|
||||
protected void testDelete() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
searchBody.put("size", SEARCH_ALL_NUM);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
|
||||
idList.forEach(id -> {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package org.codelibs.fess.it.admin.dict;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -66,4 +67,15 @@ public abstract class DictCrudTestBase extends CrudTestBase {
|
|||
protected String getJsonPath() {
|
||||
return "response." + LIST_ENDPOINT_SUFFIX + ".findAll {it." + getKeyProperty() + ".startsWith(\"" + getNamePrefix() + "\")}";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
String response = checkGetMethod(searchBody, getListEndpointSuffix()).asString();
|
||||
final int total = JsonPath.from(response).getInt("response.total");
|
||||
final List<Map<String, String>> items = JsonPath.from(response).getList("response.settings");
|
||||
final int status = JsonPath.from(response).getInt("response.status");
|
||||
assertEquals(total, items.size());
|
||||
assertEquals(0, status);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,17 +15,12 @@
|
|||
*/
|
||||
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 {
|
||||
|
||||
|
@ -88,17 +83,6 @@ public class KuromojiTests extends DictCrudTestBase {
|
|||
return updateMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
String response = checkGetMethod(searchBody, getListEndpointSuffix()).asString();
|
||||
final int total = JsonPath.from(response).getInt("response.total");
|
||||
final List<Map<String, String>> 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();
|
||||
|
|
|
@ -15,17 +15,12 @@
|
|||
*/
|
||||
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 {
|
||||
|
||||
|
@ -84,17 +79,6 @@ public class MappingTests extends DictCrudTestBase {
|
|||
return updateMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
String response = checkGetMethod(searchBody, getListEndpointSuffix()).asString();
|
||||
final int total = JsonPath.from(response).getInt("response.total");
|
||||
final List<Map<String, String>> 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();
|
||||
|
|
|
@ -15,17 +15,12 @@
|
|||
*/
|
||||
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 {
|
||||
|
||||
|
@ -82,17 +77,6 @@ public class ProtwordsTests extends DictCrudTestBase {
|
|||
return updateMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
String response = checkGetMethod(searchBody, getListEndpointSuffix()).asString();
|
||||
final int total = JsonPath.from(response).getInt("response.total");
|
||||
final List<Map<String, String>> 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();
|
||||
|
|
|
@ -15,17 +15,12 @@
|
|||
*/
|
||||
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 {
|
||||
|
||||
|
@ -82,17 +77,6 @@ public class SeunjeonTests extends DictCrudTestBase {
|
|||
return updateMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
String response = checkGetMethod(searchBody, getListEndpointSuffix()).asString();
|
||||
final int total = JsonPath.from(response).getInt("response.total");
|
||||
final List<Map<String, String>> 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();
|
||||
|
|
|
@ -15,17 +15,12 @@
|
|||
*/
|
||||
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 {
|
||||
|
||||
|
@ -84,17 +79,6 @@ public class SynonymTests extends DictCrudTestBase {
|
|||
return updateMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
String response = checkGetMethod(searchBody, getListEndpointSuffix()).asString();
|
||||
final int total = JsonPath.from(response).getInt("response.total");
|
||||
final List<Map<String, String>> 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();
|
||||
|
|
Loading…
Add table
Reference in a new issue