@Test(expected = ResourceNotFoundException.class) public void testDeleteEnvironmentResourceNotFoundException() throws Exception { when(environmentRepository.getEnvironment(environmentId)).thenThrow(resourceNotFoundException); deleteEnvironmentApi.deleteEnvironment(deleteEnvironmentRequest); }
public DeleteEnvironmentResponse deleteEnvironment(@NonNull DeleteEnvironmentRequest request) throws InternalServiceException, ResourceNotFoundException { final EnvironmentId environmentId = apiModelMapper.toModelEnvironmentId(request.getEnvironmentId()); try { final Environment environment = environmentRepository.getEnvironment(environmentId); final List<EnvironmentRevision> environmentRevisions = environmentRepository.listEnvironmentRevisions(environmentId); for (final EnvironmentRevision revision : environmentRevisions) { environmentRepository.deleteEnvironmentRevision(revision); } environmentRepository.deleteEnvironment(environmentId); return DeleteEnvironmentResponse.builder() .environment(apiModelMapper.toWrapperEnvironment(environment)) .build(); } catch (InternalServiceException | ResourceNotFoundException e) { log.error(e.getMessage(), e); throw e; } catch (Exception e) { log.error(e.getMessage(), e); throw new InternalServiceException(e.getMessage(), e); } }
DeleteEnvironmentApi { public DeleteEnvironmentResponse deleteEnvironment(@NonNull DeleteEnvironmentRequest request) throws InternalServiceException, ResourceNotFoundException { final EnvironmentId environmentId = apiModelMapper.toModelEnvironmentId(request.getEnvironmentId()); try { final Environment environment = environmentRepository.getEnvironment(environmentId); final List<EnvironmentRevision> environmentRevisions = environmentRepository.listEnvironmentRevisions(environmentId); for (final EnvironmentRevision revision : environmentRevisions) { environmentRepository.deleteEnvironmentRevision(revision); } environmentRepository.deleteEnvironment(environmentId); return DeleteEnvironmentResponse.builder() .environment(apiModelMapper.toWrapperEnvironment(environment)) .build(); } catch (InternalServiceException | ResourceNotFoundException e) { log.error(e.getMessage(), e); throw e; } catch (Exception e) { log.error(e.getMessage(), e); throw new InternalServiceException(e.getMessage(), e); } } }
DeleteEnvironmentApi { public DeleteEnvironmentResponse deleteEnvironment(@NonNull DeleteEnvironmentRequest request) throws InternalServiceException, ResourceNotFoundException { final EnvironmentId environmentId = apiModelMapper.toModelEnvironmentId(request.getEnvironmentId()); try { final Environment environment = environmentRepository.getEnvironment(environmentId); final List<EnvironmentRevision> environmentRevisions = environmentRepository.listEnvironmentRevisions(environmentId); for (final EnvironmentRevision revision : environmentRevisions) { environmentRepository.deleteEnvironmentRevision(revision); } environmentRepository.deleteEnvironment(environmentId); return DeleteEnvironmentResponse.builder() .environment(apiModelMapper.toWrapperEnvironment(environment)) .build(); } catch (InternalServiceException | ResourceNotFoundException e) { log.error(e.getMessage(), e); throw e; } catch (Exception e) { log.error(e.getMessage(), e); throw new InternalServiceException(e.getMessage(), e); } }  }
DeleteEnvironmentApi { public DeleteEnvironmentResponse deleteEnvironment(@NonNull DeleteEnvironmentRequest request) throws InternalServiceException, ResourceNotFoundException { final EnvironmentId environmentId = apiModelMapper.toModelEnvironmentId(request.getEnvironmentId()); try { final Environment environment = environmentRepository.getEnvironment(environmentId); final List<EnvironmentRevision> environmentRevisions = environmentRepository.listEnvironmentRevisions(environmentId); for (final EnvironmentRevision revision : environmentRevisions) { environmentRepository.deleteEnvironmentRevision(revision); } environmentRepository.deleteEnvironment(environmentId); return DeleteEnvironmentResponse.builder() .environment(apiModelMapper.toWrapperEnvironment(environment)) .build(); } catch (InternalServiceException | ResourceNotFoundException e) { log.error(e.getMessage(), e); throw e; } catch (Exception e) { log.error(e.getMessage(), e); throw new InternalServiceException(e.getMessage(), e); } }  DeleteEnvironmentResponse deleteEnvironment(@NonNull DeleteEnvironmentRequest request); }
DeleteEnvironmentApi { public DeleteEnvironmentResponse deleteEnvironment(@NonNull DeleteEnvironmentRequest request) throws InternalServiceException, ResourceNotFoundException { final EnvironmentId environmentId = apiModelMapper.toModelEnvironmentId(request.getEnvironmentId()); try { final Environment environment = environmentRepository.getEnvironment(environmentId); final List<EnvironmentRevision> environmentRevisions = environmentRepository.listEnvironmentRevisions(environmentId); for (final EnvironmentRevision revision : environmentRevisions) { environmentRepository.deleteEnvironmentRevision(revision); } environmentRepository.deleteEnvironment(environmentId); return DeleteEnvironmentResponse.builder() .environment(apiModelMapper.toWrapperEnvironment(environment)) .build(); } catch (InternalServiceException | ResourceNotFoundException e) { log.error(e.getMessage(), e); throw e; } catch (Exception e) { log.error(e.getMessage(), e); throw new InternalServiceException(e.getMessage(), e); } }  DeleteEnvironmentResponse deleteEnvironment(@NonNull DeleteEnvironmentRequest request);  }