use of com.google.idea.blaze.base.dependencies.TestSize in project intellij by bazelbuild.
the class BlazeJavaTestMethodConfigurationProducer method getSelectedMethodContext.
@Nullable
private static TestMethodContext getSelectedMethodContext(ConfigurationContext context) {
if (!SmRunnerUtils.getSelectedSmRunnerTreeElements(context).isEmpty()) {
// handled by a different producer
return null;
}
final List<PsiMethod> selectedMethods = TestMethodSelectionUtil.getSelectedMethods(context);
if (selectedMethods == null) {
return null;
}
assert selectedMethods.size() > 0;
final PsiMethod firstMethod = selectedMethods.get(0);
final PsiClass containingClass = firstMethod.getContainingClass();
if (containingClass == null) {
return null;
}
for (PsiMethod method : selectedMethods) {
if (!containingClass.equals(method.getContainingClass())) {
return null;
}
}
TestSize testSize = TestSizeAnnotationMap.getTestSize(firstMethod);
TargetInfo target = RunUtil.targetForTestClass(containingClass, testSize);
if (target == null) {
return null;
}
String testFilter = BlazeJUnitTestFilterFlags.testFilterForClassAndMethods(containingClass, selectedMethods);
if (testFilter == null) {
return null;
}
// Sort so multiple configurations created with different selection orders are the same.
List<String> methodNames = selectedMethods.stream().map(PsiMethod::getName).sorted().collect(Collectors.toList());
final String testFilterFlag = BlazeFlags.TEST_FILTER + "=" + testFilter;
return new TestMethodContext(firstMethod, containingClass, methodNames, testFilterFlag, target);
}
use of com.google.idea.blaze.base.dependencies.TestSize in project intellij by bazelbuild.
the class TestSizeAnnotationMap method getTestSize.
@Nullable
public static TestSize getTestSize(PsiClass psiClass) {
PsiModifierList psiModifierList = psiClass.getModifierList();
if (psiModifierList == null) {
return null;
}
PsiAnnotation[] annotations = psiModifierList.getAnnotations();
TestSize testSize = getTestSize(annotations);
if (testSize == null) {
return null;
}
return testSize;
}
use of com.google.idea.blaze.base.dependencies.TestSize in project intellij by bazelbuild.
the class TestSizeAnnotationMap method getTestSize.
@Nullable
public static TestSize getTestSize(PsiMethod psiMethod) {
PsiAnnotation[] annotations = psiMethod.getModifierList().getAnnotations();
TestSize testSize = getTestSize(annotations);
if (testSize != null) {
return testSize;
}
return getTestSize(psiMethod.getContainingClass());
}
use of com.google.idea.blaze.base.dependencies.TestSize in project intellij by bazelbuild.
the class IdeInfoFromProtobuf method makeTestIdeInfo.
private static TestIdeInfo makeTestIdeInfo(IntellijIdeInfo.TestInfo testInfo) {
String size = testInfo.getSize();
TestSize testSize = TestSize.DEFAULT_RULE_TEST_SIZE;
if (!Strings.isNullOrEmpty(size)) {
switch(size) {
case "small":
testSize = TestSize.SMALL;
break;
case "medium":
testSize = TestSize.MEDIUM;
break;
case "large":
testSize = TestSize.LARGE;
break;
case "enormous":
testSize = TestSize.ENORMOUS;
break;
default:
break;
}
}
return new TestIdeInfo(testSize);
}
Aggregations