@Test public void testUpdateApplicationWithEnabledAndVisible() throws AppRepositoryClientException, RemoteApiException { User user = new User(); user.setId(MOCK_USER); doReturn(user).when(userService).getUser(MOCK_APP_TYPE); Application application = mockApplication(); Map<String, Object> app = new HashMap<>(); app.put(APP_ID, MOCK_APP_TYPE); Map<String, Object> settings = new HashMap<>(); settings.put(ENABLED, Boolean.TRUE); settings.put(INSTALL, Boolean.TRUE); settings.put(VISIBLE, Boolean.TRUE); app.put(APP_SETTINGS, settings); doReturn(app).when(client).getAppByAppGroupId(MOCK_APP_TYPE, DEFAULT_USER_ID); IntegrationSettings integrationSettings = new IntegrationSettings(); integrationSettings.setOwner(MOCK_USER); when(appEntitlementApi.updateAppEntitlement(anyString(), any(AppEntitlement.class))).then(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { AppEntitlement appEntitlement = (AppEntitlement) invocationOnMock.getArguments()[1]; assertEquals(Boolean.TRUE, appEntitlement.getEnable()); assertEquals(Boolean.TRUE, appEntitlement.getListed()); assertEquals(Boolean.TRUE, appEntitlement.getInstall()); return appEntitlement; } }); service.setupApplication(integrationSettings, application); verify(client, times(1)).updateApp(any(AppStoreWrapper.class), eq(DEFAULT_USER_ID)); }
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);  }