@Test public void testCreateExternalAccount() throws ApiException { ApiExternalAccountList apiExternalAccountList = new ApiExternalAccountList(); when(clouderaManagerApiFactory.getExternalAccountsResourceApi(apiClient)).thenReturn(externalAccountsResourceApi); when(externalAccountsResourceApi.readAccounts(anyString(), anyString())).thenReturn(apiExternalAccountList); underTest.createExternalAccount("cb-altus-access", null, "ALTUS_ACCESS_KEY", new HashMap<>(), apiClient); verify(externalAccountsResourceApi, times(1)).readAccounts(anyString(), anyString()); }
public ApiExternalAccount createExternalAccount(String accountName, String displayName, String typeName, Map<String, String> configs, ApiClient client) throws ApiException { ExternalAccountsResourceApi externalAccountsResourceApi = clouderaManagerApiFactory.getExternalAccountsResourceApi(client); ApiExternalAccountList externalAccountList = externalAccountsResourceApi.readAccounts(typeName, "FULL"); boolean accountFound = false; if (externalAccountList.getItems() != null && !externalAccountList.getItems().isEmpty()) { for (ApiExternalAccount externalAccount : externalAccountList.getItems()) { if (accountName.equals(externalAccount.getName())) { accountFound = true; } } } ApiExternalAccount apiExternalAccount = new ApiExternalAccount(); apiExternalAccount.setName(accountName); apiExternalAccount.setDisplayName(displayName); apiExternalAccount.setTypeName(typeName); ApiConfigList accountConfigList = makeApiConfigList(configs); apiExternalAccount.setAccountConfigs(accountConfigList); if (!accountFound) { externalAccountsResourceApi.createAccount(apiExternalAccount); } return apiExternalAccount; }
ClouderaManagerExternalAccountService { public ApiExternalAccount createExternalAccount(String accountName, String displayName, String typeName, Map<String, String> configs, ApiClient client) throws ApiException { ExternalAccountsResourceApi externalAccountsResourceApi = clouderaManagerApiFactory.getExternalAccountsResourceApi(client); ApiExternalAccountList externalAccountList = externalAccountsResourceApi.readAccounts(typeName, "FULL"); boolean accountFound = false; if (externalAccountList.getItems() != null && !externalAccountList.getItems().isEmpty()) { for (ApiExternalAccount externalAccount : externalAccountList.getItems()) { if (accountName.equals(externalAccount.getName())) { accountFound = true; } } } ApiExternalAccount apiExternalAccount = new ApiExternalAccount(); apiExternalAccount.setName(accountName); apiExternalAccount.setDisplayName(displayName); apiExternalAccount.setTypeName(typeName); ApiConfigList accountConfigList = makeApiConfigList(configs); apiExternalAccount.setAccountConfigs(accountConfigList); if (!accountFound) { externalAccountsResourceApi.createAccount(apiExternalAccount); } return apiExternalAccount; } }
ClouderaManagerExternalAccountService { public ApiExternalAccount createExternalAccount(String accountName, String displayName, String typeName, Map<String, String> configs, ApiClient client) throws ApiException { ExternalAccountsResourceApi externalAccountsResourceApi = clouderaManagerApiFactory.getExternalAccountsResourceApi(client); ApiExternalAccountList externalAccountList = externalAccountsResourceApi.readAccounts(typeName, "FULL"); boolean accountFound = false; if (externalAccountList.getItems() != null && !externalAccountList.getItems().isEmpty()) { for (ApiExternalAccount externalAccount : externalAccountList.getItems()) { if (accountName.equals(externalAccount.getName())) { accountFound = true; } } } ApiExternalAccount apiExternalAccount = new ApiExternalAccount(); apiExternalAccount.setName(accountName); apiExternalAccount.setDisplayName(displayName); apiExternalAccount.setTypeName(typeName); ApiConfigList accountConfigList = makeApiConfigList(configs); apiExternalAccount.setAccountConfigs(accountConfigList); if (!accountFound) { externalAccountsResourceApi.createAccount(apiExternalAccount); } return apiExternalAccount; }  }
ClouderaManagerExternalAccountService { public ApiExternalAccount createExternalAccount(String accountName, String displayName, String typeName, Map<String, String> configs, ApiClient client) throws ApiException { ExternalAccountsResourceApi externalAccountsResourceApi = clouderaManagerApiFactory.getExternalAccountsResourceApi(client); ApiExternalAccountList externalAccountList = externalAccountsResourceApi.readAccounts(typeName, "FULL"); boolean accountFound = false; if (externalAccountList.getItems() != null && !externalAccountList.getItems().isEmpty()) { for (ApiExternalAccount externalAccount : externalAccountList.getItems()) { if (accountName.equals(externalAccount.getName())) { accountFound = true; } } } ApiExternalAccount apiExternalAccount = new ApiExternalAccount(); apiExternalAccount.setName(accountName); apiExternalAccount.setDisplayName(displayName); apiExternalAccount.setTypeName(typeName); ApiConfigList accountConfigList = makeApiConfigList(configs); apiExternalAccount.setAccountConfigs(accountConfigList); if (!accountFound) { externalAccountsResourceApi.createAccount(apiExternalAccount); } return apiExternalAccount; }  ApiExternalAccount createExternalAccount(String accountName, String displayName, String typeName,
            Map<String, String> configs, ApiClient client); }
ClouderaManagerExternalAccountService { public ApiExternalAccount createExternalAccount(String accountName, String displayName, String typeName, Map<String, String> configs, ApiClient client) throws ApiException { ExternalAccountsResourceApi externalAccountsResourceApi = clouderaManagerApiFactory.getExternalAccountsResourceApi(client); ApiExternalAccountList externalAccountList = externalAccountsResourceApi.readAccounts(typeName, "FULL"); boolean accountFound = false; if (externalAccountList.getItems() != null && !externalAccountList.getItems().isEmpty()) { for (ApiExternalAccount externalAccount : externalAccountList.getItems()) { if (accountName.equals(externalAccount.getName())) { accountFound = true; } } } ApiExternalAccount apiExternalAccount = new ApiExternalAccount(); apiExternalAccount.setName(accountName); apiExternalAccount.setDisplayName(displayName); apiExternalAccount.setTypeName(typeName); ApiConfigList accountConfigList = makeApiConfigList(configs); apiExternalAccount.setAccountConfigs(accountConfigList); if (!accountFound) { externalAccountsResourceApi.createAccount(apiExternalAccount); } return apiExternalAccount; }  ApiExternalAccount createExternalAccount(String accountName, String displayName, String typeName,
            Map<String, String> configs, ApiClient client);  }