/** * @deprecated since 6.6 * @see #insertPublicApplication(OrganizationDto, Consumer[]) */ @SafeVarargs public final ComponentDto insertApplication(OrganizationDto organizationDto, Consumer<ComponentDto>... dtoPopulators) { return insertComponentImpl(newApplication(organizationDto), false, dtoPopulators); }
@SafeVarargs public final ComponentDto insertPublicApplication(OrganizationDto organization, Consumer<ComponentDto>... dtoPopulators) { return insertComponentImpl(newApplication(organization).setPrivate(false), false, dtoPopulators); }
@SafeVarargs public final ComponentDto insertPrivateApplication(OrganizationDto organization, Consumer<ComponentDto>... dtoPopulators) { return insertComponentImpl(newApplication(organization).setPrivate(true), true, dtoPopulators); }
@Test public void create_event_on_application() { ComponentDto application = ComponentTesting.newApplication(db.getDefaultOrganization()); SnapshotDto analysis = db.components().insertProjectAndSnapshot(application); logInAsProjectAdministrator(application); CreateEventResponse result = call(OTHER.name(), "Application Event", analysis.getUuid()); ProjectAnalyses.Event event = result.getEvent(); assertThat(event.getName()).isEqualTo("Application Event"); }
@Test public void onEnd_fails_with_IAE_if_component_is_not_a_project() { when(ceTaskMock.getType()).thenReturn(CeTaskTypes.REPORT); OrganizationDto organization = OrganizationTesting.newOrganizationDto(); ComponentDto project = dbTester.components().insertPrivateProject(); ComponentDto module = dbTester.components().insertComponent(newModuleDto(project)); ComponentDto directory = dbTester.components().insertComponent(newDirectory(module, randomAlphanumeric(12))); ComponentDto file = dbTester.components().insertComponent(ComponentTesting.newFileDto(project)); ComponentDto view = dbTester.components().insertComponent(ComponentTesting.newView(organization)); ComponentDto subView = dbTester.components().insertComponent(ComponentTesting.newSubView(view)); ComponentDto projectCopy = dbTester.components().insertComponent(ComponentTesting.newProjectCopy(project, subView)); ComponentDto application = dbTester.components().insertComponent(ComponentTesting.newApplication(organization)); Arrays.asList(module, directory, file, view, subView, projectCopy, application) .forEach(component -> { try { when(ceTaskMock.getComponent()).thenReturn(Optional.of(new CeTask.Component(component.uuid(), null, null))); when(notificationService.hasProjectSubscribersForTypes(component.uuid(), singleton(ReportAnalysisFailureNotification.TYPE))) .thenReturn(true); underTest.onEnd(ceTaskMock, CeActivityDto.Status.FAILED, ceTaskResultMock, throwableMock); fail("An IllegalArgumentException should have been thrown for component " + component); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).isEqualTo(String.format( "Component %s must be a project (scope=%s, qualifier=%s)", component.uuid(), component.scope(), component.qualifier())); } }); }
@Test public void fail_if_create_version_event_on_application() { ComponentDto application = newApplication(db.organizations().insert()); SnapshotDto analysis = db.components().insertViewAndSnapshot(application); logInAsProjectAdministrator(application); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("A version event must be created on a project"); call(VERSION.name(), "5.6.3", analysis.getUuid()); }
@Test public void apply_template_by_qualifiers() { ComponentDto publicProject = db.components().insertPublicProject(organization); ComponentDto privateProject = db.components().insertPrivateProject(organization); ComponentDto view = db.components().insertComponent(newView(organization)); ComponentDto application = db.components().insertComponent(newApplication(organization)); loginAsAdmin(organization); newRequest() .setParam(PARAM_TEMPLATE_ID, template1.getUuid()) .setParam(PARAM_QUALIFIERS, String.join(",", Qualifiers.PROJECT, Qualifiers.APP)) .execute(); assertTemplate1AppliedToPrivateProject(privateProject); assertTemplate1AppliedToPublicProject(publicProject); assertTemplate1AppliedToPublicProject(application); assertNoPermissionOnProject(view); }