use of org.sonar.db.almsettings.AlmSettingsTesting.newGithubAlmSettingDto in project sonarqube by SonarSource.
the class AlmSettingDaoTest method selectByKey.
@Test
public void selectByKey() {
when(uuidFactory.create()).thenReturn(A_UUID);
String decrypted = "decrypted";
when(encryption.isEncrypted(any())).thenReturn(true);
when(encryption.decrypt(any())).thenReturn(decrypted);
AlmSettingDto almSettingDto = AlmSettingsTesting.newGithubAlmSettingDto();
underTest.insert(dbSession, almSettingDto);
assertThat(underTest.selectByKey(dbSession, almSettingDto.getKey()).get()).extracting(AlmSettingDto::getUuid, AlmSettingDto::getKey, AlmSettingDto::getRawAlm, AlmSettingDto::getUrl, AlmSettingDto::getAppId, AlmSettingDto::getCreatedAt, AlmSettingDto::getUpdatedAt, s -> almSettingDto.getDecryptedPrivateKey(encryption), s -> almSettingDto.getDecryptedPersonalAccessToken(encryption), s -> almSettingDto.getDecryptedClientSecret(encryption)).containsExactly(A_UUID, almSettingDto.getKey(), ALM.GITHUB.getId(), almSettingDto.getUrl(), almSettingDto.getAppId(), NOW, NOW, almSettingDto.getDecryptedPrivateKey(encryption), null, almSettingDto.getDecryptedClientSecret(encryption));
assertThat(underTest.selectByKey(dbSession, "foo")).isNotPresent();
}
Aggregations