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

com.netflix.eureka2.testkit.data.builder.SampleChangeNotification Maven / Gradle / Ivy

The newest version!
package com.netflix.eureka2.testkit.data.builder;

import com.netflix.eureka2.interests.ChangeNotification;
import com.netflix.eureka2.registry.InstanceInfo;
import rx.Observable;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @author David Liu
 */
public enum SampleChangeNotification {

    ZuulAdd() {
        @Override
        public ChangeNotification newNotification() {
            return newNotification(SampleInstanceInfo.ZuulServer.build());
        }

        @Override
        public ChangeNotification newNotification(InstanceInfo seed) {
            return new ChangeNotification<>(ChangeNotification.Kind.Add, seed);
        }
    },
    ZuulDelete() {
        @Override
        public ChangeNotification newNotification() {
            return newNotification(SampleInstanceInfo.ZuulServer.build());
        }

        @Override
        public ChangeNotification newNotification(InstanceInfo seed) {
            return new ChangeNotification<>(ChangeNotification.Kind.Delete, seed);
        }
    },
    DiscoveryAdd() {
        @Override
        public ChangeNotification newNotification() {
            return newNotification(SampleInstanceInfo.DiscoveryServer.build());
        }

        @Override
        public ChangeNotification newNotification(InstanceInfo seed) {
            return new ChangeNotification<>(ChangeNotification.Kind.Add, seed);
        }
    },
    DiscoveryDelete() {
        @Override
        public ChangeNotification newNotification() {
            return newNotification(SampleInstanceInfo.DiscoveryServer.build());
        }

        @Override
        public ChangeNotification newNotification(InstanceInfo seed) {
            return new ChangeNotification<>(ChangeNotification.Kind.Delete, seed);
        }
    },
    CliAdd() {
        @Override
        public ChangeNotification newNotification() {
            return newNotification(SampleInstanceInfo.CliServer.build());
        }

        @Override
        public ChangeNotification newNotification(InstanceInfo seed) {
            return new ChangeNotification<>(ChangeNotification.Kind.Add, seed);
        }
    },
    CliDelete() {
        @Override
        public ChangeNotification newNotification() {
            return newNotification(SampleInstanceInfo.CliServer.build());
        }

        @Override
        public ChangeNotification newNotification(InstanceInfo seed) {
            return new ChangeNotification<>(ChangeNotification.Kind.Delete, seed);
        }
    };

    public abstract ChangeNotification newNotification();
    public abstract ChangeNotification newNotification(InstanceInfo seed);

    public static Observable> newAddNotifications(SampleChangeNotification type, int n) {
        Collection> result = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            result.add(type.newNotification());
        }
        return Observable.from(result);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy