gpt4 book ai didi

org.mozilla.zest.core.v1.ZestAssignStringDelimiters类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 09:41:40 26 4
gpt4 key购买 nike

本文整理了Java中org.mozilla.zest.core.v1.ZestAssignStringDelimiters类的一些代码示例,展示了ZestAssignStringDelimiters类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZestAssignStringDelimiters类的具体详情如下:
包路径:org.mozilla.zest.core.v1.ZestAssignStringDelimiters
类名称:ZestAssignStringDelimiters

ZestAssignStringDelimiters介绍

[英]The Class ZestAssignStringDelimiters allows you to assign a string to the specified variable from the last response received. The string is delimited by the strings specified.
[中]ZestAssignStringDelimiters类允许您从上次收到的响应中将字符串分配给指定的变量。字符串由指定的字符串分隔。

代码示例

代码示例来源:origin: mozilla/zest

@Override
public ZestAssignStringDelimiters deepCopy() {
  ZestAssignStringDelimiters copy = new ZestAssignStringDelimiters(this.getIndex());
  copy.setVariableName(this.getVariableName());
  copy.location = this.location;
  copy.setPrefix(this.prefix);
  copy.setPostfix(this.postfix);
  copy.setEnabled(this.isEnabled());
  return copy;
}

代码示例来源:origin: mozilla/zest

/**
 * Instantiates a new zest action set variable.
 *
 * @param variableName the variable name
 * @param location the location
 * @param prefix the prefix
 * @param postfix the postfix
 */
public ZestAssignStringDelimiters(
    String variableName, String location, String prefix, String postfix) {
  super(variableName);
  this.location = location;
  this.setPrefix(prefix);
  this.setPostfix(postfix);
}

代码示例来源:origin: mozilla/zest

/**
 * Method testRegexes.
 *
 * @throws Exception
 */
@Test
public void testRegexes() throws Exception {
  ZestAssignStringDelimiters ast = new ZestAssignStringDelimiters();
  ZestResponse resp =
      new ZestResponse(
          null, "Header prefix12345postfixZ", "Body Prefix54321PostfixZ", 200, 0);
  ast.setVariableName("aaa");
  ast.setPrefix("H");
  ast.setPostfix("Z");
  ast.setLocation(ZestAssignStringDelimiters.LOC_HEAD);
  assertEquals("eader prefix12345postfix", ast.assign(resp, rt));
  ast.setVariableName("aaa");
  ast.setPrefix("B");
  ast.setPostfix("Z");
  ast.setLocation(ZestAssignStringDelimiters.LOC_BODY);
  assertEquals("ody Prefix54321Postfix", ast.assign(resp, rt));
}

代码示例来源:origin: mozilla/zest

@Test
  public void testSerialization() {
    ZestAssignStringDelimiters assign =
        new ZestAssignStringDelimiters("var", "BODY", ">>", "<<");

    String str = ZestJSON.toString(assign);
    // System.out.println(str);

    ZestAssignStringDelimiters assign2 = (ZestAssignStringDelimiters) ZestJSON.fromString(str);

    assertEquals(assign.getElementType(), assign2.getElementType());
    assertEquals(assign.getLocation(), assign2.getLocation());
    assertEquals(assign.getPrefix(), assign2.getPrefix());
    assertEquals(assign.getPostfix(), assign2.getPostfix());
  }
}

代码示例来源:origin: mozilla/zest

new ZestAssignStringDelimiters(
        "test.var.1", ZestAssignStringDelimiters.LOC_HEAD, "AA", "BB"));
assertEquals(8, script.getVariableNames().size());
script.add(c1);
c1.addIf(
    new ZestAssignStringDelimiters(
        "test.var.2", ZestAssignStringDelimiters.LOC_HEAD, "AA", "BB"));
assertEquals(9, script.getVariableNames().size());

代码示例来源:origin: mozilla/zest

/**
 * Method testSimpleCase.
 *
 * @throws Exception
 */
@Test
public void testSimpleCase() throws Exception {
  ZestAssignStringDelimiters ast = new ZestAssignStringDelimiters();
  ZestResponse resp =
      new ZestResponse(
          null, "Header prefix12345postfix", "Body Prefix54321Postfix", 200, 0);
  ast.setVariableName("aaa");
  ast.setPrefix("prefix");
  ast.setPostfix("postfix");
  assertEquals("12345", ast.assign(resp, rt));
  ast.setVariableName("aaa");
  ast.setPrefix("Prefix");
  ast.setPostfix("Postfix");
  assertEquals("54321", ast.assign(resp, rt));
}

代码示例来源:origin: mozilla/zest

ZestAssignStringDelimiters ast = new ZestAssignStringDelimiters();
ZestResponse resp = new ZestResponse(null, "aaaa", "bbbb", 200, 0);
ast.setVariableName("aaa");
ast.setPrefix("bbb");
ast.setPostfix("ccc");
try {
  ast.assign(null, rt);
  fail("Should have caused an exception");
} catch (ZestAssignFailException e) {
ast.setVariableName("aaa");
ast.setPrefix(null);
ast.setPostfix("ccc");
try {
  ast.assign(resp, rt);
  fail("Should have caused an exception");
} catch (ZestAssignFailException e) {
ast.setVariableName("aaa");
ast.setPrefix("bbb");
ast.setPostfix(null);
try {
  ast.assign(resp, rt);
  fail("Should have caused an exception");
} catch (ZestAssignFailException e) {
ast.setVariableName("aaa");
ast.setPrefix("xxx");

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com