промежуточный. тестирую новую версий конфигураций

This commit is contained in:
2024-09-15 01:36:19 +03:00
parent 1e782daa3d
commit 7ea64c49d1
18 changed files with 488 additions and 52 deletions

View File

@@ -1,18 +1,113 @@
package TestingSystem.Common;
import Common.Database.DBObject;
import Common.Database.riDBObject;
import Common.Global;
import Common.Utils.Utils;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Test.Test;
import com.sun.org.glassfish.gmbal.Description;
import java.util.LinkedHashMap;
import java.util.Vector;
public class Configuration extends riDBObject {
public int maxtime = 300; //лимит времени пуска задачи, входящей в пакет тестов
//конфигурация = данные для пакета.
//группы
//тесты
//настройки тестируемого объекта
//пакет = запуск конфигурация + тестируемый объект
//---
@Description("DEFAULT ''")
public String packedGroupsIds = "";
@Description("DEFAULT ''")
public String packedTestsIds = "";
//---
@Description("DEFAULT ''")
public String packedGroupsNames = "";
//---
@Description("DEFAULT 0")
public int groupsCount = 0;
@Description("DEFAULT 0")
public int testsCount = 0;
//--
public int maxtime = 300;
@Description("DEFAULT 0")
public int autoTesting = 0;
public String printAuto(){
return autoTesting>0? "Да":"Нет";
}
//--
public String getFlags(){return "";}
public Vector<String> getFlagsArray(){return new Vector<>();}
public Vector<String> getGroupsNamesArray(){
return Utils.unpack_s(packedGroupsNames,"\n");
}
//--
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
Configuration c = (Configuration) src;
//--
packedGroupsIds = c.packedGroupsIds;
packedTestsIds = c.packedTestsIds;
//-
packedGroupsNames = c.packedGroupsNames;
//-
groupsCount = c.groupsCount;
testsCount = c.testsCount;
//-
maxtime = c.maxtime;
autoTesting= c.autoTesting;
}
//-
public void saveGroups(Vector<Group> new_groups) {
Vector<String> res = new Vector<>();
Vector<String> names = new Vector<>();
for (Group group : new_groups) {
res.add(String.valueOf(group.id));
names.add(group.description);
}
packedGroupsIds = String.join("\n", res);
packedGroupsNames = String.join("\n", names);
groupsCount = new_groups.size();
}
public void saveTests(Vector<Test> new_tests) {
Vector<String> res = new Vector<>();
for (Test test : new_tests)
res.add(String.valueOf(test.id));
packedTestsIds = String.join("\n", res);
testsCount = new_tests.size();
}
//--
public Vector<Group> getGroups() {
Vector<Group> res = new Vector<>();
for (int o_id : Utils.unpackIntegers(packedGroupsIds, "\n"))
if (Global.testingServer.db.groups.containsKey(o_id))
res.add(Global.testingServer.db.groups.get(o_id));
return res;
}
public Vector<Test> getTests() {
Vector<Test> res = new Vector<>();
for (int o_id : Utils.unpackIntegers(packedTestsIds, "\n"))
if (Global.testingServer.db.tests.containsKey(o_id))
res.add(Global.testingServer.db.tests.get(o_id));
return res;
}
public Vector<Test> getTests(Vector<Group> groups, LinkedHashMap<Integer, Vector<Test>> testByGroups) {
Vector<Test> res = new Vector<>();
for (int o_id : Utils.unpackIntegers(packedTestsIds, "\n"))
if (Global.testingServer.db.tests.containsKey(o_id))
res.add(Global.testingServer.db.tests.get(o_id));
//--
for (Group group: groups){
Vector<Test> groupTests = new Vector<>();
for (Test test:res){
if (test.group_id==group.id)
groupTests.add(test);
}
testByGroups.put(group.id, groupTests);
}
//--
return res;
}
}

View File

@@ -47,6 +47,7 @@ public abstract class TestingPackage<J> extends riDBObject {
public int groupsCount = 0;
@Description("DEFAULT 0")
public int testsCount = 0;
//--
public TasksPackageState state = TasksPackageState.Draft;
//--
@@ -111,21 +112,21 @@ public abstract class TestingPackage<J> extends riDBObject {
}
public Vector<DVMConfiguration> getConfigurations() {
Vector<DVMConfiguration> res = new Vector<>();
for (int o_id : Utils.unpack(packedConfigurations))
for (int o_id : Utils.unpackIntegers(packedConfigurations, "\n"))
if (Global.testingServer.db.dvm_configurations.containsKey(o_id))
res.add(Global.testingServer.db.dvm_configurations.get(o_id));
return res;
}
public Vector<Group> getGroups() {
Vector<Group> res = new Vector<>();
for (int o_id : Utils.unpack(packedGroups))
for (int o_id : Utils.unpackIntegers(packedGroups, "\n"))
if (Global.testingServer.db.groups.containsKey(o_id))
res.add(Global.testingServer.db.groups.get(o_id));
return res;
}
public Vector<Test> getTests() {
Vector<Test> res = new Vector<>();
for (int o_id : Utils.unpack(packedTests))
for (int o_id : Utils.unpackIntegers(packedTests, "\n"))
if (Global.testingServer.db.tests.containsKey(o_id))
res.add(Global.testingServer.db.tests.get(o_id));
return res;

View File

@@ -55,7 +55,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
);
}
}
/*
else if (object instanceof DVMPackage) {
DVMPackage dvmPackage = (DVMPackage) object;
//--
@@ -65,11 +64,11 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
dvmPackage.package_json = null; // объект больше не нужен.
//--
}
*/
else if (object instanceof SapforPackage) {
((SapforPackage) object).init();
}
}
/*
@Override
protected void afterEditAction(DBObject object) throws Exception {
if (object instanceof DVMPackage) {
@@ -84,6 +83,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
}
}
}
*/
@Override
public void afterDeleteAction(DBObject object) throws Exception {
if (object instanceof Test) {

View File

@@ -11,7 +11,7 @@ import TestingSystem.Common.Group.GroupsDBTable;
import TestingSystem.Common.Test.Test;
import TestingSystem.Common.Test.TestDBTable;
import TestingSystem.Common.TestingPackageToKill.TestingPackagesToKillDBTable;
import TestingSystem.DVM.Configuration.ConfigurationDBTable;
import TestingSystem.DVM.Configuration.DVMConfigurationDBTable;
import TestingSystem.DVM.DVMPackage.DVMPackage;
import TestingSystem.DVM.DVMPackage.DVMPackageDBTable;
import TestingSystem.DVM.DVMTasks.DVMRunTasksSet;
@@ -34,7 +34,7 @@ import java.util.LinkedHashMap;
import java.util.Vector;
public class TestsDatabase extends SQLiteDatabase {
public ConfigurationDBTable dvm_configurations;
public DVMConfigurationDBTable dvm_configurations;
public TestDBTable tests;
public GroupsDBTable groups;
public DVMPackageDBTable dvmPackages;
@@ -54,7 +54,7 @@ public class TestsDatabase extends SQLiteDatabase {
}
@Override
protected void initAllTables() throws Exception {
addTable(dvm_configurations = new ConfigurationDBTable());
addTable(dvm_configurations = new DVMConfigurationDBTable());
addTable(groups = new GroupsDBTable());
addTable(tests = new TestDBTable());
addTable(dvmPackages = new DVMPackageDBTable());