@Test(expected = ApplicationProvisioningException.class) public void testUpdateApplicationAppRepositoryException() throws AppRepositoryClientException { IntegrationSettings settings = new IntegrationSettings(); settings.setOwner(MOCK_USER); Application application = mockApplication(); Map<String, String> app = new HashMap<>(); app.put(APP_ID, MOCK_APP_TYPE); doReturn(app).when(client).getAppByAppGroupId(MOCK_APP_TYPE, DEFAULT_USER_ID); doThrow(AppRepositoryClientException.class).when(client) .updateApp(any(AppStoreWrapper.class), eq(DEFAULT_USER_ID)); service.setupApplication(settings, application); }
public void setupApplication(IntegrationSettings settings, Application application) { String appType = application.getComponent(); LOGGER.info("Provisioning Symphony store data for application: {}", appType); if (settings.getOwner() == null) { String message = logMessage.getMessage(FAIL_GET_USER_BY_USERNAME, appType); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new UserSearchException(message, solution); } try { String domain = properties.getIntegrationBridge().getDomain(); String botUserId = settings.getOwner().toString(); AppStoreWrapper wrapper = AppStoreBuilder.build(application, domain, settings.getConfigurationId(), botUserId); Map<String, Object> app = client.getAppByAppGroupId(appType, DEFAULT_USER_ID); if (app != null) { if (app.get(APP_ID) != null) { wrapper.setId((String) app.get(APP_ID)); } if (existsAppSettings(app)) { HashMap<String, Object> appSettings = createMapToAppSettings(app); if (appSettings.containsKey(ENABLED)) { wrapper.getSettings().setEnabled((Boolean) appSettings.get(ENABLED)); } if (appSettings.containsKey(VISIBLE)) { wrapper.getSettings().setVisible((Boolean) appSettings.get(VISIBLE)); } if (appSettings.containsKey(INSTALL)) { wrapper.getSettings().setInstall((Boolean) appSettings.get(INSTALL)); } } client.updateApp(wrapper, DEFAULT_USER_ID); } else { client.createNewApp(wrapper, DEFAULT_USER_ID); } if (app == null || wrapper.getId() != null) { updateAppSettings(application); } } catch (AppRepositoryClientException | MalformedURLException e) { String message = logMessage.getMessage(FAIL_SAVE_APP, application.getId(), StringUtils.EMPTY); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new ApplicationProvisioningException(message, e, solution); } }
ApplicationService { public void setupApplication(IntegrationSettings settings, Application application) { String appType = application.getComponent(); LOGGER.info("Provisioning Symphony store data for application: {}", appType); if (settings.getOwner() == null) { String message = logMessage.getMessage(FAIL_GET_USER_BY_USERNAME, appType); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new UserSearchException(message, solution); } try { String domain = properties.getIntegrationBridge().getDomain(); String botUserId = settings.getOwner().toString(); AppStoreWrapper wrapper = AppStoreBuilder.build(application, domain, settings.getConfigurationId(), botUserId); Map<String, Object> app = client.getAppByAppGroupId(appType, DEFAULT_USER_ID); if (app != null) { if (app.get(APP_ID) != null) { wrapper.setId((String) app.get(APP_ID)); } if (existsAppSettings(app)) { HashMap<String, Object> appSettings = createMapToAppSettings(app); if (appSettings.containsKey(ENABLED)) { wrapper.getSettings().setEnabled((Boolean) appSettings.get(ENABLED)); } if (appSettings.containsKey(VISIBLE)) { wrapper.getSettings().setVisible((Boolean) appSettings.get(VISIBLE)); } if (appSettings.containsKey(INSTALL)) { wrapper.getSettings().setInstall((Boolean) appSettings.get(INSTALL)); } } client.updateApp(wrapper, DEFAULT_USER_ID); } else { client.createNewApp(wrapper, DEFAULT_USER_ID); } if (app == null || wrapper.getId() != null) { updateAppSettings(application); } } catch (AppRepositoryClientException | MalformedURLException e) { String message = logMessage.getMessage(FAIL_SAVE_APP, application.getId(), StringUtils.EMPTY); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new ApplicationProvisioningException(message, e, solution); } } }
ApplicationService { public void setupApplication(IntegrationSettings settings, Application application) { String appType = application.getComponent(); LOGGER.info("Provisioning Symphony store data for application: {}", appType); if (settings.getOwner() == null) { String message = logMessage.getMessage(FAIL_GET_USER_BY_USERNAME, appType); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new UserSearchException(message, solution); } try { String domain = properties.getIntegrationBridge().getDomain(); String botUserId = settings.getOwner().toString(); AppStoreWrapper wrapper = AppStoreBuilder.build(application, domain, settings.getConfigurationId(), botUserId); Map<String, Object> app = client.getAppByAppGroupId(appType, DEFAULT_USER_ID); if (app != null) { if (app.get(APP_ID) != null) { wrapper.setId((String) app.get(APP_ID)); } if (existsAppSettings(app)) { HashMap<String, Object> appSettings = createMapToAppSettings(app); if (appSettings.containsKey(ENABLED)) { wrapper.getSettings().setEnabled((Boolean) appSettings.get(ENABLED)); } if (appSettings.containsKey(VISIBLE)) { wrapper.getSettings().setVisible((Boolean) appSettings.get(VISIBLE)); } if (appSettings.containsKey(INSTALL)) { wrapper.getSettings().setInstall((Boolean) appSettings.get(INSTALL)); } } client.updateApp(wrapper, DEFAULT_USER_ID); } else { client.createNewApp(wrapper, DEFAULT_USER_ID); } if (app == null || wrapper.getId() != null) { updateAppSettings(application); } } catch (AppRepositoryClientException | MalformedURLException e) { String message = logMessage.getMessage(FAIL_SAVE_APP, application.getId(), StringUtils.EMPTY); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new ApplicationProvisioningException(message, e, solution); } }  }
ApplicationService { public void setupApplication(IntegrationSettings settings, Application application) { String appType = application.getComponent(); LOGGER.info("Provisioning Symphony store data for application: {}", appType); if (settings.getOwner() == null) { String message = logMessage.getMessage(FAIL_GET_USER_BY_USERNAME, appType); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new UserSearchException(message, solution); } try { String domain = properties.getIntegrationBridge().getDomain(); String botUserId = settings.getOwner().toString(); AppStoreWrapper wrapper = AppStoreBuilder.build(application, domain, settings.getConfigurationId(), botUserId); Map<String, Object> app = client.getAppByAppGroupId(appType, DEFAULT_USER_ID); if (app != null) { if (app.get(APP_ID) != null) { wrapper.setId((String) app.get(APP_ID)); } if (existsAppSettings(app)) { HashMap<String, Object> appSettings = createMapToAppSettings(app); if (appSettings.containsKey(ENABLED)) { wrapper.getSettings().setEnabled((Boolean) appSettings.get(ENABLED)); } if (appSettings.containsKey(VISIBLE)) { wrapper.getSettings().setVisible((Boolean) appSettings.get(VISIBLE)); } if (appSettings.containsKey(INSTALL)) { wrapper.getSettings().setInstall((Boolean) appSettings.get(INSTALL)); } } client.updateApp(wrapper, DEFAULT_USER_ID); } else { client.createNewApp(wrapper, DEFAULT_USER_ID); } if (app == null || wrapper.getId() != null) { updateAppSettings(application); } } catch (AppRepositoryClientException | MalformedURLException e) { String message = logMessage.getMessage(FAIL_SAVE_APP, application.getId(), StringUtils.EMPTY); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new ApplicationProvisioningException(message, e, solution); } }  @PostConstruct void init(); void setupApplication(IntegrationSettings settings, Application application); boolean updateAppSettings(Application application); }
ApplicationService { public void setupApplication(IntegrationSettings settings, Application application) { String appType = application.getComponent(); LOGGER.info("Provisioning Symphony store data for application: {}", appType); if (settings.getOwner() == null) { String message = logMessage.getMessage(FAIL_GET_USER_BY_USERNAME, appType); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new UserSearchException(message, solution); } try { String domain = properties.getIntegrationBridge().getDomain(); String botUserId = settings.getOwner().toString(); AppStoreWrapper wrapper = AppStoreBuilder.build(application, domain, settings.getConfigurationId(), botUserId); Map<String, Object> app = client.getAppByAppGroupId(appType, DEFAULT_USER_ID); if (app != null) { if (app.get(APP_ID) != null) { wrapper.setId((String) app.get(APP_ID)); } if (existsAppSettings(app)) { HashMap<String, Object> appSettings = createMapToAppSettings(app); if (appSettings.containsKey(ENABLED)) { wrapper.getSettings().setEnabled((Boolean) appSettings.get(ENABLED)); } if (appSettings.containsKey(VISIBLE)) { wrapper.getSettings().setVisible((Boolean) appSettings.get(VISIBLE)); } if (appSettings.containsKey(INSTALL)) { wrapper.getSettings().setInstall((Boolean) appSettings.get(INSTALL)); } } client.updateApp(wrapper, DEFAULT_USER_ID); } else { client.createNewApp(wrapper, DEFAULT_USER_ID); } if (app == null || wrapper.getId() != null) { updateAppSettings(application); } } catch (AppRepositoryClientException | MalformedURLException e) { String message = logMessage.getMessage(FAIL_SAVE_APP, application.getId(), StringUtils.EMPTY); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new ApplicationProvisioningException(message, e, solution); } }  @PostConstruct void init(); void setupApplication(IntegrationSettings settings, Application application); boolean updateAppSettings(Application application);  }