test_class.file: karate-core/src/test/java/com/intuit/karate/formats/postman/PostmanConverterTest.java
test_class.identifier: PostmanConverterTest
test_case.body: @Test
      public void testSuccess() throws IOException {
          if (FileUtils.isOsWindows()) { // TODO
              return;
          }
          // create the temp file and dirctory
          File tempSource = File.createTempFile("karate-postman-input", ".postman_collection.json");
          tempSource.deleteOnExit();
          Path tempOutput = Files.createTempDirectory("karate-postman-output");
          tempOutput.toFile().deleteOnExit();
  
          // populate the temp source file with the Postman export data
          InputStream is = getClass().getResourceAsStream("postman-echo-single.postman_collection");
          String postman = FileUtils.toString(is);
          Files.write(Paths.get(tempSource.toURI()), postman.getBytes());
  
          // perform the conversion
          boolean successful = new PostmanConverter().convert(tempSource.toString(), tempOutput.toString());
          Assert.assertTrue(successful);
  
          // load the expected output from the resources
          is = getClass().getResourceAsStream("expected-converted.txt");
          String expectedConverted = FileUtils.toString(is);
  
          // load the actual output form the disk
          Path actualOutputPath = Paths.get(tempOutput.toString(),
              tempSource.getName().replace(".postman_collection.json", "") + ".feature");
          String converted = new String(Files.readAllBytes(actualOutputPath), StandardCharsets.UTF_8);
  
          // the first line is dynamic, as it contains the temp dir characters
          Assert.assertTrue(converted.startsWith("Feature: karate-postman-input"));
  
          // trim the file so it doesn't contain the line starting with 'Feature':
          String convertedTrimmed = Arrays.stream(converted.split(System.lineSeparator()))
              .filter(line -> !line.startsWith("Feature:"))
              .collect(Collectors.joining(System.lineSeparator()));
  
          // assert that the trimmed actual output equals the trimmed expected output
          Assert.assertEquals(convertedTrimmed.trim(), expectedConverted.trim());
      }
test_case.class_method_signature: PostmanConverterTest.testSuccess()
test_case.full_signature: @Test public void testSuccess()
test_case.identifier: testSuccess
test_case.invocations: isOsWindows createTempFile deleteOnExit createTempDirectory deleteOnExit toFile getResourceAsStream getClass toString write get toURI getBytes convert toString toString assertTrue getResourceAsStream getClass toString get toString replace getName readAllBytes assertTrue startsWith collect filter stream split lineSeparator startsWith joining lineSeparator assertEquals trim trim
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSuccess()
focal_class.file: karate-core/src/main/java/com/intuit/karate/formats/postman/PostmanConverter.java
focal_class.identifier: PostmanConverter
focal_class.class_method_signature: PostmanConverter.convert(final String importFile, final String outputDir)
focal_class.full_signature: public boolean convert(final String importFile, final String outputDir)
focal_class.identifier: convert
focal_class.modifiers: public
focal_class.parameters: (final String importFile, final String outputDir)
focal_class.return: boolean
focal_class.signature: boolean convert(final String importFile, final String outputDir)
focal_method.body: public boolean convert(final String importFile, final String outputDir) {
          try {
              final Path pathTo = Paths.get(importFile);
              if (!Files.exists(pathTo)) {
                  System.err.println("File at '" + importFile + "' does not exist; cannot import");
                  return false;
              }
              final String content = new String(Files.readAllBytes(pathTo), StandardCharsets.UTF_8);
              final List<PostmanItem> items = PostmanUtils.readPostmanJson(content);
              final String collectionName = pathTo.getFileName().toString()
                  .replace(".postman_collection", "")
                  .replace(".json", "");
              final String converted = PostmanUtils.toKarateFeature(collectionName, items);
              final Path outputFilePath = Paths.get(outputDir, collectionName + ".feature");
              Files.write(outputFilePath, converted.getBytes());
              System.out.println("Converted feature file available at " + outputFilePath.toAbsolutePath().toString());
              return true;
          } catch (IOException e) {
              System.err.println("An error occurred with processing the file - the task could not be completed");
              return false;
          }
      }
focal_method.class_method_signature: PostmanConverter.convert(final String importFile, final String outputDir)
focal_method.full_signature: public boolean convert(final String importFile, final String outputDir)
focal_method.identifier: convert
focal_method.invocations: get exists println readAllBytes readPostmanJson replace replace toString getFileName toKarateFeature get write getBytes println toString toAbsolutePath println
focal_method.modifiers: public
focal_method.parameters: (final String importFile, final String outputDir)
focal_method.return: boolean
focal_method.signature: boolean convert(final String importFile, final String outputDir)