blob: 5fe5105f0ac01cebc01f8c74abf6ecd127c8c262 (
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
|
// Copyright Vespa.ai. 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.vespa.clustercontroller.core.ClusterEvent;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
public class ClusterEventWithDescription extends BaseMatcher<ClusterEvent> {
private final String expected;
private ClusterEventWithDescription(String expected) {
this.expected = expected;
}
@Override
public boolean matches(Object o) {
if (!(o instanceof ClusterEvent)) {
return false;
}
return expected.equals(((ClusterEvent) o).getDescription());
}
@Override
public void describeTo(Description description) {
description.appendText(String.format("ClusterEvent with description '%s'", expected));
}
@Override
public void describeMismatch(Object item, Description description) {
if (!(item instanceof ClusterEvent)) {
return;
}
ClusterEvent other = (ClusterEvent)item;
description.appendText(String.format("got description '%s'", other.getDescription()));
}
public static ClusterEventWithDescription clusterEventWithDescription(String description) {
return new ClusterEventWithDescription(description);
}
}
|