ParamSegment paramSegment = (ParamSegment)segment;
assertEquals(paramSegment.getParamName(), "id");
assertEquals(paramSegment.getMetaPattern().toString(), "[0-9]*:abba");
MetaPattern metaPattern = paramSegment.getMetaPattern();
assertTrue(metaPattern.matcher("1:abba").matches());
assertTrue(metaPattern.matcher("1234521:abba").matches());
assertTrue(metaPattern.matcher(":abba").matches());
String segmentMultiParam = "{segment0}asegment{segment1:^\\(?\\d{3}\\)?[ -]?\\d{3}[ -]?\\d{4}$}anotherseg";
segment = AbstractURLSegment.newSegment(segmentMultiParam);
assertTrue(segment instanceof MultiParamSegment);
MultiParamSegment multiParamSegment = (MultiParamSegment)segment;
List<AbstractURLSegment> subSegments = multiParamSegment.getSubSegments();
assertEquals(4, subSegments.size());
metaPattern = subSegments.get(2).getMetaPattern();
assertEquals(metaPattern.toString(), "^\\(?\\d{3}\\)?[ -]?\\d{3}[ -]?\\d{4}$");
segmentMultiParam = "filename-{symbolicName:[a-z]+}-{version:\\d\\.\\d\\.\\d}{extension:\\.[a-z]+}";
segment = AbstractURLSegment.newSegment(segmentMultiParam);
multiParamSegment = (MultiParamSegment)segment;
metaPattern = multiParamSegment.getMetaPatternWithGroups();
String fileName = "filename-gsaon-1.2.3.zip";
Matcher matcher = metaPattern.matcher(fileName);
assertTrue(matcher.matches());
// testing segment parsing with regular expressions
assertEquals("gsaon", matcher.group(1));
assertEquals("1.2.3", matcher.group(2));
assertEquals(".zip", matcher.group(3));
matcher = metaPattern.matcher("gsaon-1.2.3.zip");
assertFalse(matcher.matches());