@Test(expected = InternalServiceException.class) public void startDeploymentInternalServiceExceptionWithUnknownException() throws Exception { when(environmentRepository.getEnvironment(environmentId)) .thenThrow(new IllegalStateException("")); api.startDeployment(request); }
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);  }