@Test void testConfigureApp() { when(appFactory.create()).thenReturn(app); AppConfig appConfig = mock(AppConfig.class); when(appConfig.getLabel()).thenReturn("test-app"); when(appConfig.getDescription()).thenReturn("Test app description"); when(appConfig.getIncludeMenuAndFooter()).thenReturn(true); when(appConfig.getVersion()).thenReturn("1.0"); when(appConfig.getName()).thenReturn("app1"); when(appConfig.getApiDependency()).thenReturn("v2.0"); appManagerServiceImpl.configureApp(appConfig, "<h1>Test</h1>"); verify(dataService).add(AppMetadata.APP, app); }
@Override @Transactional public void configureApp(AppConfig appConfig, String htmlTemplate) { String appDirName = APPS_DIR + separator + appConfig.getName(); Map<String, Object> runtimeOptions = appConfig.getRuntimeOptions(); if (runtimeOptions == null) { runtimeOptions = Maps.newHashMap(); } App newApp = appFactory.create(); newApp.setLabel(appConfig.getLabel()); newApp.setDescription(appConfig.getDescription()); newApp.setAppVersion(appConfig.getVersion()); newApp.setApiDependency(appConfig.getApiDependency()); newApp.setTemplateContent(htmlTemplate); newApp.setActive(false); newApp.setIncludeMenuAndFooter(appConfig.getIncludeMenuAndFooter()); newApp.setResourceFolder(appDirName); newApp.setAppConfig(gson.toJson(runtimeOptions)); newApp.setName(appConfig.getName()); dataService.add(AppMetadata.APP, newApp); }
AppManagerServiceImpl implements AppManagerService { @Override @Transactional public void configureApp(AppConfig appConfig, String htmlTemplate) { String appDirName = APPS_DIR + separator + appConfig.getName(); Map<String, Object> runtimeOptions = appConfig.getRuntimeOptions(); if (runtimeOptions == null) { runtimeOptions = Maps.newHashMap(); } App newApp = appFactory.create(); newApp.setLabel(appConfig.getLabel()); newApp.setDescription(appConfig.getDescription()); newApp.setAppVersion(appConfig.getVersion()); newApp.setApiDependency(appConfig.getApiDependency()); newApp.setTemplateContent(htmlTemplate); newApp.setActive(false); newApp.setIncludeMenuAndFooter(appConfig.getIncludeMenuAndFooter()); newApp.setResourceFolder(appDirName); newApp.setAppConfig(gson.toJson(runtimeOptions)); newApp.setName(appConfig.getName()); dataService.add(AppMetadata.APP, newApp); } }
AppManagerServiceImpl implements AppManagerService { @Override @Transactional public void configureApp(AppConfig appConfig, String htmlTemplate) { String appDirName = APPS_DIR + separator + appConfig.getName(); Map<String, Object> runtimeOptions = appConfig.getRuntimeOptions(); if (runtimeOptions == null) { runtimeOptions = Maps.newHashMap(); } App newApp = appFactory.create(); newApp.setLabel(appConfig.getLabel()); newApp.setDescription(appConfig.getDescription()); newApp.setAppVersion(appConfig.getVersion()); newApp.setApiDependency(appConfig.getApiDependency()); newApp.setTemplateContent(htmlTemplate); newApp.setActive(false); newApp.setIncludeMenuAndFooter(appConfig.getIncludeMenuAndFooter()); newApp.setResourceFolder(appDirName); newApp.setAppConfig(gson.toJson(runtimeOptions)); newApp.setName(appConfig.getName()); dataService.add(AppMetadata.APP, newApp); } AppManagerServiceImpl(
      AppFactory appFactory,
      DataService dataService,
      FileStore fileStore,
      Gson gson,
      PluginFactory pluginFactory); }
AppManagerServiceImpl implements AppManagerService { @Override @Transactional public void configureApp(AppConfig appConfig, String htmlTemplate) { String appDirName = APPS_DIR + separator + appConfig.getName(); Map<String, Object> runtimeOptions = appConfig.getRuntimeOptions(); if (runtimeOptions == null) { runtimeOptions = Maps.newHashMap(); } App newApp = appFactory.create(); newApp.setLabel(appConfig.getLabel()); newApp.setDescription(appConfig.getDescription()); newApp.setAppVersion(appConfig.getVersion()); newApp.setApiDependency(appConfig.getApiDependency()); newApp.setTemplateContent(htmlTemplate); newApp.setActive(false); newApp.setIncludeMenuAndFooter(appConfig.getIncludeMenuAndFooter()); newApp.setResourceFolder(appDirName); newApp.setAppConfig(gson.toJson(runtimeOptions)); newApp.setName(appConfig.getName()); dataService.add(AppMetadata.APP, newApp); } AppManagerServiceImpl(
      AppFactory appFactory,
      DataService dataService,
      FileStore fileStore,
      Gson gson,
      PluginFactory pluginFactory); @Override List<AppResponse> getApps(); @Override AppResponse getAppByName(String appName); @Override @Transactional void activateApp(App app); @Override @Transactional void deactivateApp(App app); @Override @Transactional void deleteApp(String id); @Override String uploadApp(InputStream zipData, String zipFileName, String formFieldName); @Override AppConfig checkAndObtainConfig(String tempDir, String configContent); @Override @Transactional void configureApp(AppConfig appConfig, String htmlTemplate); @Override String extractFileContent(String appDir, String fileName); }
AppManagerServiceImpl implements AppManagerService { @Override @Transactional public void configureApp(AppConfig appConfig, String htmlTemplate) { String appDirName = APPS_DIR + separator + appConfig.getName(); Map<String, Object> runtimeOptions = appConfig.getRuntimeOptions(); if (runtimeOptions == null) { runtimeOptions = Maps.newHashMap(); } App newApp = appFactory.create(); newApp.setLabel(appConfig.getLabel()); newApp.setDescription(appConfig.getDescription()); newApp.setAppVersion(appConfig.getVersion()); newApp.setApiDependency(appConfig.getApiDependency()); newApp.setTemplateContent(htmlTemplate); newApp.setActive(false); newApp.setIncludeMenuAndFooter(appConfig.getIncludeMenuAndFooter()); newApp.setResourceFolder(appDirName); newApp.setAppConfig(gson.toJson(runtimeOptions)); newApp.setName(appConfig.getName()); dataService.add(AppMetadata.APP, newApp); } AppManagerServiceImpl(
      AppFactory appFactory,
      DataService dataService,
      FileStore fileStore,
      Gson gson,
      PluginFactory pluginFactory); @Override List<AppResponse> getApps(); @Override AppResponse getAppByName(String appName); @Override @Transactional void activateApp(App app); @Override @Transactional void deactivateApp(App app); @Override @Transactional void deleteApp(String id); @Override String uploadApp(InputStream zipData, String zipFileName, String formFieldName); @Override AppConfig checkAndObtainConfig(String tempDir, String configContent); @Override @Transactional void configureApp(AppConfig appConfig, String htmlTemplate); @Override String extractFileContent(String appDir, String fileName); static final String APPS_DIR; static final String ZIP_INDEX_FILE; static final String ZIP_CONFIG_FILE; static final String APP_PLUGIN_ROOT; }