рефакторинг бд файлов тестов.
This commit is contained in:
2025-03-20 17:48:18 +03:00
parent 3f4ef5f198
commit 0b5f8c6ec7
22 changed files with 374 additions and 359 deletions

View File

@@ -4,19 +4,19 @@ import Common.Passes.PassException;
import Common.Utils.Utils_;
import _VisualDVM.Global;
import _VisualDVM.ProjectData.Files.FileType;
import _VisualDVM.ProjectData.Files.ProjectFile;
import _VisualDVM.TestingSystem.Common.Group.Group;
import _VisualDVM.TestingSystem.Common.Test.Json.TestFileJson;
import _VisualDVM.TestingSystem.Common.Test.Json.TestFilesJson;
import _VisualDVM.TestingSystem.Common.Test.Test;
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
import _VisualDVM.Utils;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.Vector;
public class CreateTestFromFile extends Pass<Test> {
//----
Group group;
ProjectFile projectFile;
TestFile testFile;
File file;
//----
@Override
protected boolean needsAnimation() {
@@ -32,20 +32,20 @@ public class CreateTestFromFile extends Pass<Test> {
}
@Override
protected boolean canStart(Object... args) throws Exception {
projectFile = null;
File file_in = (File) args[0];
testFile = null;
file = (File) args[0];
group = (Group) args[1];
//--
if (Utils_.ContainsCyrillic(file_in.getName()) || Utils_.ContainsForbiddenName(file_in.getName())) {
Log.Writeln_("Имя файла " + Utils_.Brackets(file_in.getName())
if (Utils_.ContainsCyrillic(file.getName()) || Utils_.ContainsForbiddenName(file.getName())) {
Log.Writeln_("Имя файла " + Utils_.Brackets(file.getName())
+ " содержит запрещённые символы " +
Utils_.printAllForbiddenCharacters() + ", или кириллицу.");
return false;
}
//--
projectFile = new ProjectFile(file_in);
if (!projectFile.fileType.equals(FileType.program) || !projectFile.languageName.equals(group.language)) {
Log.Writeln_("Не удалось распознать файл " + Utils_.Brackets(file_in.getName()) +
testFile = new TestFile(file);
if (!testFile.fileType.equals(FileType.program) || !testFile.languageName.equals(group.language)) {
Log.Writeln_("Не удалось распознать файл " + Utils_.Brackets(file.getName()) +
" как программу на языке " + group.language.getDescription());
return false;
}
@@ -54,10 +54,10 @@ public class CreateTestFromFile extends Pass<Test> {
target.sender_address = Global.mainModule.getAccount().email;
target.sender_name = Global.mainModule.getAccount().name;
target.group_id = group.id;
target.description = Utils_.getNameWithoutExtension(file_in.getName());
TestFilesJson filesJson = new TestFilesJson();
filesJson.values.add(new TestFileJson(new ProjectFile(file_in)));
target.packedFilesJson = Utils_.gson.toJson(filesJson);
target.description = Utils_.getNameWithoutExtension(file.getName());
target.files = new Vector<>();
target.files.add(testFile);
//--
return true;
}
public File packTestCode() throws Exception {
@@ -68,8 +68,8 @@ public class CreateTestFromFile extends Pass<Test> {
//- создать бд.
FileUtils.forceMkdir(tempProject);
//--
File dst = new File(tempProject, projectFile.file.getName());
FileUtils.copyFile(projectFile.file, dst);
File dst = new File(tempProject, testFile.name);
FileUtils.copyFile(file, dst);
//---
Utils.ClearProjectData(tempProject);
//--
@@ -81,7 +81,7 @@ public class CreateTestFromFile extends Pass<Test> {
}
@Override
protected void body() throws Exception {
ShowMessage1(projectFile.file.getName());
ShowMessage1(testFile.name);
packTestCode();
}
}