use of org.sonar.db.audit.model.PersonalAccessTokenNewValue in project sonarqube by SonarSource.
the class AlmPatDaoWithPersisterTest method insertAndUpdateArePersisted.
@Test
public void insertAndUpdateArePersisted() {
when(uuidFactory.create()).thenReturn(A_UUID);
AlmPatDto almPatDto = newAlmPatDto();
underTest.insert(dbSession, almPatDto, "user-login", "alm-key");
verify(auditPersister).addPersonalAccessToken(eq(dbSession), newValueCaptor.capture());
PersonalAccessTokenNewValue newValue = newValueCaptor.getValue();
assertThat(newValue).extracting(PersonalAccessTokenNewValue::getPatUuid, PersonalAccessTokenNewValue::getUserUuid, PersonalAccessTokenNewValue::getAlmSettingUuid, PersonalAccessTokenNewValue::getUserLogin, PersonalAccessTokenNewValue::getAlmSettingKey).containsExactly(almPatDto.getUuid(), almPatDto.getUserUuid(), almPatDto.getAlmSettingUuid(), "user-login", "alm-key");
assertThat(newValue.toString()).contains("userLogin");
String updated_pat = "updated pat";
almPatDto.setPersonalAccessToken(updated_pat);
system2.setNow(NOW + 1);
underTest.update(dbSession, almPatDto, null, null);
verify(auditPersister).updatePersonalAccessToken(eq(dbSession), newValueCaptor.capture());
}
Aggregations