com.netflix.eureka2.testkit.junit.matchers.ChangeNotificationMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eureka-testkit Show documentation
Show all versions of eureka-testkit Show documentation
eureka-testkit developed by Netflix
The newest version!
package com.netflix.eureka2.testkit.junit.matchers;
import com.netflix.eureka2.interests.ChangeNotification;
import com.netflix.eureka2.interests.ChangeNotification.Kind;
import com.netflix.eureka2.registry.InstanceInfo;
import com.netflix.eureka2.testkit.junit.EurekaMatchers;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
/**
* @author Tomasz Bak
*/
public class ChangeNotificationMatcher extends BaseMatcher> {
private final Kind notificationKind;
private final InstanceInfo expectedValue;
public ChangeNotificationMatcher(Kind notificationKind, InstanceInfo expectedValue) {
this.notificationKind = notificationKind;
this.expectedValue = expectedValue;
}
@Override
public boolean matches(Object item) {
if (!(item instanceof ChangeNotification)) {
return false;
}
if (!(((ChangeNotification>) item).getData() instanceof InstanceInfo)) {
return false;
}
ChangeNotification actualNotif = (ChangeNotification) item;
if (actualNotif.getKind() != notificationKind) {
return false;
}
return EurekaMatchers.sameInstanceInfoAs(expectedValue).matches(actualNotif.getData());
}
@Override
public void describeTo(Description description) {
description.appendText("Change notification of type " + notificationKind).appendValue(expectedValue);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy