/*
 * Copyright 2000-2015 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.execution.junit;

import com.intellij.openapi.projectRoots.ex.JavaSdkUtil;
import com.intellij.openapi.roots.ExternalLibraryDescriptor;
import org.jetbrains.annotations.NotNull;

import java.util.Collections;
import java.util.List;

/**
 * @author nik
 */
public abstract class JUnitExternalLibraryDescriptor extends ExternalLibraryDescriptor {
  public static final ExternalLibraryDescriptor JUNIT3 = new JUnitExternalLibraryDescriptor("3") {
    @NotNull
    @Override
    public List<String> getLibraryClassesRoots() {
      return Collections.singletonList(JavaSdkUtil.getJunit3JarPath());
    }
  };
  public static final ExternalLibraryDescriptor JUNIT4 = new JUnitExternalLibraryDescriptor("4") {
    @NotNull
    @Override
    public List<String> getLibraryClassesRoots() {
      return JavaSdkUtil.getJUnit4JarPaths();
    }
  };
  public static final ExternalLibraryDescriptor JUNIT5 = new JUnitExternalLibraryDescriptor("org.junit.jupiter", "junit-jupiter-api", "5.2") {
    @NotNull
    @Override
    public List<String> getLibraryClassesRoots() {
      return Collections.emptyList();
    }
  };
  private final String myVersion;

  private JUnitExternalLibraryDescriptor(String version) {
    this("junit", "junit", version);
  }

  private JUnitExternalLibraryDescriptor(final String groupId, final String artifactId, final String version) {
    super(groupId, artifactId, version + ".0", version + ".999");
    myVersion = version;
  }

  @Override
  public String getPresentableName() {
    return "JUnit" + myVersion;
  }
}

@@ -665,192 +665,39 @@
 api.
-projectRoots.ex.JavaSdkUtil;%0Aimport com.intellij.openapi.roots.ExternalLibraryDescriptor;%0Aimport org.jetbrains.annotations.NotNull;%0A%0Aimport java.util.Collections;%0Aimport java.util.List
+roots.ExternalLibraryDescriptor
 ;%0A%0A/
@@ -729,17 +729,8 @@
 lic 
-abstract 
 clas
@@ -897,405 +897,124 @@
 (%223%22
-) %7B%0A    @NotNull%0A    @Override%0A    public List%3CString%3E getLibraryClassesRoots() %7B%0A      return Collections.singletonList(JavaSdkUtil.getJunit3JarPath());%0A    %7D%0A  %7D;%0A  public static final ExternalLibraryDescriptor JUNIT4 = new JUnitExternalLibraryDescriptor(%224%22) %7B%0A    @NotNull%0A    @Override%0A    public List%3CString%3E getLibraryClassesRoots() %7B%0A      return JavaSdkUtil.getJUnit4JarPaths();%0A    %7D%0A  %7D
+, %223.8.2%22);%0A  public static final ExternalLibraryDescriptor JUNIT4 = new JUnitExternalLibraryDescriptor(%224%22, %224.12%22)
 ;%0A  
@@ -1154,137 +1154,107 @@
 5.2%22
-) %7B%0A    @NotNull%0A    @Override%0A    public List%3CString%3E getLibraryClassesRoots() %7B%0A      return Collections.emptyList();%0A    %7D%0A  %7D
+,%0A                                                                                            null)
 ;%0A  
@@ -1330,25 +1330,54 @@
 ptor(String 
-v
+baseVersion, String preferredV
 ersion) %7B%0A  
@@ -1401,17 +1401,39 @@
 junit%22, 
-v
+baseVersion, preferredV
 ersion);
@@ -1504,48 +1504,196 @@
 pId,
- final String artifactId, final String v
+%0A                                         final String artifactId,%0A                                         final String version,%0A                                         String preferredV
 ersi
@@ -1761,16 +1761,34 @@
 + %22.999%22
+, preferredVersion
 );%0A    m

use repository library when adding junit library via quickfix