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 testImportServiceDefinitionFromGitLabURL() {
      List<Service> services = null;
      try {
         services = service.importServiceDefinition(
               "https://gitlab.com/api/v4/projects/53583367/repository/files/complex-example%2Fopenapi.yaml/raw?head=main",
               null, true, 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("OpenAPI Car API", importedSvc.getName());
      assertEquals("1.0.0", importedSvc.getVersion());
      assertEquals("openapi.yaml", importedSvc.getSourceArtifact());

      // Inspect and check resources.
      List<Resource> resources = resourceRepository.findByServiceId(importedSvc.getId());
      assertEquals(10, resources.size());

      // Now inspect operations.
      assertEquals(1, importedSvc.getOperations().size());
      assertEquals("GET /owner/{owner}/car", importedSvc.getOperations().get(0).getName());
      assertEquals(DispatchStyles.URI_PARTS, importedSvc.getOperations().get(0).getDispatcher());
      assertEquals(3, importedSvc.getOperations().get(0).getResourcePaths().size());

      // Inspect and check requests.
      List<Request> requests = requestRepository
            .findByOperationId(IdBuilder.buildOperationId(importedSvc, importedSvc.getOperations().get(0)));
      assertEquals(3, requests.size());
      for (Request request : requests) {
         assertEquals("openapi.yaml", request.getSourceArtifact());
      }

      // Inspect and check responses.
      List<Response> responses = responseRepository
            .findByOperationId(IdBuilder.buildOperationId(importedSvc, importedSvc.getOperations().get(0)));
      assertEquals(3, responses.size());
      for (Response response : responses) {
         assertEquals("openapi.yaml", response.getSourceArtifact());
         switch (response.getName()) {
            case "laurent":
               assertEquals("/owner=0", response.getDispatchCriteria());
               assertEquals("[{\"model\":\"BMW X5\",\"year\":2018},{\"model\":\"Tesla Model 3\",\"year\":2020}]",
                     response.getContent());
               break;
            case "maxime":
               assertEquals("/owner=1", response.getDispatchCriteria());
               assertEquals("[{\"model\":\"Volkswagen Golf\",\"year\":2017}]", response.getContent());
               break;
            case "NOT_FOUND":
               assertEquals("/owner=999999999", response.getDispatchCriteria());
               assertEquals("{\"error\":\"Could not find owner\"}", response.getContent());
               break;
            default:
               fail("Unknown response message");
         }
      }
   }