use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.
the class EnvironmentServiceTest method updateTunnelByEnvironmentId.
@Test
void updateTunnelByEnvironmentId() {
ExperimentalFeatures expFeat = environment.getExperimentalFeaturesJson();
expFeat.setTunnel(Tunnel.CCM);
environment.setExperimentalFeaturesJson(expFeat);
Optional<Environment> optEnv = Optional.of(environment);
when(environmentRepository.findById(123L)).thenReturn(optEnv);
environmentServiceUnderTest.updateTunnelByEnvironmentId(123L, Tunnel.CCMV2_JUMPGATE);
ArgumentCaptor<Environment> envCaptor = ArgumentCaptor.forClass(Environment.class);
verify(environmentRepository).save(envCaptor.capture());
Environment captured = envCaptor.getValue();
assertThat(captured.getExperimentalFeaturesJson().getTunnel()).isEqualTo(Tunnel.CCMV2_JUMPGATE);
}
use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.
the class EnvironmentServiceTest method listByAccountId.
@Test
void listByAccountId() {
Set<Environment> twoEnvironment = Set.of(new Environment(), new Environment());
final int twoInvocations = 2;
when(environmentRepository.findByAccountId(eq(TestConstants.ACCOUNT_ID))).thenReturn(twoEnvironment);
environmentServiceUnderTest.listByAccountId(TestConstants.ACCOUNT_ID);
verify(environmentRepository).findByAccountId(eq(TestConstants.ACCOUNT_ID));
verify(environmentDtoConverter, times(twoInvocations)).environmentToDto(any(Environment.class));
}
use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.
the class EnvironmentStopServiceTest method shouldStopEnvWithOnlyStoppedChildren.
@Test
public void shouldStopEnvWithOnlyStoppedChildren() {
EnvironmentDto environmentDto = getEnvironmentDto();
when(environmentService.getByCrnAndAccountId(ENV_CRN, ACCOUNT_ID)).thenReturn(environmentDto);
Environment childEnvironment = new Environment();
childEnvironment.setStatus(EnvironmentStatus.ENV_STOPPED);
when(environmentService.findAllByAccountIdAndParentEnvIdAndArchivedIsFalse(ACCOUNT_ID, ENV_ID)).thenReturn(List.of(childEnvironment));
ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.stopByCrn(ENV_CRN));
verify(reactorFlowManager).triggerStopFlow(ENV_ID, ENV_NAME, USER_CRN);
}
use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.
the class EnvironmentStatusCheckerJobTest method testSyncAnEnvSameStatus.
@Test
void testSyncAnEnvSameStatus() {
Environment environment = new Environment();
environment.setId(1234L);
environment.setStatus(AVAILABLE);
when(environmentSyncService.getStatusByFreeipa(environment)).thenReturn(AVAILABLE);
underTest.syncAnEnv(environment);
verify(environmentStatusUpdateService, never()).updateEnvironmentStatusAndNotify(eq(environment), any(), any());
}
use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.
the class EnvironmentStatusTest method setUp.
@BeforeEach
void setUp() {
underTest.setLocalId(ENVIRONMENT_ID.toString());
environment = new Environment();
environment.setId(ENVIRONMENT_ID);
environment.setCreator("creator");
environment.setResourceCrn("crn:env");
environment.setAccountId("cloudera");
when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(environment));
when(flowLogService.isOtherFlowRunning(ENVIRONMENT_ID)).thenReturn(false);
}
Aggregations