public void deleteProjectProperty(String key, Long projectId) { try (DbSession session = mybatis.openSession(false)) { deleteProjectProperty(key, projectId, session); session.commit(); } }
void deleteComponents(List<String> componentUuids) { if (componentUuids.isEmpty()) { return; } profiler.start("deleteComponents (projects)"); Lists.partition(componentUuids, MAX_RESOURCES_PER_QUERY).forEach(purgeMapper::deleteComponentsByUuids); session.commit(); profiler.stop(); }
private void insertOrganization(OrganizationDto dto, long createdAt) { when(system2.now()).thenReturn(createdAt); dbClient.organizationDao().insert(dbSession, dto, false); dbSession.commit(); } }
@Test public void deleteByOrganization_does_not_fail_if_table_is_empty() { underTest.deleteByOrganization(dbSession, "some uuid"); dbSession.commit(); }
@Test public void deleteByOrganization_does_not_fail_on_empty_db() { underTest.deleteByOrganization(dbSession, "some uuid"); dbSession.commit(); }
private String insertScannerContext(String uuid) { String data = "data of " + uuid; underTest.insert(dbSession, uuid, scannerContextInputStreamOf(data)); dbSession.commit(); return data; }
@Test public void deleteByOrganization_does_not_fail_on_empty_db() { underTest.deleteByOrganization(dbSession, "some uuid"); dbSession.commit(); }
public void deleteUserPermission(DbSession session, Long templateId, Integer userId, String permission) { PermissionTemplateUserDto permissionTemplateUser = new PermissionTemplateUserDto() .setTemplateId(templateId) .setPermission(permission) .setUserId(userId); mapper(session).deleteUserPermission(permissionTemplateUser); session.commit(); }
@SafeVarargs public final WebhookDeliveryLiteDto insert(Consumer<WebhookDeliveryDto>... dtoPopulators) { WebhookDeliveryDto dto = newDto(); stream(dtoPopulators).forEach(dtoPopulator -> dtoPopulator.accept(dto)); dbTester.getDbClient().webhookDeliveryDao().insert(dbTester.getSession(), dto); dbTester.getSession().commit(); return dto; }
@Test public void shouldNotUpdateAllSubmodules() { db.prepareDbUnit(getClass(), "shouldNotUpdateAllSubmodules.xml"); underTest.bulkUpdateKey(dbSession, "A", "org.struts", "org.apache.struts", doNotReturnAnyRekeyedResource()); dbSession.commit(); db.assertDbUnit(getClass(), "shouldNotUpdateAllSubmodules-result.xml", "projects"); }
private IndexingResult indexProject(ComponentDto project, ProjectIndexer.Cause cause) { DbSession dbSession = db.getSession(); Collection<EsQueueDto> items = underTest.prepareForRecovery(dbSession, singletonList(project.uuid()), cause); dbSession.commit(); return underTest.index(dbSession, items); }
private void insertNewCustomMetric(String... ids) { for (String id : ids) { dbClient.metricDao().insert(dbSession, newCustomMetric(id)); } dbSession.commit(); }
@Override public void execute(ComputationStep.Context context) { try (DbSession dbSession = dbClient.openSession(false)) { long analysisDate = analysisMetadataHolder.getAnalysisDate(); new DepthTraversalTypeAwareCrawler(new PersistEventComponentVisitor(dbSession, analysisDate)) .visit(treeRootHolder.getRoot()); dbSession.commit(); } }
@Test public void purge_failed_ce_tasks() { db.prepareDbUnit(getClass(), "shouldDeleteAbortedBuilds.xml"); underTest.purge(dbSession, newConfigurationWith30Days(), PurgeListener.EMPTY, new PurgeProfiler()); dbSession.commit(); db.assertDbUnit(getClass(), "shouldDeleteAbortedBuilds-result.xml", "snapshots"); }
@SafeVarargs public final WebhookDeliveryLiteDto insert(WebhookDto webhook, Consumer<WebhookDeliveryDto>... dtoPopulators) { WebhookDeliveryDto dto = newDto(); stream(dtoPopulators).forEach(dtoPopulator -> dtoPopulator.accept(dto)); String projectUuid = webhook.getProjectUuid(); dto.setComponentUuid(Objects.requireNonNull(projectUuid, "Project uuid of webhook cannot be null")); dto.setWebhookUuid(webhook.getUuid()); dbTester.getDbClient().webhookDeliveryDao().insert(dbTester.getSession(), dto); dbTester.getSession().commit(); return dto; }
@Test public void delete() { OrganizationDto organization = db.organizations().insert(); QGateWithOrgDto qualityGate = qualityGateDbTester.insertQualityGate(organization); QGateWithOrgDto otherQualityGate = qualityGateDbTester.insertQualityGate(organization); underTest.delete(qualityGate, dbSession); dbSession.commit(); assertThat(underTest.selectByOrganizationAndUuid(dbSession, organization, qualityGate.getUuid())).isNull(); assertThat(db.countSql(dbSession, format("select count(*) from org_quality_gates where quality_gate_uuid='%s'", qualityGate.getUuid()))).isZero(); assertThat(underTest.selectByOrganizationAndUuid(dbSession, organization, otherQualityGate.getUuid())).isNotNull(); assertThat(db.countSql(dbSession, format("select count(*) from org_quality_gates where quality_gate_uuid='%s'", otherQualityGate.getUuid()))).isEqualTo(1); }
@Test public void remove_to_email_channel_by_default() { UserDto user = db.users().insertUser(); userSession.logIn(user); when(dispatchers.getGlobalDispatchers()).thenReturn(singletonList(NOTIF_MY_NEW_ISSUES)); notificationUpdater.add(dbSession, defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, user, null); dbSession.commit(); call(request); db.notifications().assertDoesNotExist(defaultChannel.getKey(), NOTIF_MY_NEW_ISSUES, user.getId(), null); }
private ComponentDto createProject(String projectKey) { ComponentDto project = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert()).setDbKey(projectKey); dbClient.componentDao().insert(dbSession, project); dbSession.commit(); return project; }
private CeTaskMessageDto insertMessage(String taskUuid, int i, long createdAt) { CeTaskMessageDto res = new CeTaskMessageDto() .setUuid("message_" + i) .setTaskUuid(taskUuid) .setMessage("test_" + i) .setCreatedAt(createdAt); DbSession dbSession = dbTester.getSession(); underTest.insert(dbSession, res); dbSession.commit(); return res; } }
private CeQueueDto insertPending(String uuid, String mainComponentUuid) { CeQueueDto dto = new CeQueueDto(); dto.setUuid(uuid); dto.setTaskType(CeTaskTypes.REPORT); dto.setMainComponentUuid(mainComponentUuid); dto.setComponentUuid("uuid_" + pendingComponentUuidGenerator++); dto.setStatus(PENDING); dto.setSubmitterUuid("henri"); underTest.insert(db.getSession(), dto); db.getSession().commit(); return dto; }