Fix default run configuration name IDEA-202077

This commit is contained in:
Nikita Skvortsov
2018-11-12 15:21:35 +03:00
parent bfad94e237
commit 08e49b1644
2 changed files with 54 additions and 1 deletions
@@ -1,6 +1,7 @@
// Copyright 2000-2018 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 com.intellij.openapi.externalSystem.service.execution;
import com.intellij.execution.ExecutionBundle;
import com.intellij.execution.configurations.ConfigurationFactory;
import com.intellij.execution.configurations.ConfigurationType;
import com.intellij.execution.configurations.RunConfiguration;
@@ -143,7 +144,8 @@ public abstract class AbstractExternalSystemTaskConfigurationType implements Con
}
if (!StringUtil.isEmptyOrSpaces(projectName)) {
buffer.append(projectName);
} else {
}
else if (!StringUtil.isEmptyOrSpaces(externalProjectPath)) {
buffer.append(externalProjectPath);
}
@@ -161,6 +163,9 @@ public abstract class AbstractExternalSystemTaskConfigurationType implements Con
}
if (!isTasksAbsent) buffer.append(tasksPostfix);
if (buffer.length() == 0) {
buffer.append(ExecutionBundle.message("run.configuration.unnamed.name.prefix"));
}
return buffer.toString();
}
}
@@ -0,0 +1,48 @@
// Copyright 2000-2018 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 com.intellij.openapi.externalSystem.service.execution
import com.intellij.execution.ExecutionBundle
import com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings
import com.intellij.openapi.project.Project
import com.intellij.testFramework.UsefulTestCase
import com.intellij.testFramework.fixtures.IdeaProjectTestFixture
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
import junit.framework.TestCase
import org.junit.After
import org.junit.Before
import org.junit.Test
class AbstractExternalSystemTaskConfigurationTypeTest : UsefulTestCase() {
private lateinit var myTestFixture: IdeaProjectTestFixture
private lateinit var myProject: Project
@Before
override fun setUp() {
super.setUp()
myTestFixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(name).fixture
myTestFixture.setUp()
myProject = myTestFixture.project
}
@After
override fun tearDown() {
try {
myTestFixture.tearDown()
}
finally {
super.tearDown()
}
}
@Test
fun `test correct name generated for empty task exec settings`() {
val testSettings = ExternalSystemTaskExecutionSettings().apply {
externalSystemIdString = "Test"
}
TestCase.assertEquals(ExecutionBundle.message("run.configuration.unnamed.name.prefix"),
AbstractExternalSystemTaskConfigurationType.generateName(myProject,
testSettings)
)
}
}