@Test public void startDeployment() throws Exception { when(environmentRepository.getEnvironment(environmentId)).thenReturn(environment); when(environmentRepository.getEnvironmentRevision(environmentId, ENVIRONMENT_REVISION_ID)) .thenReturn(environmentRevision); final StartDeploymentResponse response = api.startDeployment(request); assertThat(response.getEnvironmentId()).isEqualTo(environmentIdWrapper); assertThat(response.getEnvironmentRevisionId()).isEqualTo(ENVIRONMENT_REVISION_ID); assertThat(response.getDeploymentId()).isNotEmpty(); verify(apiModelMapper).toModelEnvironmentId(environmentIdWrapper); verify(environmentRepository).getEnvironment(environmentId); verify(environmentRepository).getEnvironmentRevision(environmentId, ENVIRONMENT_REVISION_ID); InOrder inOrder = inOrder(environment, environmentRepository); inOrder.verify(environment).setActiveEnvironmentRevisionId(ENVIRONMENT_REVISION_ID); inOrder.verify(environmentRepository).updateEnvironment(environment); }
public StartDeploymentResponse startDeployment(@NonNull final StartDeploymentRequest request) throws ResourceNotFoundException, InternalServiceException { try { final EnvironmentId environmentId = apiModelMapper.toModelEnvironmentId(request.getEnvironmentId()); final Environment environment = environmentRepository.getEnvironment(environmentId); final EnvironmentRevision environmentRevision = environmentRepository.getEnvironmentRevision( environmentId, request.getEnvironmentRevisionId()); environment.setActiveEnvironmentRevisionId(environmentRevision.getEnvironmentRevisionId()); environmentRepository.updateEnvironment(environment); final String deploymentId = UUID.randomUUID().toString(); return StartDeploymentResponse.builder() .environmentId(request.getEnvironmentId()) .environmentRevisionId(request.getEnvironmentRevisionId()) .deploymentId(deploymentId) .build(); } catch (final ResourceNotFoundException | InternalServiceException e) { log.error(e.getMessage(), e); throw e; } catch (final Exception e) { log.error(e.getMessage(), e); throw new InternalServiceException(e.getMessage(), e); } }
StartDeploymentApi { public StartDeploymentResponse startDeployment(@NonNull final StartDeploymentRequest request) throws ResourceNotFoundException, InternalServiceException { try { final EnvironmentId environmentId = apiModelMapper.toModelEnvironmentId(request.getEnvironmentId()); final Environment environment = environmentRepository.getEnvironment(environmentId); final EnvironmentRevision environmentRevision = environmentRepository.getEnvironmentRevision( environmentId, request.getEnvironmentRevisionId()); environment.setActiveEnvironmentRevisionId(environmentRevision.getEnvironmentRevisionId()); environmentRepository.updateEnvironment(environment); final String deploymentId = UUID.randomUUID().toString(); return StartDeploymentResponse.builder() .environmentId(request.getEnvironmentId()) .environmentRevisionId(request.getEnvironmentRevisionId()) .deploymentId(deploymentId) .build(); } catch (final ResourceNotFoundException | InternalServiceException e) { log.error(e.getMessage(), e); throw e; } catch (final Exception e) { log.error(e.getMessage(), e); throw new InternalServiceException(e.getMessage(), e); } } }
StartDeploymentApi { public StartDeploymentResponse startDeployment(@NonNull final StartDeploymentRequest request) throws ResourceNotFoundException, InternalServiceException { try { final EnvironmentId environmentId = apiModelMapper.toModelEnvironmentId(request.getEnvironmentId()); final Environment environment = environmentRepository.getEnvironment(environmentId); final EnvironmentRevision environmentRevision = environmentRepository.getEnvironmentRevision( environmentId, request.getEnvironmentRevisionId()); environment.setActiveEnvironmentRevisionId(environmentRevision.getEnvironmentRevisionId()); environmentRepository.updateEnvironment(environment); final String deploymentId = UUID.randomUUID().toString(); return StartDeploymentResponse.builder() .environmentId(request.getEnvironmentId()) .environmentRevisionId(request.getEnvironmentRevisionId()) .deploymentId(deploymentId) .build(); } catch (final ResourceNotFoundException | InternalServiceException e) { log.error(e.getMessage(), e); throw e; } catch (final Exception e) { log.error(e.getMessage(), e); throw new InternalServiceException(e.getMessage(), e); } }  }
StartDeploymentApi { public StartDeploymentResponse startDeployment(@NonNull final StartDeploymentRequest request) throws ResourceNotFoundException, InternalServiceException { try { final EnvironmentId environmentId = apiModelMapper.toModelEnvironmentId(request.getEnvironmentId()); final Environment environment = environmentRepository.getEnvironment(environmentId); final EnvironmentRevision environmentRevision = environmentRepository.getEnvironmentRevision( environmentId, request.getEnvironmentRevisionId()); environment.setActiveEnvironmentRevisionId(environmentRevision.getEnvironmentRevisionId()); environmentRepository.updateEnvironment(environment); final String deploymentId = UUID.randomUUID().toString(); return StartDeploymentResponse.builder() .environmentId(request.getEnvironmentId()) .environmentRevisionId(request.getEnvironmentRevisionId()) .deploymentId(deploymentId) .build(); } catch (final ResourceNotFoundException | InternalServiceException e) { log.error(e.getMessage(), e); throw e; } catch (final Exception e) { log.error(e.getMessage(), e); throw new InternalServiceException(e.getMessage(), e); } }  StartDeploymentResponse startDeployment(@NonNull final StartDeploymentRequest request); }
StartDeploymentApi { public StartDeploymentResponse startDeployment(@NonNull final StartDeploymentRequest request) throws ResourceNotFoundException, InternalServiceException { try { final EnvironmentId environmentId = apiModelMapper.toModelEnvironmentId(request.getEnvironmentId()); final Environment environment = environmentRepository.getEnvironment(environmentId); final EnvironmentRevision environmentRevision = environmentRepository.getEnvironmentRevision( environmentId, request.getEnvironmentRevisionId()); environment.setActiveEnvironmentRevisionId(environmentRevision.getEnvironmentRevisionId()); environmentRepository.updateEnvironment(environment); final String deploymentId = UUID.randomUUID().toString(); return StartDeploymentResponse.builder() .environmentId(request.getEnvironmentId()) .environmentRevisionId(request.getEnvironmentRevisionId()) .deploymentId(deploymentId) .build(); } catch (final ResourceNotFoundException | InternalServiceException e) { log.error(e.getMessage(), e); throw e; } catch (final Exception e) { log.error(e.getMessage(), e); throw new InternalServiceException(e.getMessage(), e); } }  StartDeploymentResponse startDeployment(@NonNull final StartDeploymentRequest request);  }