本文整理了Java中org.mozilla.zest.core.v1.ZestExpressionLength
类的一些代码示例,展示了ZestExpressionLength
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZestExpressionLength
类的具体详情如下:
包路径:org.mozilla.zest.core.v1.ZestExpressionLength
类名称:ZestExpressionLength
[英]The Class ZestExpressionLength.
[中]类ZesteExpressionLength。
代码示例来源:origin: mozilla/zest
@Test
public void testDeepCopy() {
ZestExpressionLength length = new ZestExpressionLength("var", 100, 5, true);
ZestExpressionLength copy = length.deepCopy();
assertEquals(copy.getVariableName(), length.getVariableName());
assertEquals(copy.getLength(), length.getLength());
assertEquals(copy.getApprox(), length.getApprox());
assertEquals(copy.isInverse(), length.isInverse());
}
代码示例来源:origin: mozilla/zest
@Test
public void testEvaluateInverse() {
ZestExpressionLength length = new ZestExpressionLength("response.body", 100, 100);
length.setInverse(true);
TestRuntime runtime = new TestRuntime(response);
assertTrue(length.isTrue(runtime) && !length.evaluate(runtime));
}
代码示例来源:origin: mozilla/zest
@Test
public void testSetApprox() {
int approx = 10;
ZestExpressionLength length = new ZestExpressionLength();
length.setApprox(approx);
assertTrue(approx == length.getApprox());
}
代码示例来源:origin: mozilla/zest
@Override
public ZestExpressionLength deepCopy() {
return new ZestExpressionLength(this.variableName, this.length, this.approx, isInverse());
}
代码示例来源:origin: mozilla/zest
@Test
public void testDeepCopySameParams() {
int len = 10;
int approx = 20;
ZestExpressionLength length = new ZestExpressionLength("response.body", len, approx);
ZestExpressionLength copy = length.deepCopy();
assertTrue(copy.getLength() == len && copy.getApprox() == approx);
}
代码示例来源:origin: mozilla/zest
@Test
public void testSetChildrenCondition() {
List<ZestExpressionElement> children = new LinkedList<>();
children.add(new ZestExpressionAnd());
children.add(new ZestExpressionLength("response.body", 1, 2));
children.add(new ZestExpressionStatusCode(200));
ZestExpressionAnd root = new ZestExpressionAnd();
root.setChildrenCondition(children);
for (int i = 0; i < children.size(); i++) {
String expected = children.get(i).getClass().getName();
String obtained = root.getChild(i).getClass().getName();
String msg = "[" + i + "] - Obtained " + obtained + " instead of " + expected;
assertTrue(msg, children.get(i).getClass().equals(root.getChild(i).getClass()));
}
}
代码示例来源:origin: mozilla/zest
System.out.print(
"Length: "
+ lengthExpr.getVariableName()
+ " "
+ lengthExpr.getLength()
+ " approx: "
+ lengthExpr.getApprox());
} else if (element instanceof ZestExpressionEquals) {
ZestExpressionEquals eqExpr = (ZestExpressionEquals) element;
代码示例来源:origin: mozilla/zest
@Test
public void testZestExpressionLengthWithParamsTrue() {
ZestExpressionLength length = new ZestExpressionLength("response.body", 100, 100);
assertTrue(length.isTrue(new TestRuntime(response)));
}
代码示例来源:origin: mozilla/zest
@Test
public void testSetLength() {
int len = 10;
ZestExpressionLength length = new ZestExpressionLength();
length.setLength(len);
assertTrue(length.getLength() == len);
}
代码示例来源:origin: mozilla/zest
@Test
public void testGetLength() {
int len = 10;
int approx = 20;
ZestExpressionLength length = new ZestExpressionLength("response.body", len, approx);
assertTrue(len == length.getLength());
}
代码示例来源:origin: mozilla/zest
@Test
public void testGetApprox() {
int len = 10;
int approx = 20;
ZestExpressionLength length = new ZestExpressionLength("response.body", len, approx);
assertTrue(approx == length.getApprox());
}
代码示例来源:origin: mozilla/zest
@Test
public void testDeepCopyComplexCondition() {
ZestExpressionAnd and1 = new ZestExpressionAnd();
ZestExpressionAnd and2 = new ZestExpressionAnd();
ZestExpressionAnd and3 = new ZestExpressionAnd();
ZestExpressionLength leaf = new ZestExpressionLength();
and3.addChildCondition(leaf);
and2.addChildCondition(and3);
and1.addChildCondition(and2);
ZestExpressionAnd copy1 = and1.deepCopy();
ZestExpressionAnd copy2 = (ZestExpressionAnd) copy1.getChild(0);
ZestExpressionAnd copy3 = (ZestExpressionAnd) copy2.getChild(0);
ZestExpressionLength copyLeaf = (ZestExpressionLength) copy3.getChild(0);
assertTrue(
and1.getClass() == copy1.getClass() // TODO to many booleans
&& and2.getClass() == copy2.getClass()
&& copy3.getClass() == and3.getClass()
&& copyLeaf instanceof ZestExpressionLength
&& copyLeaf.isLeaf());
}
代码示例来源:origin: mozilla/zest
1000);
ZestExpressionLength length =
new ZestExpressionLength(ZestVariables.RESPONSE_BODY, 0, 1);
length.setInverse(true);
ZestExpressionStatusCode code = new ZestExpressionStatusCode(200);
ZestExpressionRegex regex =
代码示例来源:origin: mozilla/zest
@Override
public String toString() {
String expression =
(isInverse() ? "NOT " : "")
+ "Length: "
+ length
+ " +/- "
+ (((double) (length * approx)) / 100);
return expression;
}
}
代码示例来源:origin: mozilla/zest
@Test
public void testDeepCopySingleAndSameChildrenClasses() {
List<ZestExpressionElement> children = new LinkedList<>();
for (int i = 0; i < 10; i++) {
children.add(new ZestExpressionLength());
}
ZestExpressionAnd and = new ZestExpressionAnd(children);
ZestExpressionAnd copy = and.deepCopy();
for (int i = 0; i < children.size(); i++) {
assertTrue(and.getChild(i).getClass() == copy.getChild(i).getClass());
}
}
代码示例来源:origin: mozilla/zest
@Test
public void testZestExpressionLengthWithParamsFalse() {
ZestExpressionLength length = new ZestExpressionLength("response.body", 100, -1);
assertFalse(length.isTrue(new TestRuntime(response)));
}
代码示例来源:origin: mozilla/zest
@Test
public void testOrDeepCopySingleAndSameChildrenClasses() {
List<ZestExpressionElement> children = new LinkedList<>();
for (int i = 0; i < 10; i++) {
children.add(new ZestExpressionLength());
}
ZestExpressionOr or = new ZestExpressionOr(children);
ZestExpressionOr copy = or.deepCopy();
for (int i = 0; i < children.size(); i++) {
assertTrue(or.getChild(i).getClass() == copy.getChild(i).getClass());
}
}
代码示例来源:origin: mozilla/zest
@Test
public void testZestExpressionLength() {
ZestExpressionLength length = new ZestExpressionLength();
assertFalse(length.isTrue(new TestRuntime(response)));
}
代码示例来源:origin: mozilla/zest
@Test
public void testRemoveChildConditionReturnValue() {
ZestExpressionAnd and = new ZestExpressionAnd();
ZestExpressionLength lengthExpr = new ZestExpressionLength("response.body", 10, 20);
and.addChildCondition(lengthExpr);
assertTrue(and.removeChildCondition(lengthExpr).equals(lengthExpr));
}
代码示例来源:origin: mozilla/zest
@Test
public void testIsTrueNullBody() {
ZestResponse resp = new ZestResponse(null, null, null, 0, 0);
ZestExpressionLength length = new ZestExpressionLength("response.body", 100, 100);
assertFalse(length.isTrue(new TestRuntime(resp)));
}
}
内容来源于网络,如有侵权,请联系作者删除!