public void TestAddUriStructureOkController()
        {
            ConfigJsonHandler       configJsonHandler      = new ConfigJsonHandler();
            ISchemaConfigOperations schemaConfigOperations = new SchemaConfigMemoryOperations(configJsonHandler);
            SchemaController        schemaController       = new SchemaController(configJsonHandler, schemaConfigOperations);
            UriStructure            newUriStructure        = CreateUriStructureExample("newUriExample");
            ResourcesClass          newResourcesClass      = CreateResourceClassExample("newUriExample", "rsp", "pipaon");
            List <ResourcesClass>   lista = new List <ResourcesClass>();

            lista.Add(newResourcesClass);
            InfoUriStructure structure = new InfoUriStructure();

            structure.ResourcesClass = lista;
            structure.UriStructure   = newUriStructure;
            var result = schemaController.AddUriStructure(structure);

            if (result is BadRequestObjectResult)
            {
                Assert.True(false);
            }
            else
            {
                Assert.True(true);
            }
        }
Пример #2
0
 public IActionResult AddUriStructure(InfoUriStructure infoUriStructure)
 {
     if (infoUriStructure != null && infoUriStructure.ResourcesClass != null && infoUriStructure.UriStructure != null && infoUriStructure.ResourcesClass.Count == 1)
     {
         try
         {
             _configJsonHandler.AddUriStructureInfo(infoUriStructure.UriStructure, infoUriStructure.ResourcesClass.First());
             bool saved = _schemaConfigOperations.SaveConfigJson();
             if (saved)
             {
                 return(Ok($"uriStructure: {infoUriStructure.UriStructure.Name} has been added and the new config schema is loaded"));
             }
             else
             {
                 return(Problem(detail: "Server error has ocurred", null, 500));
             }
         }
         catch (UriStructureConfiguredException confEx)
         {
             return(BadRequest(confEx.Message));
         }
         catch (UriStructureBadInfoException badInfoEx)
         {
             return(BadRequest($"{{\"error\": \"{badInfoEx.Message}\"}}"));
         }
     }
     else
     {
         return(BadRequest("{{\"error\": \"info structure is missing\"}}"));
     }
 }
Пример #3
0
        public IActionResult GetUriStructureInfo(string name)
        {
            UriStructure uri = _configJsonHandler.GetUriStructure(name);

            if (uri != null)
            {
                List <ResourcesClass> resourceClass    = _configJsonHandler.GetResourceClass(name);
                InfoUriStructure      infoUriStructure = new InfoUriStructure();
                infoUriStructure.UriStructure   = uri;
                infoUriStructure.ResourcesClass = resourceClass;
                return(Ok(infoUriStructure));
            }
            else
            {
                return(BadRequest($"{{\"error\": \"No data of uriStructure {name}\"}}"));
            }
        }