From 08e49b16447f1910d578925a7bdfeb7311468da3 Mon Sep 17 00:00:00 2001 From: Nikita Skvortsov Date: Mon, 12 Nov 2018 15:19:32 +0300 Subject: [PATCH] Fix default run configuration name IDEA-202077 --- ...ctExternalSystemTaskConfigurationType.java | 7 ++- ...ExternalSystemTaskConfigurationTypeTest.kt | 48 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationTypeTest.kt diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationType.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationType.java index dcfe18ac8a10..48e486cb0019 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationType.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationType.java @@ -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(); } } diff --git a/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationTypeTest.kt b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationTypeTest.kt new file mode 100644 index 000000000000..069fd4b92de2 --- /dev/null +++ b/platform/external-system-impl/testSrc/com/intellij/openapi/externalSystem/service/execution/AbstractExternalSystemTaskConfigurationTypeTest.kt @@ -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) + ) + } +} \ No newline at end of file