aboutsummaryrefslogtreecommitdiffstats
path: root/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/matchers/EventForNode.java
blob: 55be4dbd70933a5e52531ce434a45363ecdbae65 (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
// Copyright Yahoo. 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.BaseMatcher;
import org.hamcrest.Description;

public class EventForNode extends BaseMatcher<NodeEvent> {
    private final Node expected;

    private 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()));
    }

    public static EventForNode eventForNode(Node expected) {
        return new EventForNode(expected);
    }
}