Рефакторинг конструкторов объектов тестирования.

This commit is contained in:
2024-10-01 17:33:08 +03:00
parent b89283fc91
commit d18eb3327e
44 changed files with 1048 additions and 993 deletions

View File

@@ -13,18 +13,17 @@ import TestingSystem.Common.Test.Test;
import java.util.LinkedHashMap;
import java.util.Vector;
public class ConfigurationCache extends VisualCache{
public class ConfigurationCache extends VisualCache {
public GroupsJson groupsJson = null;
public TestsJson testsJson = null;
public SettingsArrayJson settingsJson = null;
public String settingsSummary = null;
public Vector<String> groupsSummary= null;
public Vector<String> groupsSummary = null;
//--
public ConfigurationCache(Configuration configuration) {
if (configuration.packedGroupsJson.isEmpty()) {
groupsJson = new GroupsJson(); //просто пустой
}
else {
} else {
groupsJson = Utils.gson.fromJson(configuration.packedGroupsJson, GroupsJson.class);
}
//--
@@ -43,19 +42,19 @@ public class ConfigurationCache extends VisualCache{
}
//-
LinkedHashMap<String, Vector<String>> gmap = new LinkedHashMap<>();
for (GroupJson groupJson: groupsJson.array){
for (GroupJson groupJson : groupsJson.array) {
Vector<String> vector = null;
if (gmap.containsKey(groupJson.language)){
if (gmap.containsKey(groupJson.language)) {
vector = gmap.get(groupJson.language);
}else {
} else {
vector = new Vector<>();
gmap.put(groupJson.language, vector);
}
vector.add(groupJson.description);
}
groupsSummary = new Vector<>();
for (String language: gmap.keySet()){
groupsSummary.add(language+": "+String.join(";", gmap.get(language)));
for (String language : gmap.keySet()) {
groupsSummary.add(language + ": " + String.join(";", gmap.get(language)));
}
Vector<String> settingsDescriptionsVector = new Vector<>();
for (SettingsJson settingsJson : settingsJson.array)
@@ -65,23 +64,31 @@ public class ConfigurationCache extends VisualCache{
public int getTestsCount() {
return testsJson.array.size();
}
public String getSettingsDescriptions() {
return settingsSummary;
}
public Vector<Group> getGroups(){
public Vector<Group> getGroups() {
Vector<Group> groups = new Vector<>();
for (GroupJson groupJson : groupsJson.array){
for (GroupJson groupJson : groupsJson.array) {
if (Global.testingServer.db.groups.containsKey(groupJson.id))
groups.add(Global.testingServer.db.groups.get(groupJson.id));
}
return groups;
}
public Vector<Test> getTests(){
public Vector<Test> getTests() {
Vector<Test> tests = new Vector<>();
for (TestJson testJson : testsJson.array){
for (TestJson testJson : testsJson.array) {
if (Global.testingServer.db.tests.containsKey(testJson.id))
tests.add(Global.testingServer.db.tests.get(testJson.id));
}
return tests;
}
public Vector<Test> getGroupTests(Group group) {
Vector<Test> tests = new Vector<>();
for (TestJson testJson : testsJson.array) {
if (Global.testingServer.db.tests.containsKey(testJson.id)) {
Test test = Global.testingServer.db.tests.get(testJson.id);
if (test.group_id == group.id)
tests.add(test);
}
}
return tests;
}
}