Skip to content

Commit

Permalink
fix org.jetbrains.research.testspark package
Browse files Browse the repository at this point in the history
  • Loading branch information
arksap2002 committed Aug 14, 2023
1 parent 13f7a6b commit 8bba0d4
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import com.intellij.openapi.ui.ComboBox
import com.intellij.ui.components.JBLabel
import com.intellij.util.ui.FormBuilder
import org.jdesktop.swingx.JXTitledSeparator
import org.jetbrains.research.testspark.TestSparkLabelsBundle
import org.jetbrains.research.testspark.TestSparkToolTipsBundle
import javax.swing.JCheckBox
import javax.swing.JComponent
import javax.swing.JPanel
Expand All @@ -21,24 +23,24 @@ class SettingsEvoSuiteComponent {
private var seedTextField = JTextField()

// EvoSuite checkboxes options
private var sandboxCheckBox = JCheckBox(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("sandbox"))
private var assertionsCheckBox = JCheckBox(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("assertionCreation"))
private var clientOnThreadCheckBox = JCheckBox(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("debug"))
private var junitCheckCheckBox = JCheckBox(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("junitCheck"))
private var minimizeCheckBox = JCheckBox(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("minimize"))
private var sandboxCheckBox = JCheckBox(TestSparkLabelsBundle.defaultValue("sandbox"))
private var assertionsCheckBox = JCheckBox(TestSparkLabelsBundle.defaultValue("assertionCreation"))
private var clientOnThreadCheckBox = JCheckBox(TestSparkLabelsBundle.defaultValue("debug"))
private var junitCheckCheckBox = JCheckBox(TestSparkLabelsBundle.defaultValue("junitCheck"))
private var minimizeCheckBox = JCheckBox(TestSparkLabelsBundle.defaultValue("minimize"))

// Criterion selection checkboxes
// There is a limited amount of criteria, but multiple can be selected at once.
// Effectively, this requires its own section (or a checkboxed combobox of sorts)
private var criterionSeparator = JXTitledSeparator(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("criterionSeparator"))
private var criterionLineCheckBox = JCheckBox(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("criterionLine"))
private var criterionBranchCheckBox = JCheckBox(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("criterionBranch"))
private var criterionExceptionCheckBox = JCheckBox(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("criterionException"))
private var criterionWeakMutationCheckBox = JCheckBox(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("criterionWeakMutation"))
private var criterionOutputCheckBox = JCheckBox(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("criterionOutput"))
private var criterionMethodCheckBox = JCheckBox(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("criterionMethod"))
private var criterionMethodNoExceptionCheckBox = JCheckBox(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("criterionMethodNoExc"))
private var criterionCBranchCheckBox = JCheckBox(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("criterionCBranch"))
private var criterionSeparator = JXTitledSeparator(TestSparkLabelsBundle.defaultValue("criterionSeparator"))
private var criterionLineCheckBox = JCheckBox(TestSparkLabelsBundle.defaultValue("criterionLine"))
private var criterionBranchCheckBox = JCheckBox(TestSparkLabelsBundle.defaultValue("criterionBranch"))
private var criterionExceptionCheckBox = JCheckBox(TestSparkLabelsBundle.defaultValue("criterionException"))
private var criterionWeakMutationCheckBox = JCheckBox(TestSparkLabelsBundle.defaultValue("criterionWeakMutation"))
private var criterionOutputCheckBox = JCheckBox(TestSparkLabelsBundle.defaultValue("criterionOutput"))
private var criterionMethodCheckBox = JCheckBox(TestSparkLabelsBundle.defaultValue("criterionMethod"))
private var criterionMethodNoExceptionCheckBox = JCheckBox(TestSparkLabelsBundle.defaultValue("criterionMethodNoExc"))
private var criterionCBranchCheckBox = JCheckBox(TestSparkLabelsBundle.defaultValue("criterionCBranch"))

// Java path
private var javaPathTextField = JTextField()
Expand All @@ -57,14 +59,14 @@ class SettingsEvoSuiteComponent {
*/
private fun createSettingsPanel() {
panel = FormBuilder.createFormBuilder()
.addComponent(JXTitledSeparator(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("javaSettings")))
.addLabeledComponent(JBLabel(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("javaPath")), javaPathTextField, 10, false)
.addComponent(JXTitledSeparator(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("generalSettings")))
.addComponent(JXTitledSeparator(TestSparkLabelsBundle.defaultValue("javaSettings")))
.addLabeledComponent(JBLabel(TestSparkLabelsBundle.defaultValue("javaPath")), javaPathTextField, 10, false)
.addComponent(JXTitledSeparator(TestSparkLabelsBundle.defaultValue("generalSettings")))
// EvoSuite "input" options (e.g. text, number)
// Important settings like algorithm selection, seed selection
.addLabeledComponent(JBLabel(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("defaultSearch")), algorithmSelector, 10, false)
.addLabeledComponent(JBLabel(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("seed")), seedTextField, 10, false)
.addLabeledComponent(JBLabel(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("configId")), configurationIdTextField, 5, false)
.addLabeledComponent(JBLabel(TestSparkLabelsBundle.defaultValue("defaultSearch")), algorithmSelector, 10, false)
.addLabeledComponent(JBLabel(TestSparkLabelsBundle.defaultValue("seed")), seedTextField, 10, false)
.addLabeledComponent(JBLabel(TestSparkLabelsBundle.defaultValue("configId")), configurationIdTextField, 5, false)
// Checkboxes settings
.addComponent(sandboxCheckBox, 10)
.addComponent(assertionsCheckBox, 10)
Expand Down Expand Up @@ -93,13 +95,13 @@ class SettingsEvoSuiteComponent {
algorithmSelector.setMinimumAndPreferredWidth(300)

// Tooltips
seedTextField.toolTipText = org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("seed")
configurationIdTextField.toolTipText = org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("configId")
clientOnThreadCheckBox.toolTipText = org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("debug")
junitCheckCheckBox.toolTipText = org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("junit")
criterionSeparator.toolTipText = org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("criterion")
seedTextField.toolTipText = TestSparkToolTipsBundle.defaultValue("seed")
configurationIdTextField.toolTipText = TestSparkToolTipsBundle.defaultValue("configId")
clientOnThreadCheckBox.toolTipText = TestSparkToolTipsBundle.defaultValue("debug")
junitCheckCheckBox.toolTipText = TestSparkToolTipsBundle.defaultValue("junit")
criterionSeparator.toolTipText = TestSparkToolTipsBundle.defaultValue("criterion")

javaPathTextField.toolTipText = org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("javaPath")
javaPathTextField.toolTipText = TestSparkToolTipsBundle.defaultValue("javaPath")
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import com.intellij.ui.components.JBLabel
import com.intellij.util.io.HttpRequests
import com.intellij.util.ui.FormBuilder
import org.jdesktop.swingx.JXTitledSeparator
import org.jetbrains.research.testspark.TestSparkLabelsBundle
import org.jetbrains.research.testspark.TestSparkToolTipsBundle
import java.net.HttpURLConnection
import javax.swing.DefaultComboBoxModel
import javax.swing.JPanel
Expand Down Expand Up @@ -128,46 +130,46 @@ class SettingsLLMComponent {
}

private fun stylizePanel() {
llmUserTokenField.toolTipText = org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("llmToken")
maxLLMRequestsField.toolTipText = org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("maximumNumberOfRequests")
modelSelector.toolTipText = org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("model")
llmUserTokenField.toolTipText = TestSparkToolTipsBundle.defaultValue("llmToken")
maxLLMRequestsField.toolTipText = TestSparkToolTipsBundle.defaultValue("maximumNumberOfRequests")
modelSelector.toolTipText = TestSparkToolTipsBundle.defaultValue("model")
modelSelector.isEnabled = false
maxInputParamsDepthField.toolTipText = org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("parametersDepth")
maxPolyDepthField.toolTipText = org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("maximumPolyDepth")
maxInputParamsDepthField.toolTipText = TestSparkToolTipsBundle.defaultValue("parametersDepth")
maxPolyDepthField.toolTipText = TestSparkToolTipsBundle.defaultValue("maximumPolyDepth")
}

/**
* Create the main panel for LLM-related settings page
*/
private fun createSettingsPanel() {
panel = FormBuilder.createFormBuilder()
.addComponent(JXTitledSeparator(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("LLMSettings")))
.addComponent(JXTitledSeparator(TestSparkLabelsBundle.defaultValue("LLMSettings")))
.addLabeledComponent(
JBLabel(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("llmToken")),
JBLabel(TestSparkLabelsBundle.defaultValue("llmToken")),
llmUserTokenField,
10,
false,
)
.addLabeledComponent(
JBLabel(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("model")),
JBLabel(TestSparkLabelsBundle.defaultValue("model")),
modelSelector,
10,
false,
)
.addLabeledComponent(
JBLabel(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("parametersDepth")),
JBLabel(TestSparkLabelsBundle.defaultValue("parametersDepth")),
maxInputParamsDepthField,
10,
false,
)
.addLabeledComponent(
JBLabel(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("maximumPolyDepth")),
JBLabel(TestSparkLabelsBundle.defaultValue("maximumPolyDepth")),
maxPolyDepthField,
10,
false,
)
.addLabeledComponent(
JBLabel(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("maximumNumberOfRequests")),
JBLabel(TestSparkLabelsBundle.defaultValue("maximumNumberOfRequests")),
maxLLMRequestsField,
10,
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import com.intellij.ui.JBColor
import com.intellij.ui.components.JBLabel
import com.intellij.util.ui.FormBuilder
import org.jdesktop.swingx.JXTitledSeparator
import org.jetbrains.research.testspark.TestSparkLabelsBundle
import org.jetbrains.research.testspark.TestSparkToolTipsBundle
import org.jetbrains.research.testspark.services.SettingsProjectService
import java.awt.Color
import java.awt.Dimension
Expand Down Expand Up @@ -51,15 +53,15 @@ class SettingsPluginComponent(project: Project) {
"information about your usage patterns, such as the tests you generate and the way you " +
"modify them manually before applying them to a test suite.",
)
private val telemetrySeparator = JXTitledSeparator(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("telemetry"))
private var telemetryEnabledCheckbox = JCheckBox(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("telemetryEnabled"))
private val telemetrySeparator = JXTitledSeparator(TestSparkLabelsBundle.defaultValue("telemetry"))
private var telemetryEnabledCheckbox = JCheckBox(TestSparkLabelsBundle.defaultValue("telemetryEnabled"))
private val fileChooserDescriptor = FileChooserDescriptor(false, true, false, false, false, false)
private val textBrowseFolderListener = TextBrowseFolderListener(fileChooserDescriptor)
private val telemetryPathChooser = TextFieldWithBrowseButton()
private val telemetryPathLabel = JBLabel(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("telemetryPath"))
private val telemetryPathLabel = JBLabel(TestSparkLabelsBundle.defaultValue("telemetryPath"))

// Accessibility options
private val accessibilitySeparator = JXTitledSeparator(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("accessibility"))
private val accessibilitySeparator = JXTitledSeparator(TestSparkLabelsBundle.defaultValue("accessibility"))
private var colorPicker = JColorChooser()

init {
Expand Down Expand Up @@ -93,20 +95,20 @@ class SettingsPluginComponent(project: Project) {
// Add description of TestSpark
.addComponent(pluginDescription)
.addComponent(pluginDescriptionDisclaimer, 15)
.addComponent(JXTitledSeparator(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("environmentSettings")), 15)
.addComponent(JXTitledSeparator(TestSparkLabelsBundle.defaultValue("environmentSettings")), 15)
// .addLabeledComponent(JBLabel(TestSparkLabelsBundle.defaultValue("javaPath")), javaPathTextField, 10, false)
// Add buildPath option
.addLabeledComponent(JBLabel(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("buildPath")), buildPathTextField, 10, false)
.addLabeledComponent(JBLabel(TestSparkLabelsBundle.defaultValue("buildPath")), buildPathTextField, 10, false)
// Add buildPath option
.addLabeledComponent(JBLabel(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("buildCommand")), buildCommandTextField, 10, false)
.addLabeledComponent(JBLabel(TestSparkLabelsBundle.defaultValue("buildCommand")), buildCommandTextField, 10, false)
// Add telemetry options
.addComponent(telemetrySeparator, 15)
.addComponent(telemetryDescription, 10)
.addComponent(telemetryEnabledCheckbox, 10)
.addLabeledComponent(telemetryPathLabel, telemetryPathChooser, 10, false)
// Add accessibility options
.addComponent(accessibilitySeparator, 15)
.addComponent(JBLabel(org.jetbrains.research.testspark.TestSparkLabelsBundle.defaultValue("colorPicker")), 15)
.addComponent(JBLabel(TestSparkLabelsBundle.defaultValue("colorPicker")), 15)
.addComponent(colorPicker, 10)
.addComponentFillVertically(JPanel(), 0)
.panel
Expand All @@ -118,16 +120,16 @@ class SettingsPluginComponent(project: Project) {
*/
private fun stylizePanel() {
// Add description to build Path
buildPathTextField.toolTipText = org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("buildPath")
buildPathTextField.toolTipText = TestSparkToolTipsBundle.defaultValue("buildPath")

// Add description to build Command
buildCommandTextField.toolTipText = org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("buildCommand")
buildCommandTextField.toolTipText = TestSparkToolTipsBundle.defaultValue("buildCommand")

// Add description to telemetry
telemetryEnabledCheckbox.toolTipText = org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("telemetryEnabled")
telemetryEnabledCheckbox.toolTipText = TestSparkToolTipsBundle.defaultValue("telemetryEnabled")

// Add description to telemetry path
telemetryPathLabel.toolTipText = org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("telemetryPath")
telemetryPathLabel.toolTipText = TestSparkToolTipsBundle.defaultValue("telemetryPath")

// Get dimensions of visible rectangle
val width = panel?.visibleRect?.width
Expand Down Expand Up @@ -194,17 +196,17 @@ class SettingsPluginComponent(project: Project) {
var colorRed: Int
get() = colorPicker.color.red
set(newStatus) {
colorPicker.color = JBColor(org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("colorName"), Color(newStatus, colorPicker.color.green, colorPicker.color.blue))
colorPicker.color = JBColor(TestSparkToolTipsBundle.defaultValue("colorName"), Color(newStatus, colorPicker.color.green, colorPicker.color.blue))
}

var colorGreen: Int
get() = colorPicker.color.green
set(newStatus) {
colorPicker.color = JBColor(org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("colorName"), Color(colorPicker.color.red, newStatus, colorPicker.color.blue))
colorPicker.color = JBColor(TestSparkToolTipsBundle.defaultValue("colorName"), Color(colorPicker.color.red, newStatus, colorPicker.color.blue))
}
var colorBlue: Int
get() = colorPicker.color.blue
set(newStatus) {
colorPicker.color = JBColor(org.jetbrains.research.testspark.TestSparkToolTipsBundle.defaultValue("colorName"), Color(colorPicker.color.red, colorPicker.color.green, newStatus))
colorPicker.color = JBColor(TestSparkToolTipsBundle.defaultValue("colorName"), Color(colorPicker.color.red, colorPicker.color.green, newStatus))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import com.intellij.openapi.roots.ProjectRootManager
import com.intellij.openapi.util.io.FileUtilRt
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiFile
import org.jetbrains.research.testspark.TestSparkBundle
import org.jetbrains.research.testspark.Util
import org.jetbrains.research.testspark.actions.getSurroundingClass
import org.jetbrains.research.testspark.data.FragmentToTestDada
import org.jetbrains.research.testspark.editor.Workspace
import org.jetbrains.research.testspark.tools.template.generation.ProcessManager
Expand Down Expand Up @@ -50,14 +53,14 @@ class Pipeline(

private val psiFile: PsiFile = e.dataContext.getData(CommonDataKeys.PSI_FILE)!!
private val caret: Caret = e.dataContext.getData(CommonDataKeys.CARET)?.caretModel?.primaryCaret!!
private val cutPsiClass: PsiClass = org.jetbrains.research.testspark.actions.getSurroundingClass(psiFile, caret)
private val cutPsiClass: PsiClass = getSurroundingClass(psiFile, caret)
private val cutModule: Module = ProjectFileIndex.getInstance(project).getModuleForFile(cutPsiClass.containingFile.virtualFile)!!

private val classFQN = cutPsiClass.qualifiedName!!

init {
org.jetbrains.research.testspark.Util.makeTmp()
org.jetbrains.research.testspark.Util.makeDir(baseDir)
Util.makeTmp()
Util.makeDir(baseDir)

project.service<Workspace>().key = getKey(fileUrl, classFQN, modificationStamp, testResultName, projectClassPath)
}
Expand All @@ -71,7 +74,7 @@ class Pipeline(
val projectBuilder = ProjectBuilder(project)

ProgressManager.getInstance()
.run(object : Task.Backgroundable(project, org.jetbrains.research.testspark.TestSparkBundle.message("testGenerationMessage")) {
.run(object : Task.Backgroundable(project, TestSparkBundle.message("testGenerationMessage")) {
override fun run(indicator: ProgressIndicator) {
if (processStopped(project, indicator)) return

Expand Down
Loading

0 comments on commit 8bba0d4

Please sign in to comment.