public List<Service> importServiceDefinition(String repositoryUrl, Secret repositorySecret,
         boolean disableSSLValidation, boolean mainArtifact) throws MockRepositoryImportException {
      log.info("Importing service definitions from {}", repositoryUrl);
      File localFile = null;
      Map<String, List<String>> fileProperties = null;

      if (repositoryUrl.startsWith("http")) {
         try {
            HTTPDownloader.FileAndHeaders fileAndHeaders = HTTPDownloader
                  .handleHTTPDownloadToFileAndHeaders(repositoryUrl, repositorySecret, disableSSLValidation);
            localFile = fileAndHeaders.getLocalFile();
            fileProperties = fileAndHeaders.getResponseHeaders();
         } catch (IOException ioe) {
            throw new MockRepositoryImportException(repositoryUrl + " cannot be downloaded", ioe);
         }
      } else {
         // Simply build localFile from repository url.
         localFile = new File(repositoryUrl);
      }

      RelativeReferenceURLBuilder referenceURLBuilder = RelativeReferenceURLBuilderFactory
            .getRelativeReferenceURLBuilder(fileProperties);
      String artifactName = referenceURLBuilder.getFileName(repositoryUrl, fileProperties);

      // Initialize a reference resolver to the folder of this repositoryUrl.
      ReferenceResolver referenceResolver = new ReferenceResolver(repositoryUrl, repositorySecret, disableSSLValidation,
            referenceURLBuilder);
      return importServiceDefinition(localFile, referenceResolver, new ArtifactInfo(artifactName, mainArtifact));
   }
@Test
   void testImportServiceDefinitionMainGraphQLAndSecondaryExamples() {
      List<Service> services = null;
      try {
         File artifactFile = new File("target/test-classes/io/github/microcks/util/graphql/films.graphql");
         services = service.importServiceDefinition(artifactFile, null, new ArtifactInfo("films.graphql", true));
      } catch (MockRepositoryImportException mrie) {
         fail("No MockRepositoryImportException should have be thrown");
      }

      assertNotNull(services);
      assertEquals(1, services.size());

      // Inspect Service own attributes.
      Service importedSvc = services.get(0);
      assertEquals("Movie Graph API", importedSvc.getName());
      assertEquals("1.0", importedSvc.getVersion());
      assertEquals("films.graphql", importedSvc.getSourceArtifact());
      assertNotNull(importedSvc.getMetadata());
      assertEquals(4, importedSvc.getOperations().size());

      // Inspect and check requests.
      List<Request> requests = requestRepository
            .findByOperationId(IdBuilder.buildOperationId(importedSvc, importedSvc.getOperations().get(0)));
      assertEquals(0, requests.size());

      // Inspect and check responses.
      List<Response> responses = responseRepository
            .findByOperationId(IdBuilder.buildOperationId(importedSvc, importedSvc.getOperations().get(0)));
      assertEquals(0, responses.size());

      try {
         File artifactFile = new File("target/test-classes/io/github/microcks/util/graphql/films-1.0-examples.yml");
         services = service.importServiceDefinition(artifactFile, null,
               new ArtifactInfo("films-1.0-examples.yml", false));
      } catch (MockRepositoryImportException mrie) {
         fail("No MockRepositoryImportException should have be thrown");
      }

      // Inspect Service own attributes.
      importedSvc = services.get(0);
      assertEquals("Movie Graph API", importedSvc.getName());
      assertEquals("1.0", importedSvc.getVersion());
      assertEquals("films.graphql", importedSvc.getSourceArtifact());
      assertNotNull(importedSvc.getMetadata());
      assertEquals(4, importedSvc.getOperations().size());

      // Inspect and check requests.
      requests = requestRepository
            .findByOperationId(IdBuilder.buildOperationId(importedSvc, importedSvc.getOperations().get(0)));
      assertEquals(1, requests.size());
      for (Request request : requests) {
         assertEquals("films-1.0-examples.yml", request.getSourceArtifact());
      }

      // Inspect and check responses.
      responses = responseRepository
            .findByOperationId(IdBuilder.buildOperationId(importedSvc, importedSvc.getOperations().get(0)));
      assertEquals(1, requests.size());
      for (Response response : responses) {
         assertEquals("films-1.0-examples.yml", response.getSourceArtifact());
      }

      // Check that dispatch criteria have been correctly extracted.
      for (Operation operation : importedSvc.getOperations()) {
         if ("film".equals(operation.getName())) {
            requests = requestRepository.findByOperationId(IdBuilder.buildOperationId(importedSvc, operation));
            responses = responseRepository.findByOperationId(IdBuilder.buildOperationId(importedSvc, operation));

            assertEquals(2, requests.size());
            assertEquals(2, responses.size());

            for (Response response : responses) {
               assertTrue("?id=ZmlsbXM6MQ==".equals(response.getDispatchCriteria())
                     || "?id=ZmlsbXM6Mg==".equals(response.getDispatchCriteria()));
            }
         }
      }
   }