// Path: graphql-core/src/main/java/io/engagingspaces/graphql/discovery/impl/AbstractRegistration.java
// public class AbstractRegistration implements Registration {
// 
//     private final ServiceDiscovery discovery;
//     private final ServiceDiscoveryOptions options;
// 
//     protected AbstractRegistration(ServiceDiscovery discovery, ServiceDiscoveryOptions options) {
//         Objects.requireNonNull(discovery, "Service discovery cannot be null");
//         this.discovery = discovery;
//         this.options = options;
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public ServiceDiscovery getDiscovery() {
//         return discovery;
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public ServiceDiscoveryOptions getDiscoveryOptions() {
//         return options == null ? null : new ServiceDiscoveryOptions(options);
//     }
// 
//     /**
//      * @param other the object to compare to this registration
//      * @return {@code true} when equal, {@code false} otherwise
//      */
//     @Override
//     public boolean equals(Object other) {
//         if (other == this) {
//             return true;
//         }
//         if (!(other instanceof AbstractRegistration)) {
//             return false;
//         }
//         AbstractRegistration test = (AbstractRegistration) other;
//         return fieldEquals(discovery, test.discovery) && fieldEquals(options.getName(), test.options.getName());
//     }
// 
//     private static boolean fieldEquals(Object value1, Object value2) {
//         return value1 == null ? value2 == null : value1.equals(value2);
//     }
// 
//     /**
//      * @return the hash code of the registration
//      */
//     @Override
//     public int hashCode() {
//         int result = 17;
//         result = 31 * result + (discovery == null ? 0 : discovery.hashCode());
//         result = 31 * result + (options.getName() == null ? 0 : options.getName().hashCode());
//         return result;
//     }
// }


import io.engagingspaces.graphql.discovery.impl.AbstractRegistration;
import io.vertx.core.Vertx;
import io.vertx.servicediscovery.ServiceDiscovery;
import io.vertx.servicediscovery.ServiceDiscoveryOptions;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
    private ServiceDiscoveryOptions options2;

    @Before
    public void setUp() {
        vertx = Vertx.vertx();
        options = new ServiceDiscoveryOptions().setName("theDiscovery")
                .setAnnounceAddress("foo").setUsageAddress("bar");
        options2 = new ServiceDiscoveryOptions().setName("theDiscovery2")
                .setAnnounceAddress("foo").setUsageAddress("bar");
        discovery = ServiceDiscovery.create(vertx, options);
        discovery2 = ServiceDiscovery.create(vertx, options);
    }

    @Test
    public void should_Include_Record_Name_And_Type_In_Equality_Check() {
        DiscoveryRegistration result1 = DiscoveryRegistration.create(discovery, options);
        assertNotEquals(result1, new testRegistration(discovery, options));
        assertEquals(result1, DiscoveryRegistration.create(discovery, options));
        DiscoveryRegistration result2 = DiscoveryRegistration.create(discovery2, options);
        assertNotEquals(result1, result2);
        DiscoveryRegistration result3 = DiscoveryRegistration.create(discovery2, options2);
        assertNotEquals(result2, result3);

        // Ignore addresses
        DiscoveryRegistration result4 = DiscoveryRegistration.create(discovery2,
                options.setAnnounceAddress("baz").setUsageAddress("brr"));
        assertEquals(result2, result4);
        assertEquals(result2.hashCode(), result4.hashCode());
    }

// Path: graphql-core/src/main/java/io/engagingspaces/graphql/discovery/impl/AbstractRegistration.java
// public class AbstractRegistration implements Registration {
// 
//     private final ServiceDiscovery discovery;
//     private final ServiceDiscoveryOptions options;
// 
//     protected AbstractRegistration(ServiceDiscovery discovery, ServiceDiscoveryOptions options) {
//         Objects.requireNonNull(discovery, "Service discovery cannot be null");
//         this.discovery = discovery;
//         this.options = options;
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public ServiceDiscovery getDiscovery() {
//         return discovery;
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public ServiceDiscoveryOptions getDiscoveryOptions() {
//         return options == null ? null : new ServiceDiscoveryOptions(options);
//     }
// 
//     /**
//      * @param other the object to compare to this registration
//      * @return {@code true} when equal, {@code false} otherwise
//      */
//     @Override
//     public boolean equals(Object other) {
//         if (other == this) {
//             return true;
//         }
//         if (!(other instanceof AbstractRegistration)) {
//             return false;
//         }
//         AbstractRegistration test = (AbstractRegistration) other;
//         return fieldEquals(discovery, test.discovery) && fieldEquals(options.getName(), test.options.getName());
//     }
// 
//     private static boolean fieldEquals(Object value1, Object value2) {
//         return value1 == null ? value2 == null : value1.equals(value2);
//     }
// 
//     /**
//      * @return the hash code of the registration
//      */
//     @Override
//     public int hashCode() {
//         int result = 17;
//         result = 31 * result + (discovery == null ? 0 : discovery.hashCode());
//         result = 31 * result + (options.getName() == null ? 0 : options.getName().hashCode());
//         return result;
//     }
// }


// Path: graphql-service-consumer/src/test/java/io/engagingspaces/graphql/servicediscovery/consumer/DiscoveryRegistrationTest.java
import io.engagingspaces.graphql.discovery.impl.AbstractRegistration;
import io.vertx.core.Vertx;
import io.vertx.servicediscovery.ServiceDiscovery;
import io.vertx.servicediscovery.ServiceDiscoveryOptions;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;

    private ServiceDiscoveryOptions options2;

    @Before
    public void setUp() {
        vertx = Vertx.vertx();
        options = new ServiceDiscoveryOptions().setName("theDiscovery")
                .setAnnounceAddress("foo").setUsageAddress("bar");
        options2 = new ServiceDiscoveryOptions().setName("theDiscovery2")
                .setAnnounceAddress("foo").setUsageAddress("bar");
        discovery = ServiceDiscovery.create(vertx, options);
        discovery2 = ServiceDiscovery.create(vertx, options);
    }

    @Test
    public void should_Include_Record_Name_And_Type_In_Equality_Check() {
        DiscoveryRegistration result1 = DiscoveryRegistration.create(discovery, options);
        assertNotEquals(result1, new testRegistration(discovery, options));
        assertEquals(result1, DiscoveryRegistration.create(discovery, options));
        DiscoveryRegistration result2 = DiscoveryRegistration.create(discovery2, options);
        assertNotEquals(result1, result2);
        DiscoveryRegistration result3 = DiscoveryRegistration.create(discovery2, options2);
        assertNotEquals(result2, result3);

        // Ignore addresses
        DiscoveryRegistration result4 = DiscoveryRegistration.create(discovery2,
                options.setAnnounceAddress("baz").setUsageAddress("brr"));
        assertEquals(result2, result4);
        assertEquals(result2.hashCode(), result4.hashCode());
    }

    private class testRegistration extends AbstractRegistration {