@Test public void testGetEnvironmentRevision() throws Exception { when(dynamoDBMapper.load( EnvironmentRevisionDDBRecord.class, environmentId.generateAccountIdClusterEnvironmentName(), ENVIRONMENT_REVISION_ID)) .thenReturn(environmentRevisionDDBRecord); when(environmentMapper.toEnvironmentRevision(environmentRevisionDDBRecord)) .thenReturn(environmentRevision); final EnvironmentRevision result = environmentRepositoryDDB.getEnvironmentRevision(environmentId, ENVIRONMENT_REVISION_ID); verify(dynamoDBMapper) .load( EnvironmentRevisionDDBRecord.class, environmentId.generateAccountIdClusterEnvironmentName(), ENVIRONMENT_REVISION_ID); verify(environmentMapper).toEnvironmentRevision(environmentRevisionDDBRecord); assertThat(result).isEqualTo(environmentRevision); }
@Override public EnvironmentRevision getEnvironmentRevision( @NonNull final EnvironmentId environmentId, @NonNull final String environmentRevisionId) throws ResourceNotFoundException, InternalServiceException { final String accountIdClusterEnvironmentName = environmentId.generateAccountIdClusterEnvironmentName(); try { final EnvironmentRevisionDDBRecord environmentRevisionRecord = dynamoDBMapper.load( EnvironmentRevisionDDBRecord.class, accountIdClusterEnvironmentName, environmentRevisionId); if (environmentRevisionRecord == null) { throw new ResourceNotFoundException( ResourceType.ENVIRONMENT_REVISION, environmentRevisionId); } return environmentMapper.toEnvironmentRevision(environmentRevisionRecord); } catch (final AmazonServiceException e) { throw new InternalServiceException( String.format( "Could not load record with environment revision key %s and environment revision id %s", accountIdClusterEnvironmentName, environmentRevisionId), e); } }
EnvironmentRepositoryDDB implements EnvironmentRepository { @Override public EnvironmentRevision getEnvironmentRevision( @NonNull final EnvironmentId environmentId, @NonNull final String environmentRevisionId) throws ResourceNotFoundException, InternalServiceException { final String accountIdClusterEnvironmentName = environmentId.generateAccountIdClusterEnvironmentName(); try { final EnvironmentRevisionDDBRecord environmentRevisionRecord = dynamoDBMapper.load( EnvironmentRevisionDDBRecord.class, accountIdClusterEnvironmentName, environmentRevisionId); if (environmentRevisionRecord == null) { throw new ResourceNotFoundException( ResourceType.ENVIRONMENT_REVISION, environmentRevisionId); } return environmentMapper.toEnvironmentRevision(environmentRevisionRecord); } catch (final AmazonServiceException e) { throw new InternalServiceException( String.format( "Could not load record with environment revision key %s and environment revision id %s", accountIdClusterEnvironmentName, environmentRevisionId), e); } } }
EnvironmentRepositoryDDB implements EnvironmentRepository { @Override public EnvironmentRevision getEnvironmentRevision( @NonNull final EnvironmentId environmentId, @NonNull final String environmentRevisionId) throws ResourceNotFoundException, InternalServiceException { final String accountIdClusterEnvironmentName = environmentId.generateAccountIdClusterEnvironmentName(); try { final EnvironmentRevisionDDBRecord environmentRevisionRecord = dynamoDBMapper.load( EnvironmentRevisionDDBRecord.class, accountIdClusterEnvironmentName, environmentRevisionId); if (environmentRevisionRecord == null) { throw new ResourceNotFoundException( ResourceType.ENVIRONMENT_REVISION, environmentRevisionId); } return environmentMapper.toEnvironmentRevision(environmentRevisionRecord); } catch (final AmazonServiceException e) { throw new InternalServiceException( String.format( "Could not load record with environment revision key %s and environment revision id %s", accountIdClusterEnvironmentName, environmentRevisionId), e); } }  }
EnvironmentRepositoryDDB implements EnvironmentRepository { @Override public EnvironmentRevision getEnvironmentRevision( @NonNull final EnvironmentId environmentId, @NonNull final String environmentRevisionId) throws ResourceNotFoundException, InternalServiceException { final String accountIdClusterEnvironmentName = environmentId.generateAccountIdClusterEnvironmentName(); try { final EnvironmentRevisionDDBRecord environmentRevisionRecord = dynamoDBMapper.load( EnvironmentRevisionDDBRecord.class, accountIdClusterEnvironmentName, environmentRevisionId); if (environmentRevisionRecord == null) { throw new ResourceNotFoundException( ResourceType.ENVIRONMENT_REVISION, environmentRevisionId); } return environmentMapper.toEnvironmentRevision(environmentRevisionRecord); } catch (final AmazonServiceException e) { throw new InternalServiceException( String.format( "Could not load record with environment revision key %s and environment revision id %s", accountIdClusterEnvironmentName, environmentRevisionId), 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 EnvironmentRevision getEnvironmentRevision( @NonNull final EnvironmentId environmentId, @NonNull final String environmentRevisionId) throws ResourceNotFoundException, InternalServiceException { final String accountIdClusterEnvironmentName = environmentId.generateAccountIdClusterEnvironmentName(); try { final EnvironmentRevisionDDBRecord environmentRevisionRecord = dynamoDBMapper.load( EnvironmentRevisionDDBRecord.class, accountIdClusterEnvironmentName, environmentRevisionId); if (environmentRevisionRecord == null) { throw new ResourceNotFoundException( ResourceType.ENVIRONMENT_REVISION, environmentRevisionId); } return environmentMapper.toEnvironmentRevision(environmentRevisionRecord); } catch (final AmazonServiceException e) { throw new InternalServiceException( String.format( "Could not load record with environment revision key %s and environment revision id %s", accountIdClusterEnvironmentName, environmentRevisionId), 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);  }