@@ -7,7 +7,6 @@ import com.intellij.openapi.application.ApplicationManager
77import com.intellij.testFramework.ApplicationRule
88import com.intellij.testFramework.DisposableRule
99import com.intellij.testFramework.ProjectRule
10- import com.intellij.testFramework.registerServiceInstance
1110import com.intellij.testFramework.replaceService
1211import com.intellij.util.xmlb.XmlSerializer
1312import org.assertj.core.api.Assertions.assertThat
@@ -41,8 +40,6 @@ import software.aws.toolkits.jetbrains.core.credentials.sono.isSono
4140import software.aws.toolkits.jetbrains.core.region.MockRegionProviderRule
4241import software.aws.toolkits.jetbrains.services.amazonq.CodeWhispererFeatureConfigService
4342import software.aws.toolkits.jetbrains.services.amazonq.FeatureContext
44- import software.aws.toolkits.jetbrains.services.amazonq.profile.QRegionProfileSelectedListener
45- import software.aws.toolkits.jetbrains.services.codewhisperer.credentials.CodeWhispererClientAdaptor
4643import software.aws.toolkits.jetbrains.services.codewhisperer.customization.CodeWhispererCustomization
4744import software.aws.toolkits.jetbrains.services.codewhisperer.customization.CodeWhispererCustomizationState
4845import software.aws.toolkits.jetbrains.services.codewhisperer.customization.DefaultCodeWhispererModelConfigurator
@@ -78,7 +75,6 @@ class CodeWhispererModelConfiguratorTest {
7875 private lateinit var sut: DefaultCodeWhispererModelConfigurator
7976 private lateinit var mockClient: CodeWhispererRuntimeClient
8077 private lateinit var abManager: CodeWhispererFeatureConfigService
81- private lateinit var mockClintAdaptor: CodeWhispererClientAdaptor
8278
8379 @Before
8480 fun setup () {
@@ -114,9 +110,6 @@ class CodeWhispererModelConfiguratorTest {
114110 abManager,
115111 disposableRule.disposable
116112 )
117-
118- mockClintAdaptor = mock()
119- projectRule.project.registerServiceInstance(CodeWhispererClientAdaptor ::class .java, mockClintAdaptor)
120113 }
121114
122115 @Test
@@ -557,47 +550,4 @@ class CodeWhispererModelConfiguratorTest {
557550 assertThat(actual.previousAvailableCustomizations).hasSize(1 )
558551 assertThat(actual.previousAvailableCustomizations[" fake-sso-url" ]).isEqualTo(listOf (" arn_1" , " arn_2" , " arn_3" ))
559552 }
560-
561- @Test
562- fun `profile switch should keep using existing customization if new list still contains that arn` () {
563- val ssoConn = spy(LegacyManagedBearerSsoConnection (region = " us-east-1" , startUrl = " url 1" , scopes = Q_SCOPES ))
564- ToolkitConnectionManager .getInstance(projectRule.project).switchConnection(ssoConn)
565- val oldCustomization = CodeWhispererCustomization (" oldArn" , " oldName" , " oldDescription" )
566- sut.switchCustomization(projectRule.project, oldCustomization)
567-
568- assertThat(sut.activeCustomization(projectRule.project)).isEqualTo(oldCustomization)
569-
570- val fakeCustomizations = listOf (
571- CodeWhispererCustomization (" oldArn" , " oldName" , " oldDescription" )
572- )
573-
574- mockClintAdaptor.stub { on { listAvailableCustomizations() } doReturn fakeCustomizations}
575-
576- ApplicationManager .getApplication().messageBus
577- .syncPublisher(QRegionProfileSelectedListener .TOPIC )
578- .onProfileSelected(projectRule.project, null )
579-
580- assertThat(sut.activeCustomization(projectRule.project)).isEqualTo(oldCustomization)
581- }
582-
583- @Test
584- fun `profile switch should invalidate obsolete customization if it's not in the new list` () {
585- val ssoConn = spy(LegacyManagedBearerSsoConnection (region = " us-east-1" , startUrl = " url 1" , scopes = Q_SCOPES ))
586- ToolkitConnectionManager .getInstance(projectRule.project).switchConnection(ssoConn)
587- val oldCustomization = CodeWhispererCustomization (" oldArn" , " oldName" , " oldDescription" )
588- sut.switchCustomization(projectRule.project, oldCustomization)
589- assertThat(sut.activeCustomization(projectRule.project)).isEqualTo(oldCustomization)
590-
591- val fakeCustomizations = listOf (
592- CodeWhispererCustomization (" newArn" , " newName" , " oldDescription" )
593- )
594- mockClintAdaptor.stub { on { listAvailableCustomizations() } doReturn fakeCustomizations}
595-
596- ApplicationManager .getApplication().messageBus
597- .syncPublisher(QRegionProfileSelectedListener .TOPIC )
598- .onProfileSelected(projectRule.project, null )
599-
600- assertThat(sut.activeCustomization(projectRule.project)).isNull()
601- }
602-
603553}
0 commit comments