@Override public void setUp() throws Exception { super.setUp(); myFixture = IdeaTestFixtureFactory.getFixtureFactory() .createFixtureBuilder(RandomStringUtils.randomAlphanumeric(20)) .getFixture(); myFixture.setUp(); project = myFixture.getProject(); Settings.getInstance(project).pluginEnabled = true; }
@Test public void createServiceAccountAndDownloadKey_whenThrowingException_notifiesUser() throws IOException { when(serviceAccountCreate.execute()).thenThrow(new IOException()); Set<Role> roles = ImmutableSet.of(); CloudApiManager.createServiceAccountAndDownloadKey( roles, SERVICE_ACCOUNT_NAME, downloadDir.toPath(), cloudProject, testFixture.getProject()); ArgumentCaptor<Notification> captor = ArgumentCaptor.forClass(Notification.class); verify(notifications).notify(captor.capture()); assertThat(captor.getAllValues().size()).isEqualTo(1); assertThat(captor.getValue().getTitle()).isEqualTo("Error Creating Service Account"); }
@Before public void initialize() { helper = new CloudSdkAppEngineHelper(testFixture.getProject()); when(mockCloudSdkServiceManager.getCloudSdkService()).thenReturn(sdkService); }
@Test public void createServiceAccountAndDownloadKey_withNoRoles_createsKey() { Set<Role> roles = ImmutableSet.of(); CloudApiManager.createServiceAccountAndDownloadKey( roles, SERVICE_ACCOUNT_NAME, downloadDir.toPath(), cloudProject, testFixture.getProject()); verify(progressIndicator, times(3)).setText(anyString()); verify(progressIndicator, times(3)).setFraction(anyDouble()); String[] contents = downloadDir.list(); assertThat(contents.length).isEqualTo(1); assertThat(contents[0]).startsWith(CLOUD_PROJECT_NAME); }
@Test public void getSources_withMavenizedModule_andNoAppEngineModules_returnsEmptySources() { MavenTestUtils.getInstance() .runWithMavenModule( testFixture.getProject(), mavenModule -> { when(mavenProjectService.isJarOrWarMavenBuild(mavenModule)).thenReturn(true); List<DeploymentSource> mavenSources = mavenDeploymentSourceProvider.getDeploymentSources(testFixture.getProject()); assertThat(mavenSources).isEmpty(); }); }
@Test public void newInstance_doesSetServiceLabel() { String serviceName = "some-service-name"; when(mockAppEngineProjectService.getServiceNameFromAppEngineWebXml( testFixture.getProject(), deploymentSource)) .thenReturn(serviceName); Disposer.dispose(editor); editor = new AppEngineStandardDeploymentEditor(testFixture.getProject(), deploymentSource); assertThat(editor.getCommonConfig().getServiceLabel().getText()).isEqualTo(serviceName); }
@Test public void getDeploymentSources_withAppEngineFacet_andGradleBuildDir_returnsGradleSource() { System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, PlatformUtils.IDEA_CE_PREFIX); initForGradleSources(); List<DeploymentSource> sources = gradleDeploymentSourceProvider.getDeploymentSources(testFixture.getProject()); assertThat(sources).hasSize(1); assertThat(sources.get(0) instanceof GradlePluginDeploymentSource).isTrue(); }
@Test public void getDeploymentSources_withUltimateEdition_returnsEmpty() { System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, PlatformUtils.IDEA_PREFIX); initForGradleSources(); List<DeploymentSource> sources = gradleDeploymentSourceProvider.getDeploymentSources(testFixture.getProject()); assertThat(sources).isEmpty(); }
@Test public void testAcceptsCorrectFileType() { assertFalse(bucketEditorProvider.accept(testFixture.getProject(), virtualFile)); assertTrue(bucketEditorProvider.accept(testFixture.getProject(), gcsBucketVirtualFile)); }
@Test public void applyEditorTo_withFlexCompatSource_doesSetEnvironment() throws Exception { when(mockAppEngineProjectService.isFlexCompat(testFixture.getProject(), deploymentSource)) .thenReturn(true); editor.applyEditorTo(configuration); assertThat(configuration.getEnvironment()) .isEqualTo(AppEngineEnvironment.APP_ENGINE_FLEX_COMPAT); }
@Test public void getDeploymentSources_withAppEngineFacet_andGradleBuildDir_withNoGradle_returnsEmpty() { System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, PlatformUtils.IDEA_CE_PREFIX); addGradleBuildDir(); addAppEngineStandardFacet(); List<DeploymentSource> sources = gradleDeploymentSourceProvider.getDeploymentSources(testFixture.getProject()); assertThat(sources).isEmpty(); }
@Test public void newInstance_doesSetEnvironmentLabel() { when(deploymentSource.getEnvironment()).thenReturn(AppEngineEnvironment.APP_ENGINE_STANDARD); Disposer.dispose(editor); editor = new AppEngineStandardDeploymentEditor(testFixture.getProject(), deploymentSource); assertThat(editor.getCommonConfig().getEnvironmentLabel().getText()) .isEqualTo(AppEngineEnvironment.APP_ENGINE_STANDARD.localizedLabel()); }
@Before public void setUp() throws Exception { FacetManager.getInstance(module) .getFacetByType(AppEngineFlexibleFacet.getFacetType().getId()) .getConfiguration() .setAppYamlPath(javaYaml.getPath()); when(mockAppEngineDeployable.isValid()).thenReturn(true); configuration = new AppEngineDeploymentConfiguration(); project = testFixture.getProject(); when(mockSdkServiceManager.getCloudSdkService()).thenReturn(mockSdkService); }
@Test public void getDeploymentSources_withStandardAndFlexModules_doesNotReturnSource() { ModuleTestUtils.addFacet(module1, AppEngineFlexibleFacetType.ID); ModuleTestUtils.addFacet(module2, AppEngineStandardFacetType.ID); List<DeploymentSource> deploymentSources = moduleDeploymentSourceProvider.getDeploymentSources(testFixture.getProject()); assertThat(deploymentSources).isEmpty(); }
@Test public void getCloudLibraries_withNoDependencies_isEmpty() { MavenTestUtils.getInstance() .runWithMavenModule( testFixture.getProject(), module -> assertThat(state.getCloudLibraries(module)).isEmpty()); }
@Test public void newInstance_withStandardEnvironment_doesHideCostWarningPanel() { when(deploymentSource.getEnvironment()).thenReturn(AppEngineEnvironment.APP_ENGINE_STANDARD); Disposer.dispose(editor); editor = new AppEngineStandardDeploymentEditor(testFixture.getProject(), deploymentSource); assertThat(editor.getCommonConfig().getAppEngineCostWarningPanel().isVisible()).isFalse(); }
@Test public void newInstance_withFlexEnvironment_doesHideCostWarningPanel() { when(deploymentSource.getEnvironment()).thenReturn(AppEngineEnvironment.APP_ENGINE_FLEX); Disposer.dispose(editor); editor = new AppEngineStandardDeploymentEditor(testFixture.getProject(), deploymentSource); assertThat(editor.getCommonConfig().getAppEngineCostWarningPanel().isVisible()).isFalse(); }
@Before public void setUp() { dataService = new AppEngineGradleProjectDataService(); modelsProvider = new IdeModifiableModelsProviderImpl(testFixture.getProject()); gradleModuleComponent = AppEngineStandardGradleModuleComponent.getInstance(module); }
@Before public void setUp() { configuration = new AppEngineDeploymentConfiguration(); editor = new AppEngineStandardDeploymentEditor(testFixture.getProject(), deploymentSource); editor.getCommonConfig().setProjectSelector(projectSelector); }
@BeforeEach public void before() throws Exception { IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory(); IdeaProjectTestFixture testFixture = factory.createLightFixtureBuilder(EMPTY_PROJECT_DESCRIPTOR).getFixture(); fixture = factory.createCodeInsightFixture(testFixture, new LightTempDirTestFixtureImpl(true)); fixture.setUp(); fixture.setTestDataPath(getTestDataPath()); storage = ServiceManager.getService(testFixture.getProject(), Storage.class); }