NovaLauncher extends Launcher { public static NovaContext validateCredentials(NovaCredentials novaCredentials, ContextBuilder builder) throws InvalidNovaCredentialsException { try { NovaContext context = new NovaContext(novaCredentials, builder); SecurityGroupApi securityGroupApi = context.getSecurityGroupApi(); securityGroupApi.list(); return context; } catch (AuthorizationException e) { throw new InvalidNovaCredentialsException("account-name:" + novaCredentials.getAccountName(), e); } } NovaLauncher(NovaContext novaContext, SshKeyPair sshKeyPair); static NovaContext validateCredentials(NovaCredentials novaCredentials, ContextBuilder builder); static NovaCredentials readCredentials(Confs confs); String createSecurityGroup(String clusterName, String groupName, Nova nova, Set<String> ports); boolean uploadSshPublicKey(String keyPairName, Nova nova, boolean removeOld); boolean cleanupFailedNodes(Map<NodeMetadata, Throwable> failedNodes); @Override void cleanup(JsonCluster definition, ClusterRuntime runtime); void cleanup(String clusterName, Set<String> vmIds, Set<String> vmNames, Map<String, String> groupRegion); @Override String forkGroup(JsonCluster definition, ClusterRuntime runtime, String name); @Override List<MachineRuntime> forkMachines(JsonCluster definition, ClusterRuntime runtime, String name); static Predicate<NodeMetadata> withPredicate(final Set<String> ids, final Set<String> names,
                                                      final Set<String> groupNames);  }
@Test public void validateNovaCredentialsTest() throws InvalidNovaCredentialsException { NovaContext context = NovaLauncher.validateCredentials(novaCredentials, builder); assertNotNull(context); assertNotNull(context.getSecurityGroupApi()); }
@Test(expected = InvalidNovaCredentialsException.class) public void validateNovaCredentialsTestException() throws InvalidNovaCredentialsException { when(securityGroupApi.list()).thenThrow(AuthorizationException.class); NovaContext context = NovaLauncher.validateCredentials(novaCredentials, builder); }