Beispiel #1
0
        public async Task <IActionResult> SetVariables(string id, [FromBody] VariablesResource variablesDto)
        {
            MissingVariablesResource result = await _reasoningTaskService.SetVariablesAsync(id, variablesDto);

            if (result == null)
            {
                return(NotFound());
            }

            return(Ok(result));
        }
        public void SetVariablesAsync_MissingTask()
        {
            var variablesResource = new VariablesResource {
                Variables = new List <IVariable>()
            };

            var service = MockReasoningTaskService();

            var result = service.SetVariablesAsync("testId", variablesResource).Result;

            Assert.IsNull(result);
        }
        public void SetVariablesAsync_ExistingTask()
        {
            var reasoningTask     = ReasoningMocks.GetReasoningTask(ReasoningTaskStatus.STOPPED);
            var variablesResource = new VariablesResource {
                Variables = new List <IVariable>()
            };

            var reasoningTaskRepository = new Mock <IReasoningTaskRepository>();

            reasoningTaskRepository.Setup(x => x.GetAsync(It.IsAny <string>()))
            .Returns(Task.FromResult(reasoningTask));
            var reasoningService = new ReasoningService();

            var service = MockReasoningTaskService(reasoningTaskRepository.Object, null, reasoningService);

            var result = service.SetVariablesAsync("testId", variablesResource).Result;

            Assert.IsNotNull(result);
            Assert.IsTrue(result.MissingVariableIds.ToList().Count == 0);
        }
Beispiel #4
0
        public async Task <MissingVariablesResource> SetVariablesAsync(string id, VariablesResource variablesResource)
        {
            var reasoningTask = await _reasoningTaskRepository.GetAsync(id);

            if (reasoningTask == null)
            {
                return(null);
            }

            reasoningTask.ReasoningProcess = _reasoningService.SetValues(reasoningTask.ReasoningProcess, variablesResource.Variables);
            reasoningTask.Status           = ReasoningTaskStatus.WAITING;

            _reasoningTaskRepository.Update(id, reasoningTask);

            _logger.LogInformation($"variables {variablesResource.Variables} have been set to reasoning task {id}");

            _reasoningTaskResolver.EnqueueReasoningTask(id);

            var result = _reasoningService.GetAllMissingVariableIds(reasoningTask.ReasoningProcess);

            return(new MissingVariablesResource {
                MissingVariableIds = result
            });
        }