com.netflix.eureka2.testkit.junit.matchers.InstanceInfoMatcher 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.registry.InstanceInfo;
import com.netflix.eureka2.registry.InstanceInfo.Builder;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
/**
* @author Tomasz Bak
*/
public class InstanceInfoMatcher extends BaseMatcher {
private final InstanceInfo expectedValue;
private final boolean expectSameVersion;
public InstanceInfoMatcher(InstanceInfo expectedValue, boolean expectSameVersion) {
this.expectedValue = expectedValue;
this.expectSameVersion = expectSameVersion;
}
@Override
public boolean matches(Object item) {
if (!(item instanceof InstanceInfo)) {
return false;
}
// Versions may be different
InstanceInfo target = (InstanceInfo) item;
if (!expectSameVersion) {
target = new Builder()
.withInstanceInfo(target)
.withVersion(expectedValue.getVersion())
.build();
}
return target.equals(expectedValue);
}
@Override
public void describeTo(Description description) {
description.appendValue(expectedValue);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy