我在 // Create a gradient layer
let gradient: CAGradientLayer = CAGradientLayer()
// Create an array of colours you can use, as many colours as you require
gradient.colors = [.blue.cgColor, .red.cgColor, .orange.cgColor].cgColor
// Chose the locations for your colors, 0.5 is center
gradient.locations = [0.0, 0.5, 1.0]
// Start and end points so this goes from y: 0.0 to y: 1.0 so top to bottom
gradient.startPoint = CGPoint(x: 1.0, y: 0.0)
gradient.endPoint = CGPoint(x: 1.0, y: 1.0)
// Set the frame
gradient.frame = CGRect(x: 0.0, y: 0.0, width: yourView.frame.size.width, height: yourView.frame.size.height)
// Add to view
yourView.layer.insertSublayer(gradient, at: 0)
类上开发了Rest-Assured请求,但是我需要通过另一种方法来验证此请求,以调用该功能的黄瓜步骤。
我的黄瓜特色
dataMap
我试图这样做:
Esquema do Cenario: Criar uma conta valida
Dado que realizo a chamada no <ambiente> da <api> informando <token_admin> e um email e <senha> novos
Entao devera retornar <status code>
但是public class dataMap extends tests {
private Response response;
private ValidatableResponse json;
private RequestSpecification request;
public void criarConta(String srtAmbiente, String srtAPI, String srtToken, String srtSenha) {
String uriBase = srtAmbiente;
String Api = srtAPI;
int length = 15;
String email = generateRandomEmail(length);
System.out.println(email);
Map<String, String> emailContent = new HashMap<String,String>();
emailContent.put("email", email);
Map<String, Object> postContent = new HashMap<String,Object>();
postContent.put("customer", emailContent);
postContent.put("password", srtSenha);
request = RestAssured.given().contentType(ContentType.JSON)
.header("Authorization", "Bearer "+srtToken).with().body(postContent);
response = request.when().post(uriBase+Api).prettyPeek();
}
public void responseCriarContaStatus (String srtStatusCode) {
json = response.then().statusLine("HTTP/1.1 200 OK");
方法不起作用。当我将responseCriarContaStatus
插入json = response.then().statusLine("HTTP/1.1 200 OK");
方法中时,代码有效。
如何使用criarConta
方法验证此请求?
答案 0 :(得分:0)
您可以设置Response
对象static
,并且在定义response
之后,可以在另一种方法中使用它。我正在分享您自己的方法,然后您可以对其进行编辑。如果请求成功,则statusCode
将是200
。
private static Response response;
public void responseCriarContaStatus (String srtStatusCode) {
JSONObject json = new JSONObject(response.getBody().asString);
Asser.asserEquals(srtStatusCode , json.getString("statusCode"));