package Visual_DVM_2021.Passes.All;
import Common.Current;
import Common.UI.UI;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Server.TestingSystemPass;

import java.io.File;
public class ConvertCorrectnessTests extends TestingSystemPass<File> {
    @Override
    public String getIconPath() {
        return "/icons/DownloadAll.png";
    }
    @Override
    public String getButtonText() {
        return "";
    }
    @Override
    protected int getTimeout() {
        return 0;
    }
    @Override
    protected boolean canStart(Object... args) throws Exception {
        if (!Current.getAccount().isAdmin()) {
            Log.Writeln_("Вы не являетесь администратором");
            return false;
        }
        if (!Current.Check(Log, Current.ServerSapfor)){
            return false;
        }
        return UI.Warning("Загрузить полный пакет DVM тестов на корректность и производительность.");
    }
    @Override
    protected boolean needsAnimation() {
        return true;
    }
    @Override
    protected void performPreparation() throws Exception {
        passes.get(PassCode_2021.CloseCurrentProject);
        Current.set(Current.Root, null);
        Current.set(Current.Version, null);
    }
    @Override
    protected void showPreparation() throws Exception {
        UI.testingBar.ShowAutoCheckTesting();
    }
    @Override
    protected void ServerAction() throws Exception {
        Command(new ServerExchangeUnit_2021(ServerCode.RefreshDVMTests, String.valueOf(Current.getServerSapfor().id), Current.getAccount()));
    }
    @Override
    protected void performFinish() throws Exception {
        super.performFinish();
        passes.get(PassCode_2021.SynchronizeTests).Do();
    }
}

