Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add return type to applyTests function #333

Merged
merged 4 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ class GeneratedTestsTabBuilder(
.map { generatedTestsTabData.testCaseNameToEditorTextField[it]!! }
.map { it.document.text }

displayUtils!!.applyTests(project, uiContext, testCaseComponents)
val applyingResult = displayUtils!!.applyTests(project, uiContext, testCaseComponents)

// Remove the selected test cases from the cache and the tool window UI
clear()
if (applyingResult) clear()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import java.util.Locale
import javax.swing.JOptionPane

class JavaDisplayUtils : DisplayUtils {
override fun applyTests(project: Project, uiContext: UIContext?, testCaseComponents: List<String>) {
override fun applyTests(project: Project, uiContext: UIContext?, testCaseComponents: List<String>): Boolean {
// Descriptor for choosing folders and java files
val descriptor = FileChooserDescriptor(true, true, false, false, false, false)

Expand Down Expand Up @@ -61,7 +61,7 @@ class JavaDisplayUtils : DisplayUtils {
/**
* Cancel button pressed
*/
if (fileChooser.isEmpty()) return
if (fileChooser.isEmpty()) return false

/**
* Chosen files by user
Expand Down Expand Up @@ -102,7 +102,7 @@ class JavaDisplayUtils : DisplayUtils {
)

// Cancel button pressed
jOptionPane ?: return
jOptionPane ?: return false

// Get class name from user
className = jOptionPane as String
Expand Down Expand Up @@ -158,6 +158,8 @@ class JavaDisplayUtils : DisplayUtils {
OpenFileDescriptor(project, virtualFile!!),
true,
)

return true
}

override fun appendTestsToClass(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import java.util.Locale
import javax.swing.JOptionPane

class KotlinDisplayUtils : DisplayUtils {
override fun applyTests(project: Project, uiContext: UIContext?, testCaseComponents: List<String>) {
override fun applyTests(project: Project, uiContext: UIContext?, testCaseComponents: List<String>): Boolean {
val descriptor = FileChooserDescriptor(true, true, false, false, false, false)

// Apply filter with folders and java files with main class
Expand Down Expand Up @@ -62,7 +62,7 @@ class KotlinDisplayUtils : DisplayUtils {
/**
* Cancel button pressed
*/
if (fileChooser.isEmpty()) return
if (fileChooser.isEmpty()) return false

/**
* Chosen files by user
Expand Down Expand Up @@ -103,7 +103,7 @@ class KotlinDisplayUtils : DisplayUtils {
)

// Cancel button pressed
jOptionPane ?: return
jOptionPane ?: return false

// Get class name from user
className = jOptionPane as String
Expand Down Expand Up @@ -167,6 +167,8 @@ class KotlinDisplayUtils : DisplayUtils {
OpenFileDescriptor(project, virtualFile!!),
true,
)

return true
}

override fun appendTestsToClass(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface DisplayUtils {
/**
* Applies specified tests to a given project.
*/
fun applyTests(project: Project, uiContext: UIContext?, testCaseComponents: List<String>)
fun applyTests(project: Project, uiContext: UIContext?, testCaseComponents: List<String>): Boolean
arksap2002 marked this conversation as resolved.
Show resolved Hide resolved

/**
* Appends specified tests to a class within the given project.
Expand Down
Loading