@Test public void testGetEmrRolesFromAmazonAccount_getValidListOfRoles() { List<String> expectedEmrRoles = new ArrayList<>(); expectedEmrRoles.add( "default_role" ); expectedEmrRoles.add( "test_role" ); List<Role> emrRolesList = new ArrayList<>(); Role defaultRole = new Role(); defaultRole.setRoleName( "default_role" ); defaultRole.setAssumeRolePolicyDocument( "elasticmapreduce.amazonaws.com" ); emrRolesList.add( defaultRole ); Role testRole = new Role(); testRole.setRoleName( "test_role" ); testRole.setAssumeRolePolicyDocument( "elasticmapreduce.amazonaws.com" ); emrRolesList.add( testRole ); Role wrongRole = new Role(); wrongRole.setRoleName( "wrong_role" ); wrongRole.setAssumeRolePolicyDocument( "compute.amazonaws.com" ); emrRolesList.add( wrongRole ); Mockito.when( amazonIdentityManagement.listRoles().getRoles() ).thenReturn( emrRolesList ); AbstractModelList<String> emrRoles = aimClient.getEmrRolesFromAmazonAccount(); assertEquals( expectedEmrRoles, emrRoles ); }
@Override public AbstractModelList<String> getEmrRolesFromAmazonAccount() { List<Role> emrRolesList = aim.listRoles().getRoles(); AbstractModelList<String> emrList; emrList = emrRolesList.stream().filter( e -> e.getAssumeRolePolicyDocument().contains( "elasticmapreduce" ) ) .map( e -> e.getRoleName() ).collect( Collectors.toCollection( AbstractModelList<String>::new ) ); return emrList; }
AimClientImpl implements AimClient { @Override public AbstractModelList<String> getEmrRolesFromAmazonAccount() { List<Role> emrRolesList = aim.listRoles().getRoles(); AbstractModelList<String> emrList; emrList = emrRolesList.stream().filter( e -> e.getAssumeRolePolicyDocument().contains( "elasticmapreduce" ) ) .map( e -> e.getRoleName() ).collect( Collectors.toCollection( AbstractModelList<String>::new ) ); return emrList; } }
AimClientImpl implements AimClient { @Override public AbstractModelList<String> getEmrRolesFromAmazonAccount() { List<Role> emrRolesList = aim.listRoles().getRoles(); AbstractModelList<String> emrList; emrList = emrRolesList.stream().filter( e -> e.getAssumeRolePolicyDocument().contains( "elasticmapreduce" ) ) .map( e -> e.getRoleName() ).collect( Collectors.toCollection( AbstractModelList<String>::new ) ); return emrList; } AimClientImpl( AmazonIdentityManagement aim ); }
AimClientImpl implements AimClient { @Override public AbstractModelList<String> getEmrRolesFromAmazonAccount() { List<Role> emrRolesList = aim.listRoles().getRoles(); AbstractModelList<String> emrList; emrList = emrRolesList.stream().filter( e -> e.getAssumeRolePolicyDocument().contains( "elasticmapreduce" ) ) .map( e -> e.getRoleName() ).collect( Collectors.toCollection( AbstractModelList<String>::new ) ); return emrList; } AimClientImpl( AmazonIdentityManagement aim ); @Override AbstractModelList<String> getEc2RolesFromAmazonAccount(); @Override AbstractModelList<String> getEmrRolesFromAmazonAccount(); }
AimClientImpl implements AimClient { @Override public AbstractModelList<String> getEmrRolesFromAmazonAccount() { List<Role> emrRolesList = aim.listRoles().getRoles(); AbstractModelList<String> emrList; emrList = emrRolesList.stream().filter( e -> e.getAssumeRolePolicyDocument().contains( "elasticmapreduce" ) ) .map( e -> e.getRoleName() ).collect( Collectors.toCollection( AbstractModelList<String>::new ) ); return emrList; } AimClientImpl( AmazonIdentityManagement aim ); @Override AbstractModelList<String> getEc2RolesFromAmazonAccount(); @Override AbstractModelList<String> getEmrRolesFromAmazonAccount();  }