/** * @deprecated since 6.6 * @see #insertPublicPortfolio(OrganizationDto, Consumer[]) */ public ComponentDto insertView(OrganizationDto organizationDto, Consumer<ComponentDto> dtoPopulator) { return insertComponentImpl(newView(organizationDto), false, dtoPopulator); }
/** * @deprecated since 6.6 * @see #insertPublicPortfolio(OrganizationDto, Consumer[]) */ public ComponentDto insertView(Consumer<ComponentDto> dtoPopulator) { return insertComponentImpl(newView(db.getDefaultOrganization()), false, dtoPopulator); }
/** * @deprecated since 6.6 * @see #insertPublicPortfolio(OrganizationDto, Consumer[]) */ public ComponentDto insertView(OrganizationDto organizationDto) { return insertComponentImpl(newView(organizationDto), false, noExtraConfiguration()); }
/** * @deprecated since 6.6 * @see #insertPublicPortfolio(OrganizationDto, Consumer[]) */ public ComponentDto insertView(OrganizationDto organizationDto, String uuid) { return insertComponentImpl(newView(organizationDto, uuid), false, noExtraConfiguration()); }
/** * @deprecated since 6.6 * @see #insertPublicPortfolio(OrganizationDto, Consumer[]) */ @Deprecated public ComponentDto insertView() { return insertComponentImpl(newView(db.getDefaultOrganization()), false, noExtraConfiguration()); }
/** * @deprecated since 6.6 * @see #insertPublicPortfolio(OrganizationDto, Consumer[]) */ public ComponentDto insertView(String uuid) { return insertComponentImpl(newView(db.getDefaultOrganization(), uuid), false, noExtraConfiguration()); }
private ComponentDto newViewDto(OrganizationDto organizationDto) { return ComponentTesting.newView(organizationDto, VIEW_UUID) .setOrganizationUuid(ORGANIZATION_UUID) .setDbKey(VIEW_KEY) .setName(VIEW_NAME); }
private ComponentDto insertView(OrganizationDto organizationDto) { return db.components().insertComponent(newView(organizationDto, "752d8bfd-420c-4a83-a4e5-8ab19b13c8fc") .setName("Java") .setDbKey("Java")); }
@Test public void fail_when_component_is_not_a_project() { UserDto user = db.users().insertUser(); userSession.logIn(user); db.components().insertViewAndSnapshot(newView(db.organizations().insert()).setDbKey("VIEW_1")); when(dispatchers.getGlobalDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES)); when(dispatchers.getProjectDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES)); expectedException.expect(BadRequestException.class); expectedException.expectMessage("Component 'VIEW_1' must be a project"); call(NOTIF_MY_NEW_ISSUES, null, "VIEW_1", null); }
@Test public void fail_when_component_is_not_a_project() { UserDto user = db.users().insertUser(); userSession.logIn(user); when(dispatchers.getGlobalDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES)); when(dispatchers.getProjectDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES)); db.components().insertViewAndSnapshot(newView(db.organizations().insert()).setDbKey("VIEW_1")); expectedException.expect(BadRequestException.class); expectedException.expectMessage("Component 'VIEW_1' must be a project"); call(request.setProject("VIEW_1")); }
@Test public void count_provisioned() { OrganizationDto organization = db.organizations().insert(); db.components().insertPrivateProject(organization); db.components().insertProjectAndSnapshot(newPrivateProjectDto(organization)); db.components().insertProjectAndSnapshot(ComponentTesting.newView(organization)); Supplier<ComponentQuery.Builder> query = () -> ComponentQuery.builder().setOnProvisionedOnly(true); assertThat(underTest.countByQuery(dbSession, organization.getUuid(), query.get().setQualifiers(PROJECT).build())).isEqualTo(1); assertThat(underTest.countByQuery(dbSession, organization.getUuid(), query.get().setQualifiers(Qualifiers.VIEW).build())).isEqualTo(0); assertThat(underTest.countByQuery(dbSession, organization.getUuid(), query.get().setQualifiers(PROJECT, Qualifiers.VIEW).build())).isEqualTo(1); }
private ComponentDto insertView() { return db.components().insertComponent(newView(db.getDefaultOrganization()) .setUuid("752d8bfd-420c-4a83-a4e5-8ab19b13c8fc") .setName("Java") .setDbKey("Java")); }
@Test public void fail_when_component_is_a_subview() { ComponentDto file = db.components().insertComponent(newSubView(ComponentTesting.newView(db.organizations().insert()))); failIfComponentIsNotAProjectOrView(file); }
@Test public void fail_when_component_is_a_subview() { ComponentDto file = db.components().insertComponent(newSubView(ComponentTesting.newView(db.organizations().insert()))); failIfComponentIsNotAProjectOrView(file); }
@Test public void add_permission_to_view() { ComponentDto view = db.components().insertComponent(newView(db.getDefaultOrganization(), "view-uuid").setDbKey("view-key")); loginAsAdmin(db.getDefaultOrganization()); newRequest() .setParam(PARAM_USER_LOGIN, user.getLogin()) .setParam(PARAM_PROJECT_ID, view.uuid()) .setParam(PARAM_PERMISSION, SYSTEM_ADMIN) .execute(); assertThat(db.users().selectPermissionsOfUser(user, db.getDefaultOrganization())).isEmpty(); assertThat(db.users().selectProjectPermissionsOfUser(user, view)).containsOnly(SYSTEM_ADMIN); }
@Test public void search_views() { userSession.addPermission(ADMINISTER, db.getDefaultOrganization()); db.components().insertComponents( ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey(PROJECT_KEY_1), newView(db.getDefaultOrganization()).setDbKey("view1")); SearchWsResponse response = call(SearchRequest.builder().setQualifiers(singletonList("VW")).build()); assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly("view1"); }
@Test public void search_projects_and_views() { userSession.addPermission(ADMINISTER, db.getDefaultOrganization()); db.components().insertComponents( ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey(PROJECT_KEY_1), newView(db.getDefaultOrganization()).setDbKey("view1")); SearchWsResponse response = call(SearchRequest.builder().setQualifiers(asList("TRK", "VW")).build()); assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(PROJECT_KEY_1, "view1"); }
@Test public void search_projects_when_no_qualifier_set() { userSession.addPermission(ADMINISTER, db.getDefaultOrganization()); db.components().insertComponents( ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization()).setDbKey(PROJECT_KEY_1), newView(db.getDefaultOrganization())); SearchWsResponse response = call(SearchRequest.builder().build()); assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(PROJECT_KEY_1); }
@Test public void fail_if_create_on_view() { ComponentDto view = newView(db.organizations().insert()); SnapshotDto analysis = db.components().insertViewAndSnapshot(view); logInAsProjectAdministrator(view); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("An event must be created on a project or an application"); call(OTHER.name(), "View Event", analysis.getUuid()); }
@Test public void select_projects() { OrganizationDto organization = db.organizations().insert(); ComponentDto provisionedProject = db.components().insertPrivateProject(); ComponentDto provisionedView = db.components().insertView(organization); String projectUuid = db.components().insertProjectAndSnapshot(newPrivateProjectDto(organization)).getComponentUuid(); String disabledProjectUuid = db.components().insertProjectAndSnapshot(newPrivateProjectDto(organization).setEnabled(false)).getComponentUuid(); String viewUuid = db.components().insertProjectAndSnapshot(ComponentTesting.newView(organization)).getComponentUuid(); assertThat(underTest.selectProjects(dbSession)) .extracting(ComponentDto::uuid) .containsOnly(provisionedProject.uuid(), projectUuid); }