@Test public void testUpdateAppSettingsNotFound() throws AppRepositoryClientException { Application application = mockApplication(); doReturn(null).when(client).getAppByAppGroupId(MOCK_APP_TYPE, DEFAULT_USER_ID); boolean result = service.updateAppSettings(application); assertFalse(result); }
public boolean updateAppSettings(Application application) { String appType = application.getComponent(); LOGGER.info("Updating application settings: {}", appType); String sessionToken = authenticationProxy.getSessionToken(DEFAULT_USER_ID); try { Map<String, Object> app = client.getAppByAppGroupId(appType, DEFAULT_USER_ID); if (app != null) { AppEntitlement appEntitlement = new AppEntitlement(); appEntitlement.setAppId(appType); appEntitlement.setAppName(application.getName()); if (existsAppSettings(app)) { HashMap<String, Object> appSettings = createMapToAppSettings(app); if (appSettings.containsKey(ENABLED)) { appEntitlement.setEnable((Boolean) appSettings.get(ENABLED)); } if (appSettings.containsKey(VISIBLE)) { appEntitlement.setListed((Boolean) appSettings.get(VISIBLE)); } if (appSettings.containsKey(INSTALL)) { appEntitlement.setInstall((Boolean) appSettings.get(INSTALL)); } } else { appEntitlement.setEnable(application.isEnabled()); appEntitlement.setListed(application.isVisible()); appEntitlement.setInstall(application.isAutoInstall()); } appEntitlementApi.updateAppEntitlement(sessionToken, appEntitlement); return true; } else { return false; } } catch (AppRepositoryClientException | RemoteApiException e) { String message = logMessage.getMessage(FAIL_UPDATE_APP_SETTINGS, appType); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new ApplicationProvisioningException(message, e, solution); } }
ApplicationService { public boolean updateAppSettings(Application application) { String appType = application.getComponent(); LOGGER.info("Updating application settings: {}", appType); String sessionToken = authenticationProxy.getSessionToken(DEFAULT_USER_ID); try { Map<String, Object> app = client.getAppByAppGroupId(appType, DEFAULT_USER_ID); if (app != null) { AppEntitlement appEntitlement = new AppEntitlement(); appEntitlement.setAppId(appType); appEntitlement.setAppName(application.getName()); if (existsAppSettings(app)) { HashMap<String, Object> appSettings = createMapToAppSettings(app); if (appSettings.containsKey(ENABLED)) { appEntitlement.setEnable((Boolean) appSettings.get(ENABLED)); } if (appSettings.containsKey(VISIBLE)) { appEntitlement.setListed((Boolean) appSettings.get(VISIBLE)); } if (appSettings.containsKey(INSTALL)) { appEntitlement.setInstall((Boolean) appSettings.get(INSTALL)); } } else { appEntitlement.setEnable(application.isEnabled()); appEntitlement.setListed(application.isVisible()); appEntitlement.setInstall(application.isAutoInstall()); } appEntitlementApi.updateAppEntitlement(sessionToken, appEntitlement); return true; } else { return false; } } catch (AppRepositoryClientException | RemoteApiException e) { String message = logMessage.getMessage(FAIL_UPDATE_APP_SETTINGS, appType); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new ApplicationProvisioningException(message, e, solution); } } }
ApplicationService { public boolean updateAppSettings(Application application) { String appType = application.getComponent(); LOGGER.info("Updating application settings: {}", appType); String sessionToken = authenticationProxy.getSessionToken(DEFAULT_USER_ID); try { Map<String, Object> app = client.getAppByAppGroupId(appType, DEFAULT_USER_ID); if (app != null) { AppEntitlement appEntitlement = new AppEntitlement(); appEntitlement.setAppId(appType); appEntitlement.setAppName(application.getName()); if (existsAppSettings(app)) { HashMap<String, Object> appSettings = createMapToAppSettings(app); if (appSettings.containsKey(ENABLED)) { appEntitlement.setEnable((Boolean) appSettings.get(ENABLED)); } if (appSettings.containsKey(VISIBLE)) { appEntitlement.setListed((Boolean) appSettings.get(VISIBLE)); } if (appSettings.containsKey(INSTALL)) { appEntitlement.setInstall((Boolean) appSettings.get(INSTALL)); } } else { appEntitlement.setEnable(application.isEnabled()); appEntitlement.setListed(application.isVisible()); appEntitlement.setInstall(application.isAutoInstall()); } appEntitlementApi.updateAppEntitlement(sessionToken, appEntitlement); return true; } else { return false; } } catch (AppRepositoryClientException | RemoteApiException e) { String message = logMessage.getMessage(FAIL_UPDATE_APP_SETTINGS, appType); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new ApplicationProvisioningException(message, e, solution); } }  }
ApplicationService { public boolean updateAppSettings(Application application) { String appType = application.getComponent(); LOGGER.info("Updating application settings: {}", appType); String sessionToken = authenticationProxy.getSessionToken(DEFAULT_USER_ID); try { Map<String, Object> app = client.getAppByAppGroupId(appType, DEFAULT_USER_ID); if (app != null) { AppEntitlement appEntitlement = new AppEntitlement(); appEntitlement.setAppId(appType); appEntitlement.setAppName(application.getName()); if (existsAppSettings(app)) { HashMap<String, Object> appSettings = createMapToAppSettings(app); if (appSettings.containsKey(ENABLED)) { appEntitlement.setEnable((Boolean) appSettings.get(ENABLED)); } if (appSettings.containsKey(VISIBLE)) { appEntitlement.setListed((Boolean) appSettings.get(VISIBLE)); } if (appSettings.containsKey(INSTALL)) { appEntitlement.setInstall((Boolean) appSettings.get(INSTALL)); } } else { appEntitlement.setEnable(application.isEnabled()); appEntitlement.setListed(application.isVisible()); appEntitlement.setInstall(application.isAutoInstall()); } appEntitlementApi.updateAppEntitlement(sessionToken, appEntitlement); return true; } else { return false; } } catch (AppRepositoryClientException | RemoteApiException e) { String message = logMessage.getMessage(FAIL_UPDATE_APP_SETTINGS, appType); 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 boolean updateAppSettings(Application application) { String appType = application.getComponent(); LOGGER.info("Updating application settings: {}", appType); String sessionToken = authenticationProxy.getSessionToken(DEFAULT_USER_ID); try { Map<String, Object> app = client.getAppByAppGroupId(appType, DEFAULT_USER_ID); if (app != null) { AppEntitlement appEntitlement = new AppEntitlement(); appEntitlement.setAppId(appType); appEntitlement.setAppName(application.getName()); if (existsAppSettings(app)) { HashMap<String, Object> appSettings = createMapToAppSettings(app); if (appSettings.containsKey(ENABLED)) { appEntitlement.setEnable((Boolean) appSettings.get(ENABLED)); } if (appSettings.containsKey(VISIBLE)) { appEntitlement.setListed((Boolean) appSettings.get(VISIBLE)); } if (appSettings.containsKey(INSTALL)) { appEntitlement.setInstall((Boolean) appSettings.get(INSTALL)); } } else { appEntitlement.setEnable(application.isEnabled()); appEntitlement.setListed(application.isVisible()); appEntitlement.setInstall(application.isAutoInstall()); } appEntitlementApi.updateAppEntitlement(sessionToken, appEntitlement); return true; } else { return false; } } catch (AppRepositoryClientException | RemoteApiException e) { String message = logMessage.getMessage(FAIL_UPDATE_APP_SETTINGS, appType); 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);  }