Commit a3b56e5f authored by anthony's avatar anthony Committed by benjaminParisel

fix(export) Resources missing in page.properties

Bonita API resource was not exported in page.properties when the API
call is for a single resource (with id)
- fix regex and enhance testtest

Covers [BS-18222](https://bonitasoft.atlassian.net/browse/BS-18222)
parent 3f9f9c54
......@@ -39,7 +39,7 @@ import org.bonitasoft.web.designer.visitor.ComponentVisitor;
public class PagePropertiesBuilder {
private static final String TEMPLATE_NAME = "page.hbs.properties";
private static final String BONITA_RESOURCE_REGEX = ".+/API/([^ /]*)/([^ /?]*)[^ /]*"; // matches ..... /API/{}/{}?...
private static final String BONITA_RESOURCE_REGEX = ".+/API/([^ /]*)/([^ /?]*)[/?]?[^ /]*"; // matches ..... /API/{}/{}?...
private TemplateEngine template;
private ComponentVisitor componentVisitor;
private AuthRulesCollector authRulesCollector;
......
......@@ -22,11 +22,7 @@ import static org.bonitasoft.web.designer.builder.ComponentBuilder.aComponent;
import static org.bonitasoft.web.designer.model.data.DataType.URL;
import static org.mockito.Mockito.when;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.*;
import com.google.common.collect.ImmutableSet;
import org.bonitasoft.web.designer.builder.WidgetBuilder;
......@@ -102,11 +98,16 @@ public class PagePropertiesBuilderTest {
@Test
public void should_add_relative_bonita_resource_found_in_page_data() throws Exception {
page.setData(singletonMap("foo", anApiData("../API/bpm/userTask?filter=mine")));
Map<String, Data> dataMap = new TreeMap<String, Data>();
dataMap.put("foo", anApiData("../API/bpm/userTask?filter=mine"));
dataMap.put("bar", anApiData("../API/identity/user/1"));
dataMap.put("other", anApiData("../API/identity/group/1?param=value"));
page.setData(dataMap);
String properties = new String(pagePropertiesBuilder.build(page));
assertThat(properties).contains("resources=[GET|bpm/userTask]");
assertThat(properties).contains("resources=[GET|identity/user, GET|bpm/userTask, GET|identity/group]");
}
@Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment