@Override public String create() { String uuid = uuidFactory.create(); generatedUuids.add(uuid); return uuid; }
@Override public String create() { String uuid = uuidFactory.create(); generatedUuids.add(uuid); return uuid; }
private boolean handle(Select.Row row, SqlStatement update) throws SQLException { long id = row.getLong(1); update.setString(1, uuidFactory.create()); update.setLong(2, id); return true; }
public Collection<EsQueueDto> insert(DbSession dbSession, Collection<EsQueueDto> items) { long now = system2.now(); EsQueueMapper mapper = mapper(dbSession); items.forEach(item -> { item.setUuid(uuidFactory.create()); mapper.insert(item, now); }); return items; }
public QualityGateDto create(DbSession dbSession, OrganizationDto organizationDto, String name) { validateQualityGate(dbSession, organizationDto, name); QualityGateDto newQualityGate = new QualityGateDto() .setName(name) .setBuiltIn(false) .setUuid(uuidFactory.create()); dbClient.qualityGateDao().insert(dbSession, newQualityGate); dbClient.qualityGateDao().associate(dbSession, uuidFactory.create(), organizationDto, newQualityGate); return newQualityGate; }
private void setupSecondMultiModuleProject() { String project3Uuid = uuidFactory.create(); String singleModuleUuid = uuidFactory.create(); insertComponent(8, project3Uuid, null, project3Uuid, Qualifiers.PROJECT, "Another multi-module project"); insertComponent(9, singleModuleUuid, project3Uuid, project3Uuid, Qualifiers.MODULE, "Module X"); insertProperty(11, 8, "sonar.coverage.exclusions", "InRoot.java", null); insertProperty(12, 9, "sonar.coverage.exclusions", "InModule.java", null); }
public void insert(DbSession dbSession, QProfileChangeDto dto) { checkState(dto.getCreatedAt() == 0L, "Date of QProfileChangeDto must be set by DAO only. Got %s.", dto.getCreatedAt()); dto.setUuid(uuidFactory.create()); dto.setCreatedAt(system2.now()); mapper(dbSession).insert(dto); }
@Test public void test_format_of_uuid() { String uuid = underTest.create(); assertThat(uuid.length()).isGreaterThan(10).isLessThan(40); // URL-safe: only letters, digits, dash and underscore. assertThat(uuid).matches("^[\\w\\-_]+$"); } }
@Test public void create_from_scratch_creates_ServerId_from_JDBC_URL_and_new_uuid() { String jdbcUrl = "jdbc"; String uuid = Uuids.create(); String sanitizedJdbcUrl = "sanitized_jdbc"; settings.setProperty(JDBC_URL.getKey(), jdbcUrl); when(uuidFactory.create()).thenReturn(uuid); when(jdbcUrlSanitizer.sanitize(jdbcUrl)).thenReturn(sanitizedJdbcUrl); ServerId serverId = underTest.create(); assertThat(serverId.getDatabaseId().get()).isEqualTo(crc32Hex(sanitizedJdbcUrl)); assertThat(serverId.getDatasetId()).isEqualTo(uuid); }
@Test @UseDataProvider("anyFormatServerId") public void create_from_ServerId_creates_ServerId_from_JDBC_URL_and_serverId_datasetId(ServerId currentServerId) { String jdbcUrl = "jdbc"; String sanitizedJdbcUrl = "sanitized_jdbc"; settings.setProperty(JDBC_URL.getKey(), jdbcUrl); when(uuidFactory.create()).thenThrow(new IllegalStateException("UuidFactory.create() should not be called")); when(jdbcUrlSanitizer.sanitize(jdbcUrl)).thenReturn(sanitizedJdbcUrl); ServerId serverId = underTest.create(currentServerId); assertThat(serverId.getDatabaseId().get()).isEqualTo(crc32Hex(sanitizedJdbcUrl)); assertThat(serverId.getDatasetId()).isEqualTo(currentServerId.getDatasetId()); }
public UserPropertyDto insertOrUpdate(DbSession session, UserPropertyDto dto) { long now = system2.now(); if (mapper(session).update(dto, now) == 0) { mapper(session).insert(dto.setUuid(uuidFactory.create()), now); } return dto; }
@Test public void delete() { when(uuidFactory.create()).thenReturn(A_UUID); when(system2.now()).thenReturn(DATE); underTest.insertOrUpdate(dbSession, GITHUB, A_OWNER, true, AN_INSTALL, null); underTest.delete(dbSession, GITHUB, A_OWNER); assertThatAlmAppInstall(GITHUB, A_OWNER).doesNotExist(); }
@Test public void selectByOwnerId() { when(uuidFactory.create()).thenReturn(A_UUID); when(system2.now()).thenReturn(DATE); underTest.insertOrUpdate(dbSession, GITHUB, A_OWNER, true, AN_INSTALL, null); assertThat(underTest.selectByOwnerId(dbSession, GITHUB, A_OWNER).get()) .extracting(AlmAppInstallDto::getUuid, AlmAppInstallDto::getAlm, AlmAppInstallDto::getInstallId, AlmAppInstallDto::getOwnerId, AlmAppInstallDto::getCreatedAt, AlmAppInstallDto::getUpdatedAt) .contains(A_UUID, GITHUB, A_OWNER, AN_INSTALL, DATE, DATE); assertThat(underTest.selectByOwnerId(dbSession, BITBUCKETCLOUD, A_OWNER)).isNotPresent(); assertThat(underTest.selectByOwnerId(dbSession, GITHUB, "Unknown owner")).isNotPresent(); }
@Test public void persist_effective_url_if_present() { when(uuidFactory.create()).thenReturn(DELIVERY_UUID); String effectiveUrl = randomAlphabetic(15); WebhookDelivery delivery = newBuilderTemplate() .setEffectiveUrl(effectiveUrl) .build(); underTest.persist(delivery); WebhookDeliveryDto dto = dbClient.webhookDeliveryDao().selectByUuid(dbSession, DELIVERY_UUID).get(); assertThat(dto.getUrl()).isEqualTo(effectiveUrl); }
private EventDto newBaseEvent(Component component, Long analysisDate) { return new EventDto() .setUuid(uuidFactory.create()) .setAnalysisUuid(analysisMetadataHolder.getUuid()) .setComponentUuid(component.getUuid()) .setCreatedAt(system2.now()) .setDate(analysisDate); }
private RulesProfileDto insertRulesProfile(DbSession dbSession, BuiltInQProfile builtIn, Date now) { RulesProfileDto dto = new RulesProfileDto() .setKee(uuidFactory.create()) .setName(builtIn.getName()) .setLanguage(builtIn.getLanguage()) .setIsBuiltIn(true) .setRulesUpdatedAtAsDate(now); dbClient.qualityProfileDao().insert(dbSession, dto); return dto; }
private void addGroup(DbSession dbSession, QProfileDto profile, GroupDto group) { if (dbClient.qProfileEditGroupsDao().exists(dbSession, profile, group)) { return; } dbClient.qProfileEditGroupsDao().insert(dbSession, new QProfileEditGroupsDto() .setUuid(uuidFactory.create()) .setGroupId(group.getId()) .setQProfileUuid(profile.getKee())); dbSession.commit(); } }
private void addUser(DbSession dbSession, QProfileDto profile, UserDto user) { if (dbClient.qProfileEditUsersDao().exists(dbSession, profile, user)) { return; } dbClient.qProfileEditUsersDao().insert(dbSession, new QProfileEditUsersDto() .setUuid(uuidFactory.create()) .setUserId(user.getId()) .setQProfileUuid(profile.getKee())); dbSession.commit(); }