blob: 96f9ce95bd063989ec89b8b15b7bed18fef8aa25 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.indexinglanguage.expressions;
import com.yahoo.document.DataType;
import org.junit.Test;
import static com.yahoo.vespa.indexinglanguage.expressions.ExpressionAssert.assertVerify;
import static org.junit.Assert.*;
/**
* @author Simon Thoresen Hult
*/
public class ClearStateTestCase {
@Test
public void requireThatHashCodeAndEqualsAreImplemented() {
Expression exp = new ClearStateExpression();
assertFalse(exp.equals(new Object()));
assertEquals(exp, new ClearStateExpression());
assertEquals(exp.hashCode(), new ClearStateExpression().hashCode());
}
@Test
public void requireThatExecutionContextIsCleared() {
MyExecution ctx = new MyExecution();
ctx.execute(new ClearStateExpression());
assertTrue(ctx.cleared);
}
@Test
public void requireThatExpressionCanBeVerified() {
Expression exp = new ClearStateExpression();
assertVerify(null, exp, null);
assertVerify(DataType.INT, exp, null);
assertVerify(DataType.STRING, exp, null);
}
@Test
public void requireThatVerificationContextIsCleared() {
MyVerification ctx = new MyVerification();
ctx.execute(new ClearStateExpression());
assertTrue(ctx.cleared);
}
private static class MyExecution extends ExecutionContext {
boolean cleared = false;
@Override
public ExecutionContext clear() {
cleared = true;
return this;
}
}
private static class MyVerification extends VerificationContext {
boolean cleared = false;
@Override
public VerificationContext clear() {
cleared = true;
return this;
}
}
}
|