@Test public void testDeleteEnvironmentInternalError() throws Exception { doThrow(AmazonServiceException.class) .when(dynamoDBMapper) .delete(any(EnvironmentDDBRecord.class), eq(SaveBehavior.CLOBBER.config())); thrown.expect(InternalServiceException.class); thrown.expectMessage( "Fail to delete environment with accountIdCluster 123456789012/mycluster and environment name myenv"); environmentRepositoryDDB.deleteEnvironment(environmentId); }
@Override public void deleteEnvironment(@NonNull final EnvironmentId environmentId) throws InternalServiceException { try { dynamoDBMapper.delete( EnvironmentDDBRecord.withKeys( environmentId.generateAccountIdCluster(), environmentId.getEnvironmentName()), SaveBehavior.CLOBBER.config()); } catch (final AmazonServiceException e) { throw new InternalServiceException( String.format( "Fail to delete environment with accountIdCluster %s and environment name %s", environmentId.generateAccountIdCluster(), environmentId.getEnvironmentName()), e); } }
EnvironmentRepositoryDDB implements EnvironmentRepository { @Override public void deleteEnvironment(@NonNull final EnvironmentId environmentId) throws InternalServiceException { try { dynamoDBMapper.delete( EnvironmentDDBRecord.withKeys( environmentId.generateAccountIdCluster(), environmentId.getEnvironmentName()), SaveBehavior.CLOBBER.config()); } catch (final AmazonServiceException e) { throw new InternalServiceException( String.format( "Fail to delete environment with accountIdCluster %s and environment name %s", environmentId.generateAccountIdCluster(), environmentId.getEnvironmentName()), e); } } }
EnvironmentRepositoryDDB implements EnvironmentRepository { @Override public void deleteEnvironment(@NonNull final EnvironmentId environmentId) throws InternalServiceException { try { dynamoDBMapper.delete( EnvironmentDDBRecord.withKeys( environmentId.generateAccountIdCluster(), environmentId.getEnvironmentName()), SaveBehavior.CLOBBER.config()); } catch (final AmazonServiceException e) { throw new InternalServiceException( String.format( "Fail to delete environment with accountIdCluster %s and environment name %s", environmentId.generateAccountIdCluster(), environmentId.getEnvironmentName()), e); } }  }
EnvironmentRepositoryDDB implements EnvironmentRepository { @Override public void deleteEnvironment(@NonNull final EnvironmentId environmentId) throws InternalServiceException { try { dynamoDBMapper.delete( EnvironmentDDBRecord.withKeys( environmentId.generateAccountIdCluster(), environmentId.getEnvironmentName()), SaveBehavior.CLOBBER.config()); } catch (final AmazonServiceException e) { throw new InternalServiceException( String.format( "Fail to delete environment with accountIdCluster %s and environment name %s", environmentId.generateAccountIdCluster(), environmentId.getEnvironmentName()), e); } }  @Override Environment createEnvironmentAndEnvironmentRevision(
      @NonNull final Environment environment,
      @NonNull final EnvironmentRevision environmentRevision); @Override Environment updateEnvironment(Environment environment); @Override EnvironmentRevision getEnvironmentRevision(
      @NonNull final EnvironmentId environmentId, @NonNull final String environmentRevisionId); EnvironmentRevision createEnvironmentRevision(
      @NonNull final EnvironmentRevision environmentRevision); @Override Environment getEnvironment(@NonNull final EnvironmentId environmentId); @Override List<Environment> listEnvironments(@NonNull final Cluster cluster); @Override List<Environment> listEnvironments(
      @NonNull final Cluster cluster, final String environmentNamePrefix); @Override List<EnvironmentRevision> listEnvironmentRevisions(
      @NonNull final EnvironmentId environmentId); @Override void deleteEnvironmentRevision(@NonNull final EnvironmentRevision environmentRevision); @Override List<Cluster> listClusters(String accountId, String clusterNamePrefix); @Override void deleteEnvironment(@NonNull final EnvironmentId environmentId); }
EnvironmentRepositoryDDB implements EnvironmentRepository { @Override public void deleteEnvironment(@NonNull final EnvironmentId environmentId) throws InternalServiceException { try { dynamoDBMapper.delete( EnvironmentDDBRecord.withKeys( environmentId.generateAccountIdCluster(), environmentId.getEnvironmentName()), SaveBehavior.CLOBBER.config()); } catch (final AmazonServiceException e) { throw new InternalServiceException( String.format( "Fail to delete environment with accountIdCluster %s and environment name %s", environmentId.generateAccountIdCluster(), environmentId.getEnvironmentName()), e); } }  @Override Environment createEnvironmentAndEnvironmentRevision(
      @NonNull final Environment environment,
      @NonNull final EnvironmentRevision environmentRevision); @Override Environment updateEnvironment(Environment environment); @Override EnvironmentRevision getEnvironmentRevision(
      @NonNull final EnvironmentId environmentId, @NonNull final String environmentRevisionId); EnvironmentRevision createEnvironmentRevision(
      @NonNull final EnvironmentRevision environmentRevision); @Override Environment getEnvironment(@NonNull final EnvironmentId environmentId); @Override List<Environment> listEnvironments(@NonNull final Cluster cluster); @Override List<Environment> listEnvironments(
      @NonNull final Cluster cluster, final String environmentNamePrefix); @Override List<EnvironmentRevision> listEnvironmentRevisions(
      @NonNull final EnvironmentId environmentId); @Override void deleteEnvironmentRevision(@NonNull final EnvironmentRevision environmentRevision); @Override List<Cluster> listClusters(String accountId, String clusterNamePrefix); @Override void deleteEnvironment(@NonNull final EnvironmentId environmentId);  }