public void ServiceDefinitionLoader_GenerateServiceGraph_WhenLoadingWorkerService_ServiceIsLoaded() { //------------Setup for test-------------------------- var serviceDefinitionLoader = new ServiceDefinitionLoader(); //------------Execute Test--------------------------- //------------Assert Results------------------------- }
static ServiceAction CreateServiceAction(XElement serviceXml, XElement sourceXml) { var graph = new ServiceDefinitionLoader().GenerateServiceGraph(new StringBuilder(serviceXml.ToString())); var ds = (DynamicService)graph[0]; var sa = ds.Actions[0]; sa.Source = new Source { ResourceDefinition = new StringBuilder(sourceXml.ToString()) }; return(sa); }
public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace) { try { Dev2Logger.Log.Info("Save Resource Service"); StringBuilder resourceDefinition; string workspaceIdString = string.Empty; values.TryGetValue("ResourceXml", out resourceDefinition); StringBuilder tmp; values.TryGetValue("WorkspaceID", out tmp); if (tmp != null) { workspaceIdString = tmp.ToString(); } Guid workspaceId; if (!Guid.TryParse(workspaceIdString, out workspaceId)) { workspaceId = theWorkspace.ID; } if (resourceDefinition == null || resourceDefinition.Length == 0) { throw new InvalidDataContractException("Roles or ResourceXml is missing"); } var res = new ExecuteMessage { HasError = false }; List <DynamicServiceObjectBase> compiledResources = null; var errorMessage = Resources.CompilerMessage_BuildFailed + " " + DateTime.Now; try { // Replace with proper object hydration and parsing ;) compiledResources = new ServiceDefinitionLoader().GenerateServiceGraph(resourceDefinition); if (compiledResources.Count == 0) { CompileMessageRepo.Instance.AddMessage(workspaceId, new List <ICompileMessageTO> { new CompileMessageTO { ErrorType = ErrorType.Warning, MessageID = Guid.NewGuid(), MessagePayload = errorMessage } }); res.SetMessage(Resources.CompilerMessage_BuildFailed + " " + DateTime.Now); } } catch (Exception err) { Dev2Logger.Log.Error(err); CompileMessageRepo.Instance.AddMessage(workspaceId, new List <ICompileMessageTO> { new CompileMessageTO { ErrorType = ErrorType.Warning, MessageID = Guid.NewGuid(), MessagePayload = errorMessage } }); res.SetMessage(errorMessage); } if (compiledResources != null) { var saveResult = ResourceCatalog.Instance.SaveResource(workspaceId, resourceDefinition, null, "Save"); res.SetMessage(saveResult.Message + " " + DateTime.Now); } Dev2JsonSerializer serializer = new Dev2JsonSerializer(); return(serializer.SerializeToBuilder(res)); } catch (Exception err) { Dev2Logger.Log.Error(err); throw; } }