@Test public void testSaveFormAsset() throws Exception { Repository repository = new VFSRepository(fileSystem, producer.getIoService(), producer.getActiveFileSystems()); ((VFSRepository) repository).init(); profile.setRepository(repository); AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Text); builder.content("bpmn2 content").type("bpmn2").name("testprocess").location("/defaultPackage"); String uniqueId = repository.createAsset(builder.getAsset()); // setup parameters Map<String, String> params = new HashMap<String, String>(); params.put("uuid", uniqueId); params.put("action", "save"); params.put("profile", "jbpm"); params.put("taskname", "evaluate"); params.put("tfvalue", "this is simple task content"); TaskFormsEditorServlet taskFormsEditorServlet = new TaskFormsEditorServlet(); taskFormsEditorServlet.setProfile(profile); taskFormsEditorServlet.init(new TestServletConfig(new TestServletContext(repository))); taskFormsEditorServlet.doPost( new TestHttpServletRequest(params), new TestHttpServletResponse()); Collection<Asset> forms = repository.listAssets("/defaultPackage", new FilterByExtension("flt")); assertNotNull(forms); assertEquals(1, forms.size()); Iterator<Asset> assets = forms.iterator(); Asset asset1 = assets.next(); assertEquals("evaluate-taskform", asset1.getName()); assertEquals("/defaultPackage", asset1.getAssetLocation()); Asset<String> form1 = repository.loadAsset(asset1.getUniqueId()); assertNotNull(form1.getAssetContent()); assertEquals("this is simple task content\n", form1.getAssetContent()); }
@Test public void testLoadFormAsset() throws Exception { Repository repository = new VFSRepository(fileSystem, producer.getIoService(), producer.getActiveFileSystems()); ((VFSRepository) repository).init(); profile.setRepository(repository); AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Text); builder.content("bpmn2 content").type("bpmn2").name("testprocess").location("/defaultPackage"); String uniqueId = repository.createAsset(builder.getAsset()); AssetBuilder builderForm = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Text); builderForm .content("this is simple task content") .type("flt") .name("evaluate-taskform") .location("/defaultPackage"); String uniqueIdForm = repository.createAsset(builderForm.getAsset()); // setup parameters Map<String, String> params = new HashMap<String, String>(); params.put("uuid", uniqueId); params.put("action", "load"); params.put("profile", "jbpm"); params.put("taskname", "evaluate"); params.put("tfvalue", "this is simple task content"); TaskFormsEditorServlet taskFormsEditorServlet = new TaskFormsEditorServlet(); taskFormsEditorServlet.setProfile(profile); taskFormsEditorServlet.init(new TestServletConfig(new TestServletContext(repository))); TestHttpServletResponse response = new TestHttpServletResponse(); taskFormsEditorServlet.doPost(new TestHttpServletRequest(params), response); String formData = new String(response.getContent()); System.out.println(formData); assertEquals("this is simple task content\n", formData); }