refactoring for integration tests
This commit is contained in:
parent
7d4db6d2b6
commit
6ef0176f00
12 changed files with 354 additions and 1238 deletions
|
@ -16,9 +16,15 @@
|
|||
package org.codelibs.fess.it;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
@ -33,6 +39,8 @@ import io.restassured.specification.RequestSpecification;
|
|||
|
||||
public abstract class CrudTestBase extends ITBase {
|
||||
|
||||
protected static final int NUM = 20;
|
||||
|
||||
// ================
|
||||
// Abstract Methods
|
||||
// ================
|
||||
|
@ -46,15 +54,9 @@ public abstract class CrudTestBase extends ITBase {
|
|||
|
||||
abstract protected String getItemEndpointSuffix();
|
||||
|
||||
abstract protected void testCreate();
|
||||
abstract protected Map<String, Object> createTestParam(int id);
|
||||
|
||||
abstract protected void testRead();
|
||||
|
||||
abstract protected void testUpdate();
|
||||
|
||||
abstract protected void testDelete();
|
||||
|
||||
abstract protected void clearTestData();
|
||||
abstract protected Map<String, Object> getUpdateMap();
|
||||
|
||||
// ================
|
||||
|
||||
|
@ -70,7 +72,12 @@ public abstract class CrudTestBase extends ITBase {
|
|||
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
clearTestData();
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 10);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
checkDeleteMethod(getItemEndpointSuffix() + "/" + id);
|
||||
});
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
|
@ -78,6 +85,104 @@ public abstract class CrudTestBase extends ITBase {
|
|||
deleteTestToken();
|
||||
}
|
||||
|
||||
// ================
|
||||
// Bodies
|
||||
// ================
|
||||
protected void testCreate() {
|
||||
// Test: create setting api.
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final Map<String, Object> requestBody = createTestParam(i);
|
||||
checkPutMethod(requestBody, getItemEndpointSuffix()).then().body("response.created", equalTo(true))
|
||||
.body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
// Test: number of settings.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
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);
|
||||
List<String> nameList = getPropList(searchBody, getKeyProperty());
|
||||
|
||||
assertEquals(NUM, nameList.size());
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final String name = getNamePrefix() + i;
|
||||
assertTrue(nameList.contains(name), name);
|
||||
}
|
||||
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
// Test: get setting api
|
||||
checkGetMethod(searchBody, getItemEndpointSuffix() + "/" + id).then()
|
||||
.body("response." + getItemEndpointSuffix() + ".id", equalTo(id))
|
||||
.body("response." + getItemEndpointSuffix() + "." + getKeyProperty(), startsWith(getNamePrefix()));
|
||||
});
|
||||
|
||||
// Test: paging
|
||||
searchBody.put("size", 1);
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
searchBody.put("page", i + 1);
|
||||
checkGetMethod(searchBody, getListEndpointSuffix()).then().body("response." + getListEndpointSuffix() + ".size()", equalTo(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void testUpdate() {
|
||||
// Test: update settings api
|
||||
final Set<String> keySet = createTestParam(0).keySet();
|
||||
final Map<String, Object> updateMap = getUpdateMap();
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<Map<String, Object>> settings = getItemList(searchBody);
|
||||
|
||||
for (Map<String, Object> setting : settings) {
|
||||
final Map<String, Object> requestBody = new HashMap<>(updateMap);
|
||||
requestBody.put("version_no", 1);
|
||||
if (setting.containsKey("id")) {
|
||||
requestBody.put("id", setting.get("id"));
|
||||
}
|
||||
for (String key : keySet) {
|
||||
if (!requestBody.containsKey(key)) {
|
||||
requestBody.put(key, setting.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
checkPostMethod(requestBody, getItemEndpointSuffix()).then().body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
checkUpdate();
|
||||
}
|
||||
|
||||
protected void checkUpdate() {
|
||||
final Map<String, Object> updateMap = getUpdateMap();
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
for (Map.Entry<String, Object> entry : updateMap.entrySet()) {
|
||||
List<String> updatedList = getPropList(searchBody, entry.getKey());
|
||||
for (String val : updatedList) {
|
||||
assertEquals(val, entry.getValue().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void testDelete() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
|
||||
idList.forEach(id -> {
|
||||
//Test: delete setting api
|
||||
checkDeleteMethod(getItemEndpointSuffix() + "/" + id).then().body("response.status", equalTo(0));
|
||||
});
|
||||
|
||||
// Test: NUMber of settings.
|
||||
checkGetMethod(searchBody, getListEndpointSuffix()).then().body(getJsonPath() + ".size()", equalTo(0));
|
||||
}
|
||||
|
||||
// ================
|
||||
// Utilities
|
||||
// ================
|
||||
|
|
|
@ -16,10 +16,7 @@
|
|||
package org.codelibs.fess.it.admin;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -33,8 +30,6 @@ import io.restassured.path.json.JsonPath;
|
|||
|
||||
@Tag("it")
|
||||
public class AccessTokenTests extends CrudTestBase {
|
||||
private static final int NUM = 20;
|
||||
|
||||
private static final String NAME_PREFIX = "accessTokenTest_";
|
||||
private static final String API_PATH = "/api/admin/accesstoken";
|
||||
private static final String LIST_ENDPOINT_SUFFIX = "settings";
|
||||
|
@ -67,106 +62,30 @@ public class AccessTokenTests extends CrudTestBase {
|
|||
return ITEM_ENDPOINT_SUFFIX;
|
||||
}
|
||||
|
||||
@Test
|
||||
void crudTest() {
|
||||
testCreate();
|
||||
testRead();
|
||||
testUpdate();
|
||||
testDelete();
|
||||
}
|
||||
|
||||
@Test
|
||||
void functionTest() {
|
||||
testPermission();
|
||||
@Override
|
||||
protected Map<String, Object> createTestParam(int id) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + id;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("permissions", "Radmin-api");
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testCreate() {
|
||||
// Test: create setting api.
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("permissions", "Radmin-api");
|
||||
|
||||
checkPutMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.created", equalTo(true))
|
||||
.body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
// Test: NUMber of settings.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(NUM));
|
||||
protected Map<String, Object> getUpdateMap() {
|
||||
final Map<String, Object> updateMap = new HashMap<>();
|
||||
updateMap.put("permissions", "Radmin-api2");
|
||||
return updateMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
// Test: get settings api.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> propList = getPropList(searchBody, KEY_PROPERTY);
|
||||
assertEquals(NUM, propList.size());
|
||||
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final String prop = NAME_PREFIX + i;
|
||||
assertTrue(propList.contains(prop), prop);
|
||||
}
|
||||
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
// Test: get setting api
|
||||
checkGetMethod(searchBody, ITEM_ENDPOINT_SUFFIX + "/" + id).then()
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + ".id", equalTo(id))
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + "." + KEY_PROPERTY, startsWith(NAME_PREFIX))
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + ".token.length()", greaterThan(0));
|
||||
});
|
||||
|
||||
// Test: paging
|
||||
searchBody.put("size", 1);
|
||||
for (int i = 0; i < NUM + 1; i++) {
|
||||
searchBody.put("page", i + 1);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body("response." + LIST_ENDPOINT_SUFFIX + ".size()", equalTo(1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testUpdate() {
|
||||
// Test: update settings api
|
||||
protected void checkUpdate() {
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<Map<String, Object>> settings = getItemList(searchBody);
|
||||
|
||||
String newPermission = "Radmin-api2";
|
||||
for (Map<String, Object> setting : settings) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("id", setting.get("id"));
|
||||
requestBody.put(KEY_PROPERTY, setting.get(KEY_PROPERTY));
|
||||
requestBody.put("permissions", newPermission);
|
||||
requestBody.put("version_no", 1);
|
||||
|
||||
checkPostMethod(requestBody, "setting").then().body("response.status", equalTo(0));
|
||||
List<String> updatedList = getPropList(searchBody, "permissions");
|
||||
for (String val : updatedList) {
|
||||
assertEquals(val, "{role}admin-api2");
|
||||
}
|
||||
|
||||
searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> permissionsList = getPropList(searchBody, "permissions");
|
||||
for (String permissions : permissionsList) {
|
||||
assertEquals(newPermission.replace("R", "{role}"), permissions);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testDelete() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
//Test: delete setting api
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id).then().body("response.status", equalTo(0));
|
||||
});
|
||||
|
||||
// Test: NUMber of settings.
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(0));
|
||||
}
|
||||
|
||||
private void testPermission() {
|
||||
|
@ -186,13 +105,16 @@ public class AccessTokenTests extends CrudTestBase {
|
|||
.body("response." + ITEM_ENDPOINT_SUFFIX + ".token", equalTo(token));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTestData() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 10);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id);
|
||||
});
|
||||
@Test
|
||||
void crudTest() {
|
||||
testCreate();
|
||||
testRead();
|
||||
testUpdate();
|
||||
testDelete();
|
||||
}
|
||||
|
||||
@Test
|
||||
void functionTest() {
|
||||
testPermission();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,7 @@
|
|||
*/
|
||||
package org.codelibs.fess.it.admin;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.it.CrudTestBase;
|
||||
|
@ -31,8 +25,6 @@ import org.junit.jupiter.api.Test;
|
|||
@Tag("it")
|
||||
public class BoostDocTests extends CrudTestBase {
|
||||
|
||||
private static final int NUM = 20;
|
||||
|
||||
private static final String NAME_PREFIX = "boostDocTest_";
|
||||
private static final String API_PATH = "/api/admin/boostdoc";
|
||||
private static final String LIST_ENDPOINT_SUFFIX = "settings";
|
||||
|
@ -65,6 +57,23 @@ public class BoostDocTests extends CrudTestBase {
|
|||
return ITEM_ENDPOINT_SUFFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> createTestParam(int id) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + id;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("boost_expr", new Integer(id).toString());
|
||||
requestBody.put("sort_order", id);
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getUpdateMap() {
|
||||
final Map<String, Object> updateMap = new HashMap<>();
|
||||
updateMap.put("boost_expr", "new_boost_expr");
|
||||
return updateMap;
|
||||
}
|
||||
|
||||
@Test
|
||||
void crudTest() {
|
||||
testCreate();
|
||||
|
@ -72,107 +81,4 @@ public class BoostDocTests extends CrudTestBase {
|
|||
testUpdate();
|
||||
testDelete();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testCreate() {
|
||||
// Test: create setting api.
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("boost_expr", new Integer(i).toString());
|
||||
requestBody.put("sort_order", i);
|
||||
|
||||
checkPutMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.created", equalTo(true))
|
||||
.body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
// Test: number of settings.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(NUM));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
// Test: get settings api.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> nameList = getPropList(searchBody, KEY_PROPERTY);
|
||||
|
||||
assertEquals(NUM, nameList.size());
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final String name = NAME_PREFIX + i;
|
||||
assertTrue(nameList.contains(name), name);
|
||||
}
|
||||
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
// Test: get setting api
|
||||
checkGetMethod(searchBody, ITEM_ENDPOINT_SUFFIX + "/" + id).then()
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + ".id", equalTo(id))
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + "." + KEY_PROPERTY, startsWith(NAME_PREFIX));
|
||||
});
|
||||
|
||||
// Test: paging
|
||||
searchBody.put("size", 1);
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
searchBody.put("page", i + 1);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body("response." + LIST_ENDPOINT_SUFFIX + ".size()", equalTo(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testUpdate() {
|
||||
// Test: update settings api
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<Map<String, Object>> settings = getItemList(searchBody);
|
||||
|
||||
final String newBoostExpr = "new_boost_expr";
|
||||
for (Map<String, Object> setting : settings) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("id", setting.get("id"));
|
||||
requestBody.put(KEY_PROPERTY, setting.get(KEY_PROPERTY));
|
||||
requestBody.put("boost_expr", newBoostExpr);
|
||||
requestBody.put("sort_order", setting.get("sort_order"));
|
||||
requestBody.put("version_no", 1);
|
||||
|
||||
checkPostMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> boostExprList = getPropList(searchBody, "boost_expr");
|
||||
for (String boostExpr : boostExprList) {
|
||||
assertEquals(boostExpr, newBoostExpr);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testDelete() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
|
||||
idList.forEach(id -> {
|
||||
//Test: delete setting api
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id).then().body("response.status", equalTo(0));
|
||||
});
|
||||
|
||||
// Test: NUMber of settings.
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTestData() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 10);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,13 +15,7 @@
|
|||
*/
|
||||
package org.codelibs.fess.it.admin;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.it.CrudTestBase;
|
||||
|
@ -31,8 +25,6 @@ import org.junit.jupiter.api.Test;
|
|||
@Tag("it")
|
||||
public class DataConfigTests extends CrudTestBase {
|
||||
|
||||
private static final int NUM = 20;
|
||||
|
||||
private static final String NAME_PREFIX = "dataConfigTest_";
|
||||
private static final String API_PATH = "/api/admin/dataconfig";
|
||||
private static final String LIST_ENDPOINT_SUFFIX = "settings";
|
||||
|
@ -65,6 +57,26 @@ public class DataConfigTests extends CrudTestBase {
|
|||
return ITEM_ENDPOINT_SUFFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> createTestParam(int id) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + id;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
final String handlerName = "DatabaseDataStore";
|
||||
requestBody.put("handler_name", handlerName);
|
||||
requestBody.put("boost", id);
|
||||
requestBody.put("available", true);
|
||||
requestBody.put("sort_order", id);
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getUpdateMap() {
|
||||
final Map<String, Object> updateMap = new HashMap<>();
|
||||
updateMap.put("handler_name", "CsvDataStore");
|
||||
return updateMap;
|
||||
}
|
||||
|
||||
@Test
|
||||
void crudTest() {
|
||||
testCreate();
|
||||
|
@ -72,112 +84,4 @@ public class DataConfigTests extends CrudTestBase {
|
|||
testUpdate();
|
||||
testDelete();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testCreate() {
|
||||
// Test: create setting api.
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
final String handlerName = "DatabaseDataStore";
|
||||
requestBody.put("handler_name", handlerName);
|
||||
requestBody.put("boost", i);
|
||||
requestBody.put("available", true);
|
||||
requestBody.put("sort_order", i);
|
||||
|
||||
checkPutMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.created", equalTo(true))
|
||||
.body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
// Test: number of settings.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(NUM));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
// Test: get settings api.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> nameList = getPropList(searchBody, KEY_PROPERTY);
|
||||
|
||||
assertEquals(NUM, nameList.size());
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final String name = NAME_PREFIX + i;
|
||||
assertTrue(nameList.contains(name), name);
|
||||
}
|
||||
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
// Test: get setting api
|
||||
checkGetMethod(searchBody, ITEM_ENDPOINT_SUFFIX + "/" + id).then()
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + ".id", equalTo(id))
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + "." + KEY_PROPERTY, startsWith(NAME_PREFIX));
|
||||
});
|
||||
|
||||
// Test: paging
|
||||
searchBody.put("size", 1);
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
searchBody.put("page", i + 1);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body("response." + LIST_ENDPOINT_SUFFIX + ".size()", equalTo(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testUpdate() {
|
||||
// Test: update settings api
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<Map<String, Object>> settings = getItemList(searchBody);
|
||||
|
||||
final String newHandlerName = "CsvDataStore";
|
||||
for (Map<String, Object> setting : settings) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("id", setting.get("id"));
|
||||
requestBody.put(KEY_PROPERTY, setting.get(KEY_PROPERTY));
|
||||
requestBody.put("handler_name", newHandlerName);
|
||||
requestBody.put("boost", setting.get("boost"));
|
||||
requestBody.put("available", true);
|
||||
requestBody.put("sort_order", setting.get("sort_order"));
|
||||
requestBody.put("version_no", 1);
|
||||
|
||||
checkPostMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> handlerList = getPropList(searchBody, "handler_name");
|
||||
for (String handler : handlerList) {
|
||||
assertEquals(handler, newHandlerName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testDelete() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
|
||||
idList.forEach(id -> {
|
||||
//Test: delete setting api
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id).then().body("response.status", equalTo(0));
|
||||
});
|
||||
|
||||
// Test: NUMber of settings.
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTestData() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 10);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,13 +15,7 @@
|
|||
*/
|
||||
package org.codelibs.fess.it.admin;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.it.CrudTestBase;
|
||||
|
@ -30,7 +24,6 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
@Tag("it")
|
||||
public class DuplicateHostTests extends CrudTestBase {
|
||||
private static final int NUM = 20;
|
||||
|
||||
private static final String NAME_PREFIX = "duplicateHostTest_";
|
||||
private static final String API_PATH = "/api/admin/duplicatehost";
|
||||
|
@ -64,6 +57,23 @@ public class DuplicateHostTests extends CrudTestBase {
|
|||
return ITEM_ENDPOINT_SUFFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> createTestParam(int id) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + id;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("duplicate_host_name", "duplicate_" + new Integer(id).toString());
|
||||
requestBody.put("sort_order", id);
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getUpdateMap() {
|
||||
final Map<String, Object> updateMap = new HashMap<>();
|
||||
updateMap.put("duplicate_host_name", "new_duplicate_host");
|
||||
return updateMap;
|
||||
}
|
||||
|
||||
@Test
|
||||
void crudTest() {
|
||||
testCreate();
|
||||
|
@ -72,106 +82,4 @@ public class DuplicateHostTests extends CrudTestBase {
|
|||
testDelete();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testCreate() {
|
||||
// Test: create setting api.
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("duplicate_host_name", "duplicate_" + i);
|
||||
requestBody.put("sort_order", i);
|
||||
|
||||
checkPutMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.created", equalTo(true))
|
||||
.body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
// Test: number of settings.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(NUM));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
// Test: get settings api.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> propList = getPropList(searchBody, KEY_PROPERTY);
|
||||
|
||||
assertEquals(NUM, propList.size());
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
assertTrue(propList.contains(keyProp), keyProp);
|
||||
}
|
||||
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
// Test: get setting api
|
||||
checkGetMethod(searchBody, ITEM_ENDPOINT_SUFFIX + "/" + id).then()
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + ".id", equalTo(id))
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + "." + KEY_PROPERTY, startsWith(NAME_PREFIX));
|
||||
});
|
||||
|
||||
// Test: paging
|
||||
searchBody.put("size", 1);
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
searchBody.put("page", i + 1);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body("response." + LIST_ENDPOINT_SUFFIX + ".size()", equalTo(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testUpdate() {
|
||||
// Test: update settings api
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<Map<String, Object>> settings = getItemList(searchBody);
|
||||
|
||||
final String newDHostName = "newDuplicateHost";
|
||||
for (Map<String, Object> setting : settings) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("id", setting.get("id"));
|
||||
requestBody.put(KEY_PROPERTY, setting.get(KEY_PROPERTY));
|
||||
requestBody.put("duplicate_host_name", newDHostName);
|
||||
requestBody.put("sort_order", setting.get("sort_order"));
|
||||
requestBody.put("version_no", 1);
|
||||
|
||||
checkPostMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> valueList = getPropList(searchBody, "duplicate_host_name");
|
||||
for (String value : valueList) {
|
||||
assertEquals(value, newDHostName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testDelete() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
|
||||
idList.forEach(id -> {
|
||||
//Test: delete setting api
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id).then().body("response.status", equalTo(0));
|
||||
});
|
||||
|
||||
// Test: NUMber of settings.
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTestData() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 10);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,13 +15,7 @@
|
|||
*/
|
||||
package org.codelibs.fess.it.admin;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.it.CrudTestBase;
|
||||
|
@ -31,8 +25,6 @@ import org.junit.jupiter.api.Test;
|
|||
@Tag("it")
|
||||
public class FileConfigTests extends CrudTestBase {
|
||||
|
||||
private static final int NUM = 20;
|
||||
|
||||
private static final String NAME_PREFIX = "fileConfigTest_";
|
||||
private static final String API_PATH = "/api/admin/fileconfig";
|
||||
private static final String LIST_ENDPOINT_SUFFIX = "settings";
|
||||
|
@ -65,6 +57,28 @@ public class FileConfigTests extends CrudTestBase {
|
|||
return ITEM_ENDPOINT_SUFFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> createTestParam(int id) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + id;
|
||||
final String paths = "file:///" + NAME_PREFIX + id;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("paths", paths);
|
||||
requestBody.put("num_of_thread", 5);
|
||||
requestBody.put("interval_time", 1000);
|
||||
requestBody.put("boost", id);
|
||||
requestBody.put("available", true);
|
||||
requestBody.put("sort_order", id);
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getUpdateMap() {
|
||||
final Map<String, Object> updateMap = new HashMap<>();
|
||||
updateMap.put("paths", "file:///new/path");
|
||||
return updateMap;
|
||||
}
|
||||
|
||||
@Test
|
||||
void crudTest() {
|
||||
testCreate();
|
||||
|
@ -72,117 +86,4 @@ public class FileConfigTests extends CrudTestBase {
|
|||
testUpdate();
|
||||
testDelete();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testCreate() {
|
||||
// Test: create setting api.
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
final String paths = "file:///" + NAME_PREFIX + i;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("paths", paths);
|
||||
requestBody.put("num_of_thread", 5);
|
||||
requestBody.put("interval_time", 1000);
|
||||
requestBody.put("boost", i);
|
||||
requestBody.put("available", true);
|
||||
requestBody.put("sort_order", i);
|
||||
|
||||
checkPutMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.created", equalTo(true))
|
||||
.body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
// Test: number of settings.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(NUM));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
// Test: get settings api.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> propList = getPropList(searchBody, KEY_PROPERTY);
|
||||
|
||||
assertEquals(NUM, propList.size());
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final String prop = NAME_PREFIX + i;
|
||||
assertTrue(propList.contains(prop), prop);
|
||||
}
|
||||
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
// Test: get setting api
|
||||
checkGetMethod(searchBody, ITEM_ENDPOINT_SUFFIX + "/" + id).then()
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + ".id", equalTo(id))
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + "." + KEY_PROPERTY, startsWith(NAME_PREFIX));
|
||||
});
|
||||
|
||||
// Test: paging
|
||||
searchBody.put("size", 1);
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
searchBody.put("page", i + 1);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body("response." + LIST_ENDPOINT_SUFFIX + ".size()", equalTo(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testUpdate() {
|
||||
// Test: update settings api
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<Map<String, Object>> settings = getItemList(searchBody);
|
||||
|
||||
final String newPaths = "file:///new/" + NAME_PREFIX;
|
||||
for (Map<String, Object> setting : settings) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
|
||||
requestBody.put("id", setting.get("id"));
|
||||
requestBody.put(KEY_PROPERTY, setting.get(KEY_PROPERTY));
|
||||
requestBody.put("paths", newPaths);
|
||||
requestBody.put("num_of_thread", setting.get("num_of_thread"));
|
||||
requestBody.put("interval_time", setting.get("interval_time"));
|
||||
requestBody.put("boost", setting.get("boost"));
|
||||
requestBody.put("available", true);
|
||||
requestBody.put("sort_order", setting.get("sort_order"));
|
||||
requestBody.put("version_no", 1);
|
||||
|
||||
checkPostMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> valList = getPropList(searchBody, "paths");
|
||||
for (String val : valList) {
|
||||
assertEquals(val, newPaths);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testDelete() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
|
||||
idList.forEach(id -> {
|
||||
//Test: delete setting api
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id).then().body("response.status", equalTo(0));
|
||||
});
|
||||
|
||||
// Test: NUMber of settings.
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTestData() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 10);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
*/
|
||||
package org.codelibs.fess.it.admin;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
|
@ -32,7 +30,6 @@ import io.restassured.path.json.JsonPath;
|
|||
|
||||
@Tag("it")
|
||||
public class GroupTests extends CrudTestBase {
|
||||
private static final int NUM = 20;
|
||||
|
||||
private static final String NAME_PREFIX = "groupTest_";
|
||||
private static final String API_PATH = "/api/admin/group";
|
||||
|
@ -66,6 +63,41 @@ public class GroupTests extends CrudTestBase {
|
|||
return ITEM_ENDPOINT_SUFFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> createTestParam(int id) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + id;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
final Map<String, String> attributes = new HashMap<>();
|
||||
attributes.put("gidNumber", new Integer(id).toString());
|
||||
requestBody.put("attributes", attributes);
|
||||
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getUpdateMap() {
|
||||
final Map<String, Object> updateMap = new HashMap<>();
|
||||
final Map<String, String> newAttributes = new HashMap<>();
|
||||
newAttributes.put("gidNumber", "100");
|
||||
updateMap.put("attributes", newAttributes);
|
||||
|
||||
return updateMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkUpdate() {
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
String response = checkGetMethod(searchBody, getListEndpointSuffix()).asString();
|
||||
List<Map<String, String>> attrList = JsonPath.from(response).getList(getJsonPath() + ".attributes");
|
||||
assertEquals(NUM, attrList.size());
|
||||
for (Map<String, String> attr : attrList) {
|
||||
assertTrue(attr.containsKey("gidNumber"));
|
||||
assertEquals(attr.get("gidNumber"), "100");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void crudTest() {
|
||||
testCreate();
|
||||
|
@ -73,111 +105,4 @@ public class GroupTests extends CrudTestBase {
|
|||
testUpdate();
|
||||
testDelete();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testCreate() {
|
||||
// Test: create setting api.
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
final Map<String, String> attributes = new HashMap<>();
|
||||
attributes.put("gidNumber", new Integer(i).toString());
|
||||
requestBody.put("attributes", attributes);
|
||||
|
||||
checkPutMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.created", equalTo(true))
|
||||
.body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
// Test: number of settings.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(NUM));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
// Test: get settings api.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> propList = getPropList(searchBody, KEY_PROPERTY);
|
||||
|
||||
assertEquals(NUM, propList.size());
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
assertTrue(propList.contains(keyProp), keyProp);
|
||||
}
|
||||
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
// Test: get setting api
|
||||
checkGetMethod(searchBody, ITEM_ENDPOINT_SUFFIX + "/" + id).then()
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + ".id", equalTo(id))
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + "." + KEY_PROPERTY, startsWith(NAME_PREFIX));
|
||||
});
|
||||
|
||||
// Test: paging
|
||||
searchBody.put("size", 1);
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
searchBody.put("page", i + 1);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body("response." + LIST_ENDPOINT_SUFFIX + ".size()", equalTo(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testUpdate() {
|
||||
// Test: update settings api
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<Map<String, Object>> settings = getItemList(searchBody);
|
||||
|
||||
final Map<String, String> newAttributes = new HashMap<>();
|
||||
newAttributes.put("gidNumber", "100");
|
||||
for (Map<String, Object> setting : settings) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("id", setting.get("id"));
|
||||
requestBody.put(KEY_PROPERTY, setting.get(KEY_PROPERTY));
|
||||
requestBody.put("attributes", newAttributes);
|
||||
requestBody.put("version_no", 1);
|
||||
|
||||
checkPostMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
String response = checkGetMethod(searchBody, getListEndpointSuffix()).asString();
|
||||
List<Map<String, String>> attrList = JsonPath.from(response).getList(getJsonPath() + ".attributes");
|
||||
assertEquals(settings.size(), attrList.size());
|
||||
for (Map<String, String> attr : attrList) {
|
||||
assertTrue(attr.containsKey("gidNumber"));
|
||||
assertEquals(attr.get("gidNumber"), "100");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testDelete() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
|
||||
idList.forEach(id -> {
|
||||
//Test: delete setting api
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id).then().body("response.status", equalTo(0));
|
||||
});
|
||||
|
||||
// Test: NUMber of settings.
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTestData() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 10);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,13 +15,7 @@
|
|||
*/
|
||||
package org.codelibs.fess.it.admin;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.it.CrudTestBase;
|
||||
|
@ -30,7 +24,6 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
@Tag("it")
|
||||
public class KeyMatchTests extends CrudTestBase {
|
||||
private static final int NUM = 20;
|
||||
|
||||
private static final String NAME_PREFIX = "keyMatchTest_";
|
||||
private static final String API_PATH = "/api/admin/keymatch";
|
||||
|
@ -64,6 +57,25 @@ public class KeyMatchTests extends CrudTestBase {
|
|||
return ITEM_ENDPOINT_SUFFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> createTestParam(int id) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + id;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("query", "query" + id);
|
||||
requestBody.put("max_size", new Integer(id).toString());
|
||||
requestBody.put("boost", 100);
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getUpdateMap() {
|
||||
final Map<String, Object> updateMap = new HashMap<>();
|
||||
updateMap.put("query", "new_query");
|
||||
return updateMap;
|
||||
}
|
||||
|
||||
@Test
|
||||
void crudTest() {
|
||||
testCreate();
|
||||
|
@ -71,109 +83,4 @@ public class KeyMatchTests extends CrudTestBase {
|
|||
testUpdate();
|
||||
testDelete();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testCreate() {
|
||||
// Test: create setting api.
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("query", "query" + i);
|
||||
requestBody.put("max_size", new Integer(i).toString());
|
||||
requestBody.put("boost", 100);
|
||||
|
||||
checkPutMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.created", equalTo(true))
|
||||
.body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
// Test: number of settings.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(NUM));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
// Test: get settings api.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> propList = getPropList(searchBody, KEY_PROPERTY);
|
||||
|
||||
assertEquals(NUM, propList.size());
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
assertTrue(propList.contains(keyProp), keyProp);
|
||||
}
|
||||
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
// Test: get setting api
|
||||
checkGetMethod(searchBody, ITEM_ENDPOINT_SUFFIX + "/" + id).then()
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + ".id", equalTo(id))
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + "." + KEY_PROPERTY, startsWith(NAME_PREFIX));
|
||||
});
|
||||
|
||||
// Test: paging
|
||||
searchBody.put("size", 1);
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
searchBody.put("page", i + 1);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body("response." + LIST_ENDPOINT_SUFFIX + ".size()", equalTo(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testUpdate() {
|
||||
// Test: update settings api
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<Map<String, Object>> settings = getItemList(searchBody);
|
||||
|
||||
final String newQuery = "new_query";
|
||||
for (Map<String, Object> setting : settings) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("id", setting.get("id"));
|
||||
requestBody.put(KEY_PROPERTY, setting.get(KEY_PROPERTY));
|
||||
requestBody.put("query", newQuery);
|
||||
requestBody.put("max_size", setting.get("max_size"));
|
||||
requestBody.put("boost", setting.get("boost"));
|
||||
requestBody.put("version_no", 1);
|
||||
|
||||
checkPostMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> valueList = getPropList(searchBody, "query");
|
||||
for (String value : valueList) {
|
||||
assertEquals(value, newQuery);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testDelete() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
|
||||
idList.forEach(id -> {
|
||||
//Test: delete setting api
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id).then().body("response.status", equalTo(0));
|
||||
});
|
||||
|
||||
// Test: NUMber of settings.
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTestData() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 10);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,13 +15,7 @@
|
|||
*/
|
||||
package org.codelibs.fess.it.admin;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.it.CrudTestBase;
|
||||
|
@ -30,7 +24,6 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
@Tag("it")
|
||||
public class LabelTypeTests extends CrudTestBase {
|
||||
private static final int NUM = 20;
|
||||
|
||||
private static final String NAME_PREFIX = "labelTypeTest_";
|
||||
private static final String API_PATH = "/api/admin/labeltype";
|
||||
|
@ -64,6 +57,22 @@ public class LabelTypeTests extends CrudTestBase {
|
|||
return ITEM_ENDPOINT_SUFFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> createTestParam(int id) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + id;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("value", new Integer(id).toString());
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getUpdateMap() {
|
||||
final Map<String, Object> updateMap = new HashMap<>();
|
||||
updateMap.put("value", "newValue");
|
||||
return updateMap;
|
||||
}
|
||||
|
||||
@Test
|
||||
void crudTest() {
|
||||
testCreate();
|
||||
|
@ -71,105 +80,4 @@ public class LabelTypeTests extends CrudTestBase {
|
|||
testUpdate();
|
||||
testDelete();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testCreate() {
|
||||
// Test: create setting api.
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("value", new Integer(i).toString());
|
||||
|
||||
checkPutMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.created", equalTo(true))
|
||||
.body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
// Test: number of settings.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(NUM));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
// Test: get settings api.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> propList = getPropList(searchBody, KEY_PROPERTY);
|
||||
|
||||
assertEquals(NUM, propList.size());
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
assertTrue(propList.contains(keyProp), keyProp);
|
||||
}
|
||||
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
// Test: get setting api
|
||||
checkGetMethod(searchBody, ITEM_ENDPOINT_SUFFIX + "/" + id).then()
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + ".id", equalTo(id))
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + "." + KEY_PROPERTY, startsWith(NAME_PREFIX));
|
||||
});
|
||||
|
||||
// Test: paging
|
||||
searchBody.put("size", 1);
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
searchBody.put("page", i + 1);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body("response." + LIST_ENDPOINT_SUFFIX + ".size()", equalTo(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testUpdate() {
|
||||
// Test: update settings api
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<Map<String, Object>> settings = getItemList(searchBody);
|
||||
|
||||
final String newValue = "newvalue";
|
||||
for (Map<String, Object> setting : settings) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("id", setting.get("id"));
|
||||
requestBody.put(KEY_PROPERTY, setting.get(KEY_PROPERTY));
|
||||
requestBody.put("value", newValue);
|
||||
requestBody.put("version_no", 1);
|
||||
|
||||
checkPostMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> valueList = getPropList(searchBody, "value");
|
||||
for (String value : valueList) {
|
||||
assertEquals(value, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testDelete() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
|
||||
idList.forEach(id -> {
|
||||
//Test: delete setting api
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id).then().body("response.status", equalTo(0));
|
||||
});
|
||||
|
||||
// Test: NUMber of settings.
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTestData() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 10);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,13 +15,7 @@
|
|||
*/
|
||||
package org.codelibs.fess.it.admin;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.it.CrudTestBase;
|
||||
|
@ -30,7 +24,6 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
@Tag("it")
|
||||
public class PathMapTests extends CrudTestBase {
|
||||
private static final int NUM = 20;
|
||||
|
||||
private static final String NAME_PREFIX = "pathMapTest_";
|
||||
private static final String API_PATH = "/api/admin/pathmap";
|
||||
|
@ -64,6 +57,24 @@ public class PathMapTests extends CrudTestBase {
|
|||
return ITEM_ENDPOINT_SUFFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> createTestParam(int id) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + id;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("replacement", "replacement" + id);
|
||||
requestBody.put("process_type", "C");
|
||||
requestBody.put("sort_order", id);
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getUpdateMap() {
|
||||
final Map<String, Object> updateMap = new HashMap<>();
|
||||
updateMap.put("process_type", "D");
|
||||
return updateMap;
|
||||
}
|
||||
|
||||
@Test
|
||||
void crudTest() {
|
||||
testCreate();
|
||||
|
@ -71,109 +82,4 @@ public class PathMapTests extends CrudTestBase {
|
|||
testUpdate();
|
||||
testDelete();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testCreate() {
|
||||
// Test: create setting api.
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("replacement", "replacement" + i);
|
||||
requestBody.put("process_type", "C");
|
||||
requestBody.put("sort_order", i);
|
||||
|
||||
checkPutMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.created", equalTo(true))
|
||||
.body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
// Test: number of settings.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(NUM));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
// Test: get settings api.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> propList = getPropList(searchBody, KEY_PROPERTY);
|
||||
|
||||
assertEquals(NUM, propList.size());
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
assertTrue(propList.contains(keyProp), keyProp);
|
||||
}
|
||||
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
// Test: get setting api
|
||||
checkGetMethod(searchBody, ITEM_ENDPOINT_SUFFIX + "/" + id).then()
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + ".id", equalTo(id))
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + "." + KEY_PROPERTY, startsWith(NAME_PREFIX));
|
||||
});
|
||||
|
||||
// Test: paging
|
||||
searchBody.put("size", 1);
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
searchBody.put("page", i + 1);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body("response." + LIST_ENDPOINT_SUFFIX + ".size()", equalTo(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testUpdate() {
|
||||
// Test: update settings api
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<Map<String, Object>> settings = getItemList(searchBody);
|
||||
|
||||
final String newProcessType = "D";
|
||||
for (Map<String, Object> setting : settings) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("id", setting.get("id"));
|
||||
requestBody.put(KEY_PROPERTY, setting.get(KEY_PROPERTY));
|
||||
requestBody.put("replacement", setting.get("replacement"));
|
||||
requestBody.put("process_type", newProcessType);
|
||||
requestBody.put("sort_order", setting.get("sort_order"));
|
||||
requestBody.put("version_no", 1);
|
||||
|
||||
checkPostMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> valueList = getPropList(searchBody, "process_type");
|
||||
for (String value : valueList) {
|
||||
assertEquals(value, newProcessType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testDelete() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
|
||||
idList.forEach(id -> {
|
||||
//Test: delete setting api
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id).then().body("response.status", equalTo(0));
|
||||
});
|
||||
|
||||
// Test: NUMber of settings.
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTestData() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 10);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,9 +15,6 @@
|
|||
*/
|
||||
package org.codelibs.fess.it.admin;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -30,7 +27,6 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
@Tag("it")
|
||||
public class RoleTests extends CrudTestBase {
|
||||
private static final int NUM = 20;
|
||||
|
||||
private static final String NAME_PREFIX = "roleTest_";
|
||||
private static final String API_PATH = "/api/admin/role";
|
||||
|
@ -64,6 +60,33 @@ public class RoleTests extends CrudTestBase {
|
|||
return ITEM_ENDPOINT_SUFFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> createTestParam(int id) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + id;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
private static final String NEW_SUFFIX = "_new";
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getUpdateMap() {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put(KEY_PROPERTY, NAME_PREFIX + NEW_SUFFIX);
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkUpdate() {
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> valueList = getPropList(searchBody, KEY_PROPERTY);
|
||||
for (String value : valueList) {
|
||||
assertTrue(value.endsWith(NEW_SUFFIX));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void crudTest() {
|
||||
testCreate();
|
||||
|
@ -71,103 +94,4 @@ public class RoleTests extends CrudTestBase {
|
|||
testUpdate();
|
||||
testDelete();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testCreate() {
|
||||
// Test: create setting api.
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
|
||||
checkPutMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.created", equalTo(true))
|
||||
.body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
// Test: number of settings.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(NUM));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
// Test: get settings api.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> propList = getPropList(searchBody, KEY_PROPERTY);
|
||||
|
||||
assertEquals(NUM, propList.size());
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
assertTrue(propList.contains(keyProp), keyProp);
|
||||
}
|
||||
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
// Test: get setting api
|
||||
checkGetMethod(searchBody, ITEM_ENDPOINT_SUFFIX + "/" + id).then()
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + ".id", equalTo(id))
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + "." + KEY_PROPERTY, startsWith(NAME_PREFIX));
|
||||
});
|
||||
|
||||
// Test: paging
|
||||
searchBody.put("size", 1);
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
searchBody.put("page", i + 1);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body("response." + LIST_ENDPOINT_SUFFIX + ".size()", equalTo(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testUpdate() {
|
||||
// Test: update settings api
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<Map<String, Object>> settings = getItemList(searchBody);
|
||||
|
||||
final String newPrefix = "new_";
|
||||
for (Map<String, Object> setting : settings) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("id", setting.get("id"));
|
||||
requestBody.put(KEY_PROPERTY, newPrefix + setting.get(KEY_PROPERTY));
|
||||
requestBody.put("version_no", 1);
|
||||
|
||||
checkPostMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> valueList = getPropList(searchBody, KEY_PROPERTY);
|
||||
for (String value : valueList) {
|
||||
assertTrue(value.startsWith(newPrefix));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testDelete() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
|
||||
idList.forEach(id -> {
|
||||
//Test: delete setting api
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id).then().body("response.status", equalTo(0));
|
||||
});
|
||||
|
||||
// Test: NUMber of settings.
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTestData() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 10);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,13 +15,7 @@
|
|||
*/
|
||||
package org.codelibs.fess.it.admin;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.it.CrudTestBase;
|
||||
|
@ -31,8 +25,6 @@ import org.junit.jupiter.api.Test;
|
|||
@Tag("it")
|
||||
public class WebConfigTests extends CrudTestBase {
|
||||
|
||||
private static final int NUM = 20;
|
||||
|
||||
private static final String NAME_PREFIX = "webConfigTest_";
|
||||
private static final String API_PATH = "/api/admin/webconfig";
|
||||
private static final String LIST_ENDPOINT_SUFFIX = "settings";
|
||||
|
@ -65,6 +57,29 @@ public class WebConfigTests extends CrudTestBase {
|
|||
return ITEM_ENDPOINT_SUFFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> createTestParam(int id) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + id;
|
||||
final String urls = "http://" + NAME_PREFIX + id;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("urls", urls);
|
||||
requestBody.put("user_agent", "Mozilla/5.0");
|
||||
requestBody.put("num_of_thread", 5);
|
||||
requestBody.put("interval_time", 1000);
|
||||
requestBody.put("boost", id);
|
||||
requestBody.put("available", true);
|
||||
requestBody.put("sort_order", id);
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getUpdateMap() {
|
||||
final Map<String, Object> updateMap = new HashMap<>();
|
||||
updateMap.put("urls", "http://new." + NAME_PREFIX);
|
||||
return updateMap;
|
||||
}
|
||||
|
||||
@Test
|
||||
void crudTest() {
|
||||
testCreate();
|
||||
|
@ -72,119 +87,4 @@ public class WebConfigTests extends CrudTestBase {
|
|||
testUpdate();
|
||||
testDelete();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testCreate() {
|
||||
// Test: create setting api.
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
final String keyProp = NAME_PREFIX + i;
|
||||
final String urls = "http://" + NAME_PREFIX + i;
|
||||
requestBody.put(KEY_PROPERTY, keyProp);
|
||||
requestBody.put("urls", urls);
|
||||
requestBody.put("user_agent", "Mozilla/5.0");
|
||||
requestBody.put("num_of_thread", 5);
|
||||
requestBody.put("interval_time", 1000);
|
||||
requestBody.put("boost", i);
|
||||
requestBody.put("available", true);
|
||||
requestBody.put("sort_order", i);
|
||||
|
||||
checkPutMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.created", equalTo(true))
|
||||
.body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
// Test: number of settings.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(NUM));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testRead() {
|
||||
// Test: get settings api.
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> propList = getPropList(searchBody, KEY_PROPERTY);
|
||||
|
||||
assertEquals(NUM, propList.size());
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
final String prop = NAME_PREFIX + i;
|
||||
assertTrue(propList.contains(prop), prop);
|
||||
}
|
||||
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
// Test: get setting api
|
||||
checkGetMethod(searchBody, ITEM_ENDPOINT_SUFFIX + "/" + id).then()
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + ".id", equalTo(id))
|
||||
.body("response." + ITEM_ENDPOINT_SUFFIX + "." + KEY_PROPERTY, startsWith(NAME_PREFIX));
|
||||
});
|
||||
|
||||
// Test: paging
|
||||
searchBody.put("size", 1);
|
||||
for (int i = 0; i < NUM; i++) {
|
||||
searchBody.put("page", i + 1);
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body("response." + LIST_ENDPOINT_SUFFIX + ".size()", equalTo(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testUpdate() {
|
||||
// Test: update settings api
|
||||
Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<Map<String, Object>> settings = getItemList(searchBody);
|
||||
|
||||
final String newUrls = "http://new." + NAME_PREFIX;
|
||||
for (Map<String, Object> setting : settings) {
|
||||
final Map<String, Object> requestBody = new HashMap<>();
|
||||
|
||||
requestBody.put("id", setting.get("id"));
|
||||
requestBody.put(KEY_PROPERTY, setting.get(KEY_PROPERTY));
|
||||
requestBody.put("urls", newUrls);
|
||||
requestBody.put("user_agent", setting.get("user_agent"));
|
||||
requestBody.put("num_of_thread", setting.get("num_of_thread"));
|
||||
requestBody.put("interval_time", setting.get("interval_time"));
|
||||
requestBody.put("boost", setting.get("boost"));
|
||||
requestBody.put("available", true);
|
||||
requestBody.put("sort_order", setting.get("sort_order"));
|
||||
requestBody.put("version_no", 1);
|
||||
|
||||
checkPostMethod(requestBody, ITEM_ENDPOINT_SUFFIX).then().body("response.status", equalTo(0));
|
||||
}
|
||||
|
||||
searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> valList = getPropList(searchBody, "urls");
|
||||
for (String val : valList) {
|
||||
assertEquals(val, newUrls);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void testDelete() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 2);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
|
||||
idList.forEach(id -> {
|
||||
//Test: delete setting api
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id).then().body("response.status", equalTo(0));
|
||||
});
|
||||
|
||||
// Test: NUMber of settings.
|
||||
checkGetMethod(searchBody, LIST_ENDPOINT_SUFFIX).then().body(getJsonPath() + ".size()", equalTo(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearTestData() {
|
||||
final Map<String, Object> searchBody = new HashMap<>();
|
||||
searchBody.put("size", NUM * 10);
|
||||
List<String> idList = getPropList(searchBody, "id");
|
||||
idList.forEach(id -> {
|
||||
checkDeleteMethod(ITEM_ENDPOINT_SUFFIX + "/" + id);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue