blob: 7b806982313a49233b5a74e799b552c64f194af9 (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.matchers;
import com.yahoo.vdslib.state.Node;
import com.yahoo.vespa.clustercontroller.core.NodeEvent;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.mockito.ArgumentMatcher;
public class EventForNode extends ArgumentMatcher<NodeEvent> {
private final Node expected;
EventForNode(Node expected) {
this.expected = expected;
}
@Override
public boolean matches(Object o) {
return ((NodeEvent)o).getNode().getNode().equals(expected);
}
@Override
public void describeTo(Description description) {
description.appendText(String.format("NodeEvent for node %s", expected));
}
@Override
public void describeMismatch(Object item, Description description) {
NodeEvent other = (NodeEvent)item;
description.appendText(String.format("got node %s", other.getNode().getNode()));
}
@Factory
public static EventForNode eventForNode(Node expected) {
return new EventForNode(expected);
}
}
|