// Path: graphql-testdata/src/main/java/org/example/graphql/testdata/droids/DroidsSchema.java
// public static final GraphQLSchema droidsSchema = GraphQLSchema.newSchema()
//         .query(queryType)
//         .build();
// 
// Path: graphql-testdata/src/main/java/org/example/graphql/testdata/starwars/StarWarsSchema.java
// public static final GraphQLSchema starWarsSchema = GraphQLSchema.newSchema()
//          .query(queryType)
//          .build();


import static org.junit.Assert.assertTrue;
import io.vertx.core.Future;
import io.vertx.core.Vertx;
import io.vertx.ext.unit.Async;
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.RunTestOnContext;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import io.vertx.servicediscovery.ServiceDiscovery;
import io.vertx.servicediscovery.ServiceDiscoveryOptions;
import org.junit.*;
import org.junit.runner.RunWith;
import static org.example.graphql.testdata.droids.DroidsSchema.droidsSchema;
import static org.example.graphql.testdata.starwars.StarWarsSchema.starWarsSchema;
import static org.junit.Assert.assertEquals;

    @Before
    public void setUp() {
        vertx = rule.vertx();
        options = new ServiceDiscoveryOptions().setName("theDiscovery")
                .setAnnounceAddress("announceAddress").setUsageAddress("usageAddress");
        schemaRegistrar = SchemaRegistrar.create(vertx);
        schemaPublisher = new TestClass(schemaRegistrar);
    }

    @After
    public void tearDown(TestContext context) {
        vertx.close();
        schemaRegistrar.close(null, context.asyncAssertSuccess());
    }

    @Test
    public void should_Manage_Schema_Registration_And_Close_Properly(TestContext context) {
        Async async = context.async();
        context.assertNotNull(schemaRegistrar.getPublisherId());
        schemaRegistrar = SchemaRegistrar.create(vertx, "thePublisherId");
        context.assertEquals("thePublisherId", schemaRegistrar.getPublisherId());

        ServiceDiscovery discovery = schemaRegistrar.getOrCreateDiscovery(options);
        context.assertNotNull(discovery);
        context.assertNotNull(schemaRegistrar.registrations());
        context.assertEquals(0, schemaRegistrar.registrations().size());

        // Fans of nested handlers, take note! ;)
        // Publish 1
// Path: graphql-testdata/src/main/java/org/example/graphql/testdata/droids/DroidsSchema.java
// public static final GraphQLSchema droidsSchema = GraphQLSchema.newSchema()
//         .query(queryType)
//         .build();
// 
// Path: graphql-testdata/src/main/java/org/example/graphql/testdata/starwars/StarWarsSchema.java
// public static final GraphQLSchema starWarsSchema = GraphQLSchema.newSchema()
//          .query(queryType)
//          .build();


// Path: graphql-service-publisher/src/test/java/io/engagingspaces/graphql/servicediscovery/publisher/SchemaRegistrarTest.java
import static org.junit.Assert.assertTrue;
import io.vertx.core.Future;
import io.vertx.core.Vertx;
import io.vertx.ext.unit.Async;
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.RunTestOnContext;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import io.vertx.servicediscovery.ServiceDiscovery;
import io.vertx.servicediscovery.ServiceDiscoveryOptions;
import org.junit.*;
import org.junit.runner.RunWith;
import static org.example.graphql.testdata.droids.DroidsSchema.droidsSchema;
import static org.example.graphql.testdata.starwars.StarWarsSchema.starWarsSchema;
import static org.junit.Assert.assertEquals;


    @Before
    public void setUp() {
        vertx = rule.vertx();
        options = new ServiceDiscoveryOptions().setName("theDiscovery")
                .setAnnounceAddress("announceAddress").setUsageAddress("usageAddress");
        schemaRegistrar = SchemaRegistrar.create(vertx);
        schemaPublisher = new TestClass(schemaRegistrar);
    }

    @After
    public void tearDown(TestContext context) {
        vertx.close();
        schemaRegistrar.close(null, context.asyncAssertSuccess());
    }

    @Test
    public void should_Manage_Schema_Registration_And_Close_Properly(TestContext context) {
        Async async = context.async();
        context.assertNotNull(schemaRegistrar.getPublisherId());
        schemaRegistrar = SchemaRegistrar.create(vertx, "thePublisherId");
        context.assertEquals("thePublisherId", schemaRegistrar.getPublisherId());

        ServiceDiscovery discovery = schemaRegistrar.getOrCreateDiscovery(options);
        context.assertNotNull(discovery);
        context.assertNotNull(schemaRegistrar.registrations());
        context.assertEquals(0, schemaRegistrar.registrations().size());

        // Fans of nested handlers, take note! ;)
        // Publish 1
        schemaPublisher.publish(options, droidsSchema, rh -> {