use of com.sequenceiq.environment.environment.dto.EnvironmentChangeCredentialDto in project cloudbreak by hortonworks.
the class EnvironmentModificationServiceTest method changeCredentialByEnvironmentCrn.
@Test
void changeCredentialByEnvironmentCrn() {
String credentialName = "credentialName";
final Credential value = new Credential();
EnvironmentChangeCredentialDto environmentChangeDto = EnvironmentChangeCredentialDto.EnvironmentChangeCredentialDtoBuilder.anEnvironmentChangeCredentialDto().withCredentialName(credentialName).build();
when(environmentService.findByResourceCrnAndAccountIdAndArchivedIsFalse(eq(CRN), eq(ACCOUNT_ID))).thenReturn(Optional.of(new Environment()));
when(credentialService.getByNameForAccountId(eq(credentialName), eq(ACCOUNT_ID), eq(ENVIRONMENT))).thenReturn(value);
environmentModificationServiceUnderTest.changeCredentialByEnvironmentCrn(ACCOUNT_ID, CRN, environmentChangeDto);
ArgumentCaptor<Environment> environmentArgumentCaptor = ArgumentCaptor.forClass(Environment.class);
verify(environmentService).save(environmentArgumentCaptor.capture());
assertEquals(value, environmentArgumentCaptor.getValue().getCredential());
}
use of com.sequenceiq.environment.environment.dto.EnvironmentChangeCredentialDto in project cloudbreak by hortonworks.
the class EnvironmentController method changeCredentialByEnvironmentName.
@Override
@CheckPermissionByRequestProperty(path = "credentialName", type = NAME, action = DESCRIBE_CREDENTIAL)
@CheckPermissionByResourceName(action = AuthorizationResourceAction.CHANGE_CREDENTIAL)
public DetailedEnvironmentResponse changeCredentialByEnvironmentName(@ResourceName String environmentName, @RequestObject @Valid EnvironmentChangeCredentialRequest request) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
EnvironmentChangeCredentialDto dto = environmentApiConverter.convertEnvironmentChangeCredentialDto(request);
EnvironmentDto result = environmentModificationService.changeCredentialByEnvironmentName(accountId, environmentName, dto);
return environmentResponseConverter.dtoToDetailedResponse(result);
}
use of com.sequenceiq.environment.environment.dto.EnvironmentChangeCredentialDto in project cloudbreak by hortonworks.
the class EnvironmentModificationServiceTest method changeCredentialByEnvironmentName.
@Test
void changeCredentialByEnvironmentName() {
String credentialName = "credentialName";
final Credential value = new Credential();
EnvironmentChangeCredentialDto environmentChangeDto = EnvironmentChangeCredentialDto.EnvironmentChangeCredentialDtoBuilder.anEnvironmentChangeCredentialDto().withCredentialName(credentialName).build();
when(environmentService.findByNameAndAccountIdAndArchivedIsFalse(eq(ENVIRONMENT_NAME), eq(ACCOUNT_ID))).thenReturn(Optional.of(new Environment()));
when(credentialService.getByNameForAccountId(eq(credentialName), eq(ACCOUNT_ID), eq(ENVIRONMENT))).thenReturn(value);
environmentModificationServiceUnderTest.changeCredentialByEnvironmentName(ACCOUNT_ID, ENVIRONMENT_NAME, environmentChangeDto);
ArgumentCaptor<Environment> environmentArgumentCaptor = ArgumentCaptor.forClass(Environment.class);
verify(environmentService).save(environmentArgumentCaptor.capture());
assertEquals(value, environmentArgumentCaptor.getValue().getCredential());
}
Aggregations