All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netflix.eureka2.testkit.junit.matchers.ChangeNotificationMatcher Maven / Gradle / Ivy

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