[Cucumber for Java] extract intefaces from CucumberJvmAdapter, remove unnecessary...
authorAndrey Vokin <andrey.vokin@jetbrains.com>
Mon, 11 Nov 2019 11:10:40 +0000 (12:10 +0100)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Mon, 11 Nov 2019 17:12:03 +0000 (17:12 +0000)
GitOrigin-RevId: 67e2bac34e656d171cbad847210d453f7f50ee29

15 files changed:
platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java
plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvm2Adapter.java
plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvm2SMFormatter.java
plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvmAdapter.java [deleted file]
plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvmSMConverter.java
plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvmSMFormatterUtil.java
plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/IdeaTestCase.java [new file with mode: 0644]
plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/IdeaTestSourceReadEvent.java [new file with mode: 0644]
plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/IdeaTestStep.java [new file with mode: 0644]
plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/IdeaTestStepFinishedEvent.java [new file with mode: 0644]
plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/IdeaWriteEvent.java [new file with mode: 0644]
plugins/cucumber-jvm-formatter3/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvm3Adapter.java
plugins/cucumber-jvm-formatter3/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvm3SMFormatter.java
plugins/cucumber-jvm-formatter5/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvm5Adapter.java
plugins/cucumber-jvm-formatter5/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvm5SMFormatter.java

index 20078f4bc69350a19eac9ab0b7749c6535cb604d..a3d695d6577b6e5f20cd319b5bf7cd58bd652ed0 100644 (file)
@@ -1084,7 +1084,7 @@ public class PlatformTestUtil {
         latch.countDown();
       }
     });
-    latch.await();
+    latch.await(60, TimeUnit.SECONDS);
     ProcessHandler processHandler = refRunContentDescriptor.get().getProcessHandler();
     if (processHandler == null) {
       return null;
@@ -1092,7 +1092,7 @@ public class PlatformTestUtil {
 
     CapturingProcessAdapter capturingProcessAdapter = new CapturingProcessAdapter();
     processHandler.addProcessListener(capturingProcessAdapter);
-    processHandler.waitFor();
+    processHandler.waitFor(60000);
 
     if (capturingProcessAdapter.getOutput().getStderr().length() > 0) {
       LOG.warn(capturingProcessAdapter.getOutput().getStderr());
index ba4ed98b02f5d9c697223c8a1e9d5c76710e3fc4..2bfc30e36a8e60ffd25082087ebd22acda8ba4d8 100644 (file)
@@ -12,53 +12,19 @@ import java.lang.reflect.Method;
 import static org.jetbrains.plugins.cucumber.java.run.CucumberJvmSMFormatterUtil.FILE_RESOURCE_PREFIX;
 
 public class CucumberJvm2Adapter {
-  public static class IdeaTestCaseEvent implements CucumberJvmAdapter.IdeaTestCaseEvent {
-    private final IdeaTestCase myTestCase;
-
-    public IdeaTestCaseEvent(TestCaseStarted testCaseStarted) {
-      myTestCase = new IdeaTestCase(testCaseStarted.testCase);
-    }
-
-    public IdeaTestCaseEvent(TestCaseFinished testCaseFinished) {
-      myTestCase = new IdeaTestCase(testCaseFinished.testCase);
-    }
-
-
-    @Override
-    public CucumberJvmAdapter.IdeaTestCase getTestCase() {
-      return myTestCase;
-    }
-
-    @Override
-    public String getUri() {
-      return myTestCase.getUri();
-    }
-  }
-
-  public static class IdeaTestStepEvent implements CucumberJvmAdapter.IdeaTestStepEvent {
+  public static class IdeaTestStepFinishedEvent implements org.jetbrains.plugins.cucumber.java.run.IdeaTestStepFinishedEvent {
     private final IdeaTestStep myTestStep;
+    private final TestStepFinished myRealEvent;
 
-    public IdeaTestStepEvent(TestStepStarted testStepStarted) {
-      this(testStepStarted.testStep);
-    }
-
-    public IdeaTestStepEvent(TestStep testStep) {
-      myTestStep = new IdeaTestStep(testStep);
+    public IdeaTestStepFinishedEvent(TestStepFinished testStepFinished) {
+      myTestStep = new IdeaTestStep(testStepFinished.testStep);
+      myRealEvent = testStepFinished;
     }
 
     @Override
-    public CucumberJvmAdapter.IdeaTestStep getTestStep() {
+    public org.jetbrains.plugins.cucumber.java.run.IdeaTestStep getTestStep() {
       return myTestStep;
     }
-  }
-
-  public static class IdeaTestStepFinishedEvent extends IdeaTestStepEvent implements CucumberJvmAdapter.IdeaTestStepFinishedEvent {
-    TestStepFinished myRealEvent;
-
-    public IdeaTestStepFinishedEvent(TestStepFinished testStepFinished) {
-      super(testStepFinished.testStep);
-      myRealEvent = testStepFinished;
-    }
 
     @Override
     public Status getResult() {
@@ -81,7 +47,7 @@ public class CucumberJvm2Adapter {
     }
   }
 
-  public static class IdeaTestCase implements CucumberJvmAdapter.IdeaTestCase {
+  public static class IdeaTestCase implements org.jetbrains.plugins.cucumber.java.run.IdeaTestCase {
     private final TestCase myRealTestCase;
 
     IdeaTestCase(TestCase realTestCase) {
@@ -119,7 +85,7 @@ public class CucumberJvm2Adapter {
     }
   }
 
-  public static class IdeaTestStep implements CucumberJvmAdapter.IdeaTestStep {
+  public static class IdeaTestStep implements org.jetbrains.plugins.cucumber.java.run.IdeaTestStep {
     private final TestStep myRealStep;
 
     public IdeaTestStep(TestStep realStep) {
index d79a11002d04c456f4bf010fcda745ad17a58077..cdde0b112136524812cb2b957b74507259facf55 100644 (file)
@@ -19,14 +19,14 @@ public class CucumberJvm2SMFormatter extends CucumberJvmSMConverter implements F
   private final EventHandler<TestCaseStarted> testCaseStartedHandler = new EventHandler<TestCaseStarted>() {
     @Override
     public void receive(TestCaseStarted event) {
-      CucumberJvm2SMFormatter.this.handleTestCaseStarted(new CucumberJvm2Adapter.IdeaTestCaseEvent(event));
+      CucumberJvm2SMFormatter.this.handleTestCaseStarted(new CucumberJvm2Adapter.IdeaTestCase(event.testCase));
     }
   };
 
   private final EventHandler<TestCaseFinished> testCaseFinishedHandler = new EventHandler<TestCaseFinished>() {
     @Override
     public void receive(TestCaseFinished event) {
-      handleTestCaseFinished(new CucumberJvm2Adapter.IdeaTestCaseEvent(event));
+      handleTestCaseFinished(new CucumberJvm2Adapter.IdeaTestCase(event.testCase));
     }
   };
 
@@ -40,14 +40,14 @@ public class CucumberJvm2SMFormatter extends CucumberJvmSMConverter implements F
   private final EventHandler<WriteEvent> writeEventHandler = new EventHandler<WriteEvent>() {
     @Override
     public void receive(WriteEvent event) {
-      CucumberJvm2SMFormatter.this.handleWriteEvent(new CucumberJvmAdapter.IdeaWriteEvent(event.text));
+      CucumberJvm2SMFormatter.this.handleWriteEvent(new IdeaWriteEvent(event.text));
     }
   };
 
   private final EventHandler<TestStepStarted> testStepStartedHandler = new EventHandler<TestStepStarted>() {
     @Override
     public void receive(TestStepStarted event) {
-      handleTestStepStarted(new CucumberJvm2Adapter.IdeaTestStepEvent(event));
+      handleTestStepStarted(new CucumberJvm2Adapter.IdeaTestStep(event.testStep));
     }
   };
 
@@ -61,7 +61,7 @@ public class CucumberJvm2SMFormatter extends CucumberJvmSMConverter implements F
   private final EventHandler<TestSourceRead> testSourceReadHandler = new EventHandler<TestSourceRead>() {
     @Override
     public void receive(TestSourceRead event) {
-      CucumberJvm2SMFormatter.this.handleTestSourceRead(new CucumberJvmAdapter.IdeaTestSourceReadEvent(event.uri, event.source));
+      CucumberJvm2SMFormatter.this.handleTestSourceRead(new IdeaTestSourceReadEvent(event.uri, event.source));
     }
   };
 
diff --git a/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvmAdapter.java b/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/CucumberJvmAdapter.java
deleted file mode 100644 (file)
index 4e01d75..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
-package org.jetbrains.plugins.cucumber.java.run;
-
-public class CucumberJvmAdapter {
-  interface IdeaTestCaseEvent {
-    IdeaTestCase getTestCase();
-    String getUri();
-  }
-
-  interface IdeaTestStepEvent {
-    IdeaTestStep getTestStep();
-  }
-
-  interface IdeaTestStepFinishedEvent extends IdeaTestStepEvent {
-    enum Status {PASSED, PENDING, SKIPPED, FAILED, }
-    Status getResult();
-    Long getDuration();
-    String getErrorMessage();
-  }
-
-  public static class IdeaWriteEvent {
-    private final String myText;
-
-    public IdeaWriteEvent(String text) {
-      myText = text;
-    }
-
-    public String getText() {
-      return myText;
-    }
-  }
-
-  public static class IdeaTestSourceReadEvent {
-    private final String myUri;
-
-    private final String mySource;
-
-    public IdeaTestSourceReadEvent(String uri, String source) {
-      myUri = uri;
-      mySource = source;
-    }
-
-    public String getUri() {
-      return myUri;
-    }
-
-    public String getSource() {
-      return mySource;
-    }
-  }
-
-  interface IdeaTestCase {
-    boolean isScenarioOutline();
-    String getUri();
-    int getScenarioOutlineLine();
-    int getLine();
-    String getScenarioName();
-  }
-
-  interface IdeaTestStep {
-    String getLocation();
-    String getStepName();
-  }
-}
index 488d9b42a9dfeb253c0ad8cf35e1b37c79828fc1..1b416333767100d90e24b1ba4c6418a4593a772d 100644 (file)
@@ -32,40 +32,41 @@ public class CucumberJvmSMConverter {
     outCommand(TEMPLATE_SCENARIO_COUNTING_STARTED, "0", getCurrentTime());
   }
 
-  protected void handleTestCaseStarted(CucumberJvmAdapter.IdeaTestCaseEvent event) {
+  protected void handleTestCaseStarted(IdeaTestCase testCase) {
+    String uri = testCase.getUri();
     if (currentFilePath == null) {
-      outCommand(TEMPLATE_TEST_SUITE_STARTED, getCurrentTime(), getEventUri(event), getFeatureFileDescription(getEventUri(event)));
+      outCommand(TEMPLATE_TEST_SUITE_STARTED, getCurrentTime(), uri, getFeatureFileDescription(uri));
     }
-    else if (!getEventUri(event).equals(currentFilePath)) {
+    else if (!uri.equals(currentFilePath)) {
       closeCurrentScenarioOutline();
       outCommand(TEMPLATE_TEST_SUITE_FINISHED, getCurrentTime(), getFeatureFileDescription(currentFilePath));
-      outCommand(TEMPLATE_TEST_SUITE_STARTED, getCurrentTime(), getEventUri(event), getFeatureFileDescription(getEventUri(event)));
+      outCommand(TEMPLATE_TEST_SUITE_STARTED, getCurrentTime(), uri, getFeatureFileDescription(uri));
     }
 
     outCommand(TEMPLATE_SCENARIO_STARTED, getCurrentTime());
 
-    if (event.getTestCase().isScenarioOutline()) {
-      int mainScenarioLine = event.getTestCase().getScenarioOutlineLine();
+    if (testCase.isScenarioOutline()) {
+      int mainScenarioLine = testCase.getScenarioOutlineLine();
       if (currentScenarioOutlineLine != mainScenarioLine || currentFilePath == null ||
-          !currentFilePath.equals(getEventUri(event))) {
+          !currentFilePath.equals(uri)) {
         closeCurrentScenarioOutline();
         currentScenarioOutlineLine = mainScenarioLine;
-        currentScenarioOutlineName = "Scenario Outline: " + event.getTestCase().getScenarioName();
-        outCommand(TEMPLATE_TEST_SUITE_STARTED, getCurrentTime(), getEventUri(event) + ":" + currentScenarioOutlineLine,
+        currentScenarioOutlineName = "Scenario Outline: " + testCase.getScenarioName();
+        outCommand(TEMPLATE_TEST_SUITE_STARTED, getCurrentTime(), uri + ":" + currentScenarioOutlineLine,
                    currentScenarioOutlineName);
         outCommand(TEMPLATE_TEST_SUITE_STARTED, getCurrentTime(), "", EXAMPLES_CAPTION);
       }
     } else {
       closeCurrentScenarioOutline();
     }
-    currentFilePath = getEventUri(event);
+    currentFilePath = uri;
 
-    outCommand(TEMPLATE_TEST_SUITE_STARTED, getCurrentTime(), getEventUri(event) + ":" + event.getTestCase().getLine(),
-               getScenarioName(event.getTestCase()));
+    outCommand(TEMPLATE_TEST_SUITE_STARTED, getCurrentTime(), uri + ":" + testCase.getLine(),
+               getScenarioName(testCase));
   }
 
-  protected void handleTestCaseFinished(CucumberJvmAdapter.IdeaTestCaseEvent event) {
-    outCommand(TEMPLATE_TEST_SUITE_FINISHED, getCurrentTime(), getScenarioName(event.getTestCase()));
+  protected void handleTestCaseFinished(IdeaTestCase testCase) {
+    outCommand(TEMPLATE_TEST_SUITE_FINISHED, getCurrentTime(), getScenarioName(testCase));
     outCommand(TEMPLATE_SCENARIO_FINISHED, getCurrentTime());
   }
 
@@ -74,20 +75,20 @@ public class CucumberJvmSMConverter {
     outCommand(TEMPLATE_TEST_SUITE_FINISHED, getCurrentTime(), getFeatureFileDescription(currentFilePath));
   }
 
-  protected void handleWriteEvent(CucumberJvmAdapter.IdeaWriteEvent event) {
+  protected void handleWriteEvent(IdeaWriteEvent event) {
     myOut.println(event.getText());
   }
 
-  protected void handleTestStepStarted(CucumberJvmAdapter.IdeaTestStepEvent event) {
-    outCommand(TEMPLATE_TEST_STARTED, getCurrentTime(), event.getTestStep().getLocation(), event.getTestStep().getStepName());
+  protected void handleTestStepStarted(IdeaTestStep testStep) {
+    outCommand(TEMPLATE_TEST_STARTED, getCurrentTime(), testStep.getLocation(), testStep.getStepName());
   }
 
-  protected void handleTestStepFinished(CucumberJvmAdapter.IdeaTestStepFinishedEvent event) {
-    if (event.getResult() == CucumberJvmAdapter.IdeaTestStepFinishedEvent.Status.PASSED) {
+  protected void handleTestStepFinished(IdeaTestStepFinishedEvent event) {
+    if (event.getResult() == IdeaTestStepFinishedEvent.Status.PASSED) {
       // write nothing
     }
-    else if (event.getResult() == CucumberJvmAdapter.IdeaTestStepFinishedEvent.Status.SKIPPED ||
-             event.getResult() == CucumberJvmAdapter.IdeaTestStepFinishedEvent.Status.PENDING) {
+    else if (event.getResult() == IdeaTestStepFinishedEvent.Status.SKIPPED ||
+             event.getResult() == IdeaTestStepFinishedEvent.Status.PENDING) {
       outCommand(TEMPLATE_TEST_PENDING, event.getTestStep().getStepName(), getCurrentTime());
     }
     else {
@@ -105,7 +106,7 @@ public class CucumberJvmSMConverter {
     outCommand(TEMPLATE_TEST_FINISHED, getCurrentTime(), String.valueOf(event.getDuration()), event.getTestStep().getStepName());
   }
 
-  protected void handleTestSourceRead(CucumberJvmAdapter.IdeaTestSourceReadEvent event) {
+  protected void handleTestSourceRead(IdeaTestSourceReadEvent event) {
     closeCurrentScenarioOutline();
     pathToDescription.put(event.getUri(), getFeatureName(event.getSource()));
   }
@@ -155,17 +156,13 @@ public class CucumberJvmSMConverter {
     myOut.println(escapeCommand(command, parameters));
   }
 
-  private static String getScenarioName(CucumberJvmAdapter.IdeaTestCase testCase) {
+  private static String getScenarioName(IdeaTestCase testCase) {
     if (testCase.isScenarioOutline()) {
       return SCENARIO_OUTLINE_CAPTION + testCase.getLine();
     }
     return "Scenario: " + testCase.getScenarioName();
   }
 
-  protected String getEventUri(CucumberJvmAdapter.IdeaTestCaseEvent event) {
-    return event.getUri();
-  }
-
   private String getCurrentTime() {
     if (myCurrentTimeValue != null) {
       return myCurrentTimeValue;
index 39848de4f5774b09ff2d929f6f7901ac38d062b6..67e3db68a8a29257597e0c574629f7cf1a5f8948 100644 (file)
@@ -1,7 +1,5 @@
 package org.jetbrains.plugins.cucumber.java.run;
 
-import cucumber.api.TestStep;
-
 import java.io.BufferedReader;
 import java.io.FileReader;
 import java.io.IOException;
@@ -97,14 +95,14 @@ public class CucumberJvmSMFormatterUtil {
   }
 
   public static String getStepKeyword(String filePath, int lineNumber) throws IOException {
-    String line = readLineNumber(filePath, lineNumber);
+    String line = readLineWithNumber(filePath, lineNumber);
     if (line != null) {
       return line.trim().split(" ", 2)[0];
     }
     return null;
   }
 
-  private static String readLineNumber(String filePath, int lineNumber) throws IOException {
+  private static String readLineWithNumber(String filePath, int lineNumber) throws IOException {
     int currentLineNumber = 0;
     FileReader fileStream = null;
     try {
diff --git a/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/IdeaTestCase.java b/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/IdeaTestCase.java
new file mode 100644 (file)
index 0000000..a107475
--- /dev/null
@@ -0,0 +1,10 @@
+// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+package org.jetbrains.plugins.cucumber.java.run;
+
+interface IdeaTestCase {
+  boolean isScenarioOutline();
+  String getUri();
+  int getScenarioOutlineLine();
+  int getLine();
+  String getScenarioName();
+}
diff --git a/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/IdeaTestSourceReadEvent.java b/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/IdeaTestSourceReadEvent.java
new file mode 100644 (file)
index 0000000..c323269
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+package org.jetbrains.plugins.cucumber.java.run;
+
+public class IdeaTestSourceReadEvent {
+  private final String myUri;
+
+  private final String mySource;
+
+  public IdeaTestSourceReadEvent(String uri, String source) {
+    myUri = uri;
+    mySource = source;
+  }
+
+  public String getUri() {
+    return myUri;
+  }
+
+  public String getSource() {
+    return mySource;
+  }
+}
diff --git a/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/IdeaTestStep.java b/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/IdeaTestStep.java
new file mode 100644 (file)
index 0000000..b6f5ad1
--- /dev/null
@@ -0,0 +1,7 @@
+// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+package org.jetbrains.plugins.cucumber.java.run;
+
+interface IdeaTestStep {
+  String getLocation();
+  String getStepName();
+}
diff --git a/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/IdeaTestStepFinishedEvent.java b/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/IdeaTestStepFinishedEvent.java
new file mode 100644 (file)
index 0000000..5bd4b6c
--- /dev/null
@@ -0,0 +1,10 @@
+// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+package org.jetbrains.plugins.cucumber.java.run;
+
+interface IdeaTestStepFinishedEvent {
+  enum Status {PASSED, PENDING, SKIPPED, FAILED, }
+  IdeaTestStep getTestStep();
+  Status getResult();
+  Long getDuration();
+  String getErrorMessage();
+}
diff --git a/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/IdeaWriteEvent.java b/plugins/cucumber-jvm-formatter/src/org/jetbrains/plugins/cucumber/java/run/IdeaWriteEvent.java
new file mode 100644 (file)
index 0000000..5f61ed2
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+package org.jetbrains.plugins.cucumber.java.run;
+
+public class IdeaWriteEvent {
+  private final String myText;
+
+  public IdeaWriteEvent(String text) {
+    myText = text;
+  }
+
+  public String getText() {
+    return myText;
+  }
+}
index c213e52b22c4f6be3bb8197f891a815a76546b66..4e257f3ee42ef34561db6e43d01472550e120d85 100644 (file)
@@ -14,52 +14,19 @@ import java.lang.reflect.Method;
 import static org.jetbrains.plugins.cucumber.java.run.CucumberJvmSMFormatterUtil.FILE_RESOURCE_PREFIX;
 
 public class CucumberJvm3Adapter {
-  public static class IdeaTestCaseEvent implements CucumberJvmAdapter.IdeaTestCaseEvent {
-    private final IdeaTestCase myTestCase;
-
-    public IdeaTestCaseEvent(TestCaseStarted testCaseStarted) {
-      myTestCase = new IdeaTestCase(testCaseStarted.testCase);
-    }
-
-    public IdeaTestCaseEvent(TestCaseFinished testCaseFinished) {
-      myTestCase = new IdeaTestCase(testCaseFinished.testCase);
-    }
-
-    @Override
-    public CucumberJvmAdapter.IdeaTestCase getTestCase() {
-      return myTestCase;
-    }
-
-    @Override
-    public String getUri() {
-      return myTestCase.getUri();
-    }
-  }
-
-  public static class IdeaTestStepEvent implements CucumberJvmAdapter.IdeaTestStepEvent {
+  public static class IdeaTestStepFinishedEvent implements org.jetbrains.plugins.cucumber.java.run.IdeaTestStepFinishedEvent {
     private final IdeaTestStep myTestStep;
+    private final TestStepFinished myRealEvent;
 
-    public IdeaTestStepEvent(TestStepStarted testStepStarted) {
-      this(testStepStarted.testStep);
-    }
-
-    public IdeaTestStepEvent(TestStep testStep) {
-      myTestStep = new IdeaTestStep(testStep);
+    public IdeaTestStepFinishedEvent(TestStepFinished testStepFinished) {
+      myTestStep = new IdeaTestStep(testStepFinished.testStep);
+      myRealEvent = testStepFinished;
     }
 
     @Override
-    public CucumberJvmAdapter.IdeaTestStep getTestStep() {
+    public org.jetbrains.plugins.cucumber.java.run.IdeaTestStep getTestStep() {
       return myTestStep;
     }
-  }
-
-  public static class IdeaTestStepFinishedEvent extends IdeaTestStepEvent implements CucumberJvmAdapter.IdeaTestStepFinishedEvent {
-    TestStepFinished myRealEvent;
-
-    public IdeaTestStepFinishedEvent(TestStepFinished testStepFinished) {
-      super(testStepFinished.testStep);
-      myRealEvent = testStepFinished;
-    }
 
     @Override
     public Status getResult() {
@@ -82,7 +49,7 @@ public class CucumberJvm3Adapter {
     }
   }
 
-  public static class IdeaTestCase implements CucumberJvmAdapter.IdeaTestCase {
+  public static class IdeaTestCase implements org.jetbrains.plugins.cucumber.java.run.IdeaTestCase {
     private final TestCase myRealTestCase;
 
     IdeaTestCase(TestCase realTestCase) {
@@ -120,7 +87,7 @@ public class CucumberJvm3Adapter {
     }
   }
 
-  public static class IdeaTestStep implements CucumberJvmAdapter.IdeaTestStep {
+  public static class IdeaTestStep implements org.jetbrains.plugins.cucumber.java.run.IdeaTestStep {
     private final TestStep myRealStep;
 
     public IdeaTestStep(TestStep realStep) {
index 9dddeb4adc00e302add1b7de9ace9b26704c6240..ebbf6543a32a6bb4b613615ccc52ca951fe7cf27 100644 (file)
@@ -12,14 +12,14 @@ public class CucumberJvm3SMFormatter extends CucumberJvmSMConverter implements F
   private final EventHandler<TestCaseStarted> testCaseStartedHandler = new EventHandler<TestCaseStarted>() {
     @Override
     public void receive(TestCaseStarted event) {
-      CucumberJvm3SMFormatter.this.handleTestCaseStarted(new CucumberJvm3Adapter.IdeaTestCaseEvent(event));
+      CucumberJvm3SMFormatter.this.handleTestCaseStarted(new CucumberJvm3Adapter.IdeaTestCase(event.testCase));
     }
   };
 
   private final EventHandler<TestCaseFinished> testCaseFinishedHandler = new EventHandler<TestCaseFinished>() {
     @Override
     public void receive(TestCaseFinished event) {
-      handleTestCaseFinished(new CucumberJvm3Adapter.IdeaTestCaseEvent(event));
+      handleTestCaseFinished(new CucumberJvm3Adapter.IdeaTestCase(event.testCase));
     }
   };
 
@@ -33,14 +33,14 @@ public class CucumberJvm3SMFormatter extends CucumberJvmSMConverter implements F
   private final EventHandler<WriteEvent> writeEventHandler = new EventHandler<WriteEvent>() {
     @Override
     public void receive(WriteEvent event) {
-      CucumberJvm3SMFormatter.this.handleWriteEvent(new CucumberJvmAdapter.IdeaWriteEvent(event.text));
+      CucumberJvm3SMFormatter.this.handleWriteEvent(new IdeaWriteEvent(event.text));
     }
   };
 
   private final EventHandler<TestStepStarted> testStepStartedHandler = new EventHandler<TestStepStarted>() {
     @Override
     public void receive(TestStepStarted event) {
-      handleTestStepStarted(new CucumberJvm3Adapter.IdeaTestStepEvent(event));
+      handleTestStepStarted(new CucumberJvm3Adapter.IdeaTestStep(event.testStep));
     }
   };
 
@@ -54,7 +54,7 @@ public class CucumberJvm3SMFormatter extends CucumberJvmSMConverter implements F
   private final EventHandler<TestSourceRead> testSourceReadHandler = new EventHandler<TestSourceRead>() {
     @Override
     public void receive(TestSourceRead event) {
-      CucumberJvm3SMFormatter.this.handleTestSourceRead(new CucumberJvmAdapter.IdeaTestSourceReadEvent(event.uri, event.source));
+      CucumberJvm3SMFormatter.this.handleTestSourceRead(new IdeaTestSourceReadEvent(event.uri, event.source));
     }
   };
 
index b84b3a83a348a607bf0cf09026ba6857db5b0020..f047f9b2b7288aaf226a3a9d5b9065b861b6e7a2 100644 (file)
@@ -10,52 +10,19 @@ import java.lang.reflect.Method;
 import static org.jetbrains.plugins.cucumber.java.run.CucumberJvmSMFormatterUtil.FILE_RESOURCE_PREFIX;
 
 public class CucumberJvm5Adapter {
-  public static class IdeaTestCaseEvent implements CucumberJvmAdapter.IdeaTestCaseEvent {
-    private final IdeaTestCase myTestCase;
-
-    public IdeaTestCaseEvent(TestCaseStarted testCaseStarted) {
-      myTestCase = new IdeaTestCase(testCaseStarted.getTestCase());
-    }
-
-    public IdeaTestCaseEvent(TestCaseFinished testCaseFinished) {
-      myTestCase = new IdeaTestCase(testCaseFinished.getTestCase());
-    }
-
-    @Override
-    public CucumberJvmAdapter.IdeaTestCase getTestCase() {
-      return myTestCase;
-    }
-
-    @Override
-    public String getUri() {
-      return myTestCase.getUri();
-    }
-  }
-
-  public static class IdeaTestStepEvent implements CucumberJvmAdapter.IdeaTestStepEvent {
+  public static class IdeaTestStepFinishedEvent implements org.jetbrains.plugins.cucumber.java.run.IdeaTestStepFinishedEvent {
     private final IdeaTestStep myTestStep;
+    private final TestStepFinished myRealEvent;
 
-    public IdeaTestStepEvent(TestStepStarted testStepStarted) {
-      this(testStepStarted.getTestStep());
-    }
-
-    public IdeaTestStepEvent(TestStep testStep) {
-      myTestStep = new IdeaTestStep(testStep);
+    public IdeaTestStepFinishedEvent(TestStepFinished testStepFinished) {
+      myTestStep = new IdeaTestStep(testStepFinished.getTestStep());
+      myRealEvent = testStepFinished;
     }
 
     @Override
-    public CucumberJvmAdapter.IdeaTestStep getTestStep() {
+    public org.jetbrains.plugins.cucumber.java.run.IdeaTestStep getTestStep() {
       return myTestStep;
     }
-  }
-
-  public static class IdeaTestStepFinishedEvent extends IdeaTestStepEvent implements CucumberJvmAdapter.IdeaTestStepFinishedEvent {
-    TestStepFinished myRealEvent;
-
-    public IdeaTestStepFinishedEvent(TestStepFinished testStepFinished) {
-      super(testStepFinished.getTestStep());
-      myRealEvent = testStepFinished;
-    }
 
     @Override
     public Status getResult() {
@@ -80,7 +47,7 @@ public class CucumberJvm5Adapter {
     }
   }
 
-  public static class IdeaTestCase implements CucumberJvmAdapter.IdeaTestCase {
+  public static class IdeaTestCase implements org.jetbrains.plugins.cucumber.java.run.IdeaTestCase {
     private final TestCase myRealTestCase;
 
     IdeaTestCase(TestCase realTestCase) {
@@ -118,7 +85,7 @@ public class CucumberJvm5Adapter {
     }
   }
 
-  public static class IdeaTestStep implements CucumberJvmAdapter.IdeaTestStep {
+  public static class IdeaTestStep implements org.jetbrains.plugins.cucumber.java.run.IdeaTestStep {
     private final TestStep myRealStep;
 
     public IdeaTestStep(TestStep realStep) {
index 7afb6d290d38920fc71c5ff716fcd1722171cd27..6c9a0eaf721e92dc71223bfbd191130733659ae3 100644 (file)
@@ -20,14 +20,14 @@ public class CucumberJvm5SMFormatter extends CucumberJvmSMConverter implements C
   private final EventHandler<TestCaseStarted> testCaseStartedHandler = new EventHandler<TestCaseStarted>() {
     @Override
     public void receive(TestCaseStarted event) {
-      CucumberJvm5SMFormatter.this.handleTestCaseStarted(new CucumberJvm5Adapter.IdeaTestCaseEvent(event));
+      CucumberJvm5SMFormatter.this.handleTestCaseStarted(new CucumberJvm5Adapter.IdeaTestCase(event.getTestCase()));
     }
   };
 
   private final EventHandler<TestCaseFinished> testCaseFinishedHandler = new EventHandler<TestCaseFinished>() {
     @Override
     public void receive(TestCaseFinished event) {
-      handleTestCaseFinished(new CucumberJvm5Adapter.IdeaTestCaseEvent(event));
+      handleTestCaseFinished(new CucumberJvm5Adapter.IdeaTestCase(event.getTestCase()));
     }
   };
 
@@ -41,14 +41,14 @@ public class CucumberJvm5SMFormatter extends CucumberJvmSMConverter implements C
   private final EventHandler<WriteEvent> writeEventHandler = new EventHandler<WriteEvent>() {
     @Override
     public void receive(WriteEvent event) {
-      CucumberJvm5SMFormatter.this.handleWriteEvent(new CucumberJvmAdapter.IdeaWriteEvent(event.getText()));
+      CucumberJvm5SMFormatter.this.handleWriteEvent(new IdeaWriteEvent(event.getText()));
     }
   };
 
   private final EventHandler<TestStepStarted> testStepStartedHandler = new EventHandler<TestStepStarted>() {
     @Override
     public void receive(TestStepStarted event) {
-      handleTestStepStarted(new CucumberJvm5Adapter.IdeaTestStepEvent(event));
+      handleTestStepStarted(new CucumberJvm5Adapter.IdeaTestStep(event.getTestStep()));
     }
   };
 
@@ -63,7 +63,7 @@ public class CucumberJvm5SMFormatter extends CucumberJvmSMConverter implements C
     @Override
     public void receive(TestSourceRead event) {
       CucumberJvm5SMFormatter.this
-        .handleTestSourceRead(new CucumberJvmAdapter.IdeaTestSourceReadEvent(event.getUri().getPath(), event.getSource()));
+        .handleTestSourceRead(new IdeaTestSourceReadEvent(event.getUri().getPath(), event.getSource()));
     }
   };