package _VisualDVM.Passes.All;
import _VisualDVM.Current;
import _VisualDVM.Global;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.Passes.Server.TestingSystemPass;
import _VisualDVM.Repository.Server.ServerCode;
import _VisualDVM.Repository.Server.ServerExchangeUnit_2021;

import java.io.Serializable;
public class ReplaceTestProject extends CreateTestFromProject {
    @Override
    public String getIconPath() {
        return "/icons/Menu/Undo.png";
    }
    @Override
    protected void performDone() throws Exception {
        TestingSystemPass testingSystemPass = new TestingSystemPass() {
            @Override
            protected boolean canStart(Object... args) throws Exception {
                target = args[0];
                return true;
            }
            @Override
            public String getDescription() {
                return "Замена кода теста на сервере";
            }
            @Override
            protected void ServerAction() throws Exception {
                Command(new ServerExchangeUnit_2021(ServerCode.ReplaceTestCode, null, (Serializable) target));
            }
        };
        testingSystemPass.Do(target);
        Global.mainModule.getPass(PassCode.SynchronizeTests).Do();
    }
    @Override
    protected boolean initTarget() throws Exception {
        if (Global.mainModule.Check(Log, Current.Test)) {
            target = Global.mainModule.getTest();
            return true;
        }
        return false;
    }
}
