/// <inheritdoc />
        protected override async Task UpdateBuild(Build build, ChangeBuildState command)
        {
            StateChangeCheckResult result = await changeChecker.Check(build, command.NewState);

            if (!result.CanChange)
            {
                throw new ValidationException(new BuildTransferRuleCheckValidationError()
                {
                    ErrorName = "StateTranslateRuleViolation",
                    From      = build.LifeCycleState,
                    To        = command.NewState,
                    Rules     = result.UnMatchRuleNames,
                });
            }

            List <string> newSuffixes = GetNewSuffixes(build.Suffixes.ToArray(), build.LifeCycleState, command.NewState).ToList();

            Logger.LogDebug($"Try change state of build {build}. NewState: {command.NewState}. NewSuffixes: {newSuffixes.JoinWith(",")}");

            IResponseMessage response =
                await buildSyncService.ChangeSuffix(build.Location, build.SourceType, newSuffixes, build.Suffixes.ToList());

            switch (response)
            {
            case ChangeSuffixesResponse {
                    IsSuccessful: true
            } :
                build.UpdateLifeCycleState(command.NewState, DateTime.Now, command.Comment, command.User.Sid);
                return;
Exemplo n.º 2
0
        public async Task Check_BuildCurrentAndNewState_CanChange(string suffix, LifeCycleState currentState, LifeCycleState newState, bool expectedCanChange)
        {
            Build build = CreateBuild(currentState, suffix);

            StateChangeCheckResult result = await buildStateChangeChecker.Check(build, newState);

            Assert.Equal(expectedCanChange, result.CanChange);
        }