@Override
   public List<Service> getServiceDefinitions() throws MockRepositoryImportException {
      List<Service> result = new ArrayList<>();

      // Build a new service.
      Service service = new Service();

      JsonNode metadataNode = spec.get("metadata");
      if (metadataNode == null) {
         log.error("Missing mandatory metadata in {}", spec.asText());
         throw new MockRepositoryImportException("Mandatory metadata property is missing in APIMetadata");
      }
      service.setName(metadataNode.path("name").asText());
      service.setVersion(metadataNode.path("version").asText());

      Metadata metadata = new Metadata();
      MetadataExtractor.completeMetadata(metadata, metadataNode);
      service.setMetadata(metadata);

      // Then build its operations.
      service.setOperations(extractOperations());

      result.add(service);
      return result;
   }
@Test
   void testAPIMetadataImport() {
      MetadataImporter importer = null;
      try {
         importer = new MetadataImporter(
               "target/test-classes/io/github/microcks/util/metadata/hello-grpc-v1-metadata.yml");
      } catch (IOException ioe) {
         fail("Exception should not be thrown");
      }

      // Check that basic service properties are there.
      List<Service> services = null;
      try {
         services = importer.getServiceDefinitions();
      } catch (MockRepositoryImportException e) {
         fail("Exception should not be thrown");
      }
      assertEquals(1, services.size());
      Service service = services.get(0);
      assertEquals("HelloService", service.getName());
      assertEquals("v1", service.getVersion());

      assertEquals(3, service.getMetadata().getLabels().size());
      assertEquals("greeting", service.getMetadata().getLabels().get("domain"));
      assertEquals("stable", service.getMetadata().getLabels().get("status"));
      assertEquals("Team A", service.getMetadata().getLabels().get("team"));

      assertEquals(1, service.getOperations().size());
      Operation operation = service.getOperations().get(0);

      assertEquals("POST /greeting", operation.getName());
      assertEquals(Long.valueOf(100), operation.getDefaultDelay());
      assertEquals(DispatchStyles.JSON_BODY, operation.getDispatcher());
      assertNotNull(operation.getDispatcherRules());
   }