Пример #1
0
        public void TestUpdateRouteResponse()
        {
            string json = @"{
  ""metadata"": {
    ""guid"": ""3bbcf6f5-6930-4ed9-87f8-e1466ebf388e"",
    ""url"": ""/v2/routes/3bbcf6f5-6930-4ed9-87f8-e1466ebf388e"",
    ""created_at"": ""2016-02-09T10:21:52Z"",
    ""updated_at"": ""2016-02-09T10:21:52Z""
  },
  ""entity"": {
    ""host"": ""new_host"",
    ""domain_guid"": ""67f729d7-4fd2-4d2a-b28c-c5adecd964b5"",
    ""space_guid"": ""8dd45178-5d66-4584-a1da-f7751f12c102"",
    ""domain_url"": ""/v2/domains/67f729d7-4fd2-4d2a-b28c-c5adecd964b5"",
    ""space_url"": ""/v2/spaces/8dd45178-5d66-4584-a1da-f7751f12c102"",
    ""apps_url"": ""/v2/routes/3bbcf6f5-6930-4ed9-87f8-e1466ebf388e/apps""
  }
}";

            UpdateRouteResponse obj = Utilities.DeserializeJson <UpdateRouteResponse>(json);

            Assert.AreEqual("3bbcf6f5-6930-4ed9-87f8-e1466ebf388e", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
            Assert.AreEqual("/v2/routes/3bbcf6f5-6930-4ed9-87f8-e1466ebf388e", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
            Assert.AreEqual("2016-02-09T10:21:52Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
            Assert.AreEqual("2016-02-09T10:21:52Z", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
            Assert.AreEqual("new_host", TestUtil.ToTestableString(obj.Host), true);
            Assert.AreEqual("67f729d7-4fd2-4d2a-b28c-c5adecd964b5", TestUtil.ToTestableString(obj.DomainGuid), true);
            Assert.AreEqual("8dd45178-5d66-4584-a1da-f7751f12c102", TestUtil.ToTestableString(obj.SpaceGuid), true);
            Assert.AreEqual("/v2/domains/67f729d7-4fd2-4d2a-b28c-c5adecd964b5", TestUtil.ToTestableString(obj.DomainUrl), true);
            Assert.AreEqual("/v2/spaces/8dd45178-5d66-4584-a1da-f7751f12c102", TestUtil.ToTestableString(obj.SpaceUrl), true);
            Assert.AreEqual("/v2/routes/3bbcf6f5-6930-4ed9-87f8-e1466ebf388e/apps", TestUtil.ToTestableString(obj.AppsUrl), true);
        }
Пример #2
0
        public void TestUpdateRouteResponse()
        {
            string json = @"{
  ""metadata"": {
    ""guid"": ""bd6618c9-ff42-4559-9042-28df2d136d56"",
    ""url"": ""/v2/routes/bd6618c9-ff42-4559-9042-28df2d136d56"",
    ""created_at"": ""2015-04-16T12:04:14+00:00"",
    ""updated_at"": ""2015-04-16T12:04:14+00:00""
  },
  ""entity"": {
    ""host"": ""new_host"",
    ""domain_guid"": ""151dd40c-afa8-4f3c-b39a-cfe915cf3fda"",
    ""space_guid"": ""90477a11-c3e1-4ed7-bf44-86d90619674d"",
    ""domain_url"": ""/v2/domains/151dd40c-afa8-4f3c-b39a-cfe915cf3fda"",
    ""space_url"": ""/v2/spaces/90477a11-c3e1-4ed7-bf44-86d90619674d"",
    ""apps_url"": ""/v2/routes/bd6618c9-ff42-4559-9042-28df2d136d56/apps""
  }
}";

            UpdateRouteResponse obj = Utilities.DeserializeJson <UpdateRouteResponse>(json);

            Assert.AreEqual("bd6618c9-ff42-4559-9042-28df2d136d56", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
            Assert.AreEqual("/v2/routes/bd6618c9-ff42-4559-9042-28df2d136d56", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
            Assert.AreEqual("2015-04-16T12:04:14+00:00", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
            Assert.AreEqual("2015-04-16T12:04:14+00:00", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
            Assert.AreEqual("new_host", TestUtil.ToTestableString(obj.Host), true);
            Assert.AreEqual("151dd40c-afa8-4f3c-b39a-cfe915cf3fda", TestUtil.ToTestableString(obj.DomainGuid), true);
            Assert.AreEqual("90477a11-c3e1-4ed7-bf44-86d90619674d", TestUtil.ToTestableString(obj.SpaceGuid), true);
            Assert.AreEqual("/v2/domains/151dd40c-afa8-4f3c-b39a-cfe915cf3fda", TestUtil.ToTestableString(obj.DomainUrl), true);
            Assert.AreEqual("/v2/spaces/90477a11-c3e1-4ed7-bf44-86d90619674d", TestUtil.ToTestableString(obj.SpaceUrl), true);
            Assert.AreEqual("/v2/routes/bd6618c9-ff42-4559-9042-28df2d136d56/apps", TestUtil.ToTestableString(obj.AppsUrl), true);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            UpdateRouteResponse response = new UpdateRouteResponse();

            var unmarshaller = RouteDataUnmarshaller.Instance;

            response.Route = unmarshaller.Unmarshall(context);

            return(response);
        }
Пример #4
0
        public void Route_test()
        {
            CreateRouteResponse   newRoute      = null;
            UpdateRouteResponse   updatedRoute  = null;
            RetrieveRouteResponse retrieveRoute = null;

            CreateRouteRequest request = new CreateRouteRequest();

            request.DomainGuid = domainGuid;
            request.SpaceGuid  = spaceGuid;

            try
            {
                newRoute = client.Routes.CreateRoute(request).Result;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while creating route: {0}", ex.ToString());
            }
            Assert.IsNotNull(newRoute);

            try
            {
                retrieveRoute = client.Routes.RetrieveRoute(newRoute.EntityMetadata.Guid).Result;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while reading route: {0}", ex.ToString());
            }
            Assert.IsNotNull(retrieveRoute);

            UpdateRouteRequest updateR = new UpdateRouteRequest();

            updateR.Host = "newtestdomain";

            try
            {
                updatedRoute = client.Routes.UpdateRoute(newRoute.EntityMetadata.Guid, updateR).Result;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while updating route: {0}", ex.ToString());
            }
            Assert.IsNotNull(updatedRoute);
            Assert.AreEqual(updateR.Host, updatedRoute.Host);

            try
            {
                client.Routes.DeleteRoute(newRoute.EntityMetadata.Guid).Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception while deleting space: {0}", ex.ToString());
            }
        }
Пример #5
0
        public void TestUpdateRouteResponse()
        {
            string json = @"{
  ""metadata"": {
    ""guid"": ""8c165012-3564-4087-95ac-f22c4d6b8806"",
    ""url"": ""/v2/routes/ac5f25ba-5714-453b-a823-22ce0588021c"",
    ""created_at"": ""2016-09-02T11:52:13Z"",
    ""updated_at"": ""2016-09-02T11:52:14Z""
  },
  ""entity"": {
    ""host"": ""host-21"",
    ""path"": """",
    ""domain_guid"": ""8c165012-3564-4087-95ac-f22c4d6b8806"",
    ""space_guid"": ""8c165012-3564-4087-95ac-f22c4d6b8806"",
    ""service_instance_guid"": null,
    ""port"": 10000,
    ""domain_url"": ""/v2/shared_domains/d3d68f3a-f005-4d5a-802e-801bec893b4a"",
    ""space_url"": ""/v2/spaces/d3c7b2dc-9de0-49c4-aa78-97547c2f0ca6"",
    ""apps_url"": ""/v2/routes/ac5f25ba-5714-453b-a823-22ce0588021c/apps"",
    ""route_mappings_url"": ""/v2/routes/ac5f25ba-5714-453b-a823-22ce0588021c/route_mappings""
  }
}";

            UpdateRouteResponse obj = Utilities.DeserializeJson <UpdateRouteResponse>(json);

            Assert.AreEqual("8c165012-3564-4087-95ac-f22c4d6b8806", TestUtil.ToTestableString(obj.EntityMetadata.Guid), true);
            Assert.AreEqual("/v2/routes/ac5f25ba-5714-453b-a823-22ce0588021c", TestUtil.ToTestableString(obj.EntityMetadata.Url), true);
            Assert.AreEqual("2016-09-02T11:52:13Z", TestUtil.ToTestableString(obj.EntityMetadata.CreatedAt), true);
            Assert.AreEqual("2016-09-02T11:52:14Z", TestUtil.ToTestableString(obj.EntityMetadata.UpdatedAt), true);
            Assert.AreEqual("host-21", TestUtil.ToTestableString(obj.Host), true);
            Assert.AreEqual("", TestUtil.ToTestableString(obj.Path), true);
            Assert.AreEqual("8c165012-3564-4087-95ac-f22c4d6b8806", TestUtil.ToTestableString(obj.DomainGuid), true);
            Assert.AreEqual("8c165012-3564-4087-95ac-f22c4d6b8806", TestUtil.ToTestableString(obj.SpaceGuid), true);
            Assert.AreEqual("", TestUtil.ToTestableString(obj.ServiceInstanceGuid), true);
            Assert.AreEqual("10000", TestUtil.ToTestableString(obj.Port), true);
            Assert.AreEqual("/v2/shared_domains/d3d68f3a-f005-4d5a-802e-801bec893b4a", TestUtil.ToTestableString(obj.DomainUrl), true);
            Assert.AreEqual("/v2/spaces/d3c7b2dc-9de0-49c4-aa78-97547c2f0ca6", TestUtil.ToTestableString(obj.SpaceUrl), true);
            Assert.AreEqual("/v2/routes/ac5f25ba-5714-453b-a823-22ce0588021c/apps", TestUtil.ToTestableString(obj.AppsUrl), true);
            Assert.AreEqual("/v2/routes/ac5f25ba-5714-453b-a823-22ce0588021c/route_mappings", TestUtil.ToTestableString(obj.RouteMappingsUrl), true);
        }
Пример #6
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            UpdateRouteResponse response = new UpdateRouteResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("apiKeyRequired", targetDepth))
                {
                    var unmarshaller = BoolUnmarshaller.Instance;
                    response.ApiKeyRequired = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("authorizationScopes", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <string, StringUnmarshaller>(StringUnmarshaller.Instance);
                    response.AuthorizationScopes = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("authorizationType", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.AuthorizationType = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("authorizerId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.AuthorizerId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("modelSelectionExpression", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ModelSelectionExpression = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("operationName", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.OperationName = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("requestModels", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance);
                    response.RequestModels = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("requestParameters", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <string, ParameterConstraints, StringUnmarshaller, ParameterConstraintsUnmarshaller>(StringUnmarshaller.Instance, ParameterConstraintsUnmarshaller.Instance);
                    response.RequestParameters = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("routeId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.RouteId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("routeKey", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.RouteKey = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("routeResponseSelectionExpression", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.RouteResponseSelectionExpression = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("target", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Target = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }