Java Code Examples for org.jboss.forge.furnace.versions.Versions#parseVersionRange()
The following examples show how to use
org.jboss.forge.furnace.versions.Versions#parseVersionRange() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetadataTechnologyHandler.java From windup with Eclipse Public License 1.0 | 6 votes |
@Override public TechnologyReference processElement(ParserContext handlerManager, Element element) throws ConfigurationException { String id = element.getAttribute(ID); String versionRangeString = element.getAttribute(VERSION_RANGE); if (StringUtils.isBlank(id)) { throw new WindupXMLRulesetParsingException("The '" + element.getTagName() + "' element must have a non-empty '" + ID + "' attribute"); } VersionRange versionRange = null; if (StringUtils.isNotBlank(versionRangeString)) { try { versionRange = Versions.parseVersionRange(versionRangeString); } catch (VersionException ex) { throw new WindupXMLRulesetParsingException("The '" + VERSION_RANGE + "' attribute with value \"" + versionRangeString + "\" in the element " + element.getTagName() + " is not a valid version", ex); } } return new TechnologyReference(id, versionRange); }
Example 2
Source File: TechnologyReferenceTransformerHandlerTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testXmlParsinfOfRulesetMetadata() throws Exception { File fXmlFile = new File(XML_FILE); RuleLoaderContext loaderContext = new RuleLoaderContext(Collections.singleton(fXmlFile.toPath()), null); ParserContext parser = new ParserContext(furnace, loaderContext); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); dbFactory.setNamespaceAware(true); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document firstXmlFile = dBuilder.parse(fXmlFile); List<TechnologyReferenceTransformer> transformers = parser.processElement(firstXmlFile.getDocumentElement()); // verify xmlfile Assert.assertEquals(2, transformers.size()); Assert.assertEquals("sampleinput1", transformers.get(0).getOriginal().getId()); Assert.assertEquals("[1]", transformers.get(0).getOriginal().getVersionRange().toString()); Assert.assertEquals("sampleoutput2", transformers.get(0).getTarget().getId()); Assert.assertEquals("[2]", transformers.get(0).getTarget().getVersionRange().toString()); TechnologyReference input1 = new TechnologyReference("sampleinput1", Versions.parseVersionRange("[1]")); TechnologyReference output2 = transformers.get(0).transform(input1); Assert.assertEquals("sampleoutput2", output2.getId()); Assert.assertEquals("[2]", output2.getVersionRange().toString()); Assert.assertEquals("sampleinput3", transformers.get(1).getOriginal().getId()); Assert.assertEquals("[3]", transformers.get(1).getOriginal().getVersionRange().toString()); Assert.assertEquals("sampleoutput4", transformers.get(1).getTarget().getId()); Assert.assertEquals("[4]", transformers.get(1).getTarget().getVersionRange().toString()); }
Example 3
Source File: TechnologyReference.java From windup with Eclipse Public License 1.0 | 5 votes |
/** * Construct a new {@link TechnologyReference} using the given {@link String} ID and {@link String} version range. */ public TechnologyReference(String id, String versionRange) { this.id = id; if (versionRange != null) this.versionRange = Versions.parseVersionRange(versionRange); }
Example 4
Source File: TechnologyReference.java From windup with Eclipse Public License 1.0 | 5 votes |
/** * Parses a {@link TechnologyReference} from a string that is formatted as either * "id" or "id:versionRange". */ public static TechnologyReference parseFromIDAndVersion(String idAndVersion) { if (idAndVersion.contains(":")) { String tech = StringUtils.substringBefore(idAndVersion, ":"); String versionRangeString = StringUtils.substringAfter(idAndVersion, ":"); if (!versionRangeString.matches("^[(\\[].*[)\\]]")) versionRangeString = "[" + versionRangeString + "]"; VersionRange versionRange = Versions.parseVersionRange(versionRangeString); return new TechnologyReference(tech, versionRange); } return new TechnologyReference(idAndVersion); }
Example 5
Source File: TechnologyReferenceTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testVersionRangeIntersectionSimple() { VersionRange versionRange1 = Versions.parseVersionRange("(10,20)"); VersionRange versionRange2 = Versions.parseVersionRange("(12,17]"); TechnologyReference technologyReference = new TechnologyReference("tech", versionRange1); boolean overlap = technologyReference.versionRangesOverlap(versionRange2); Assert.assertTrue(overlap); }
Example 6
Source File: TechnologyReferenceTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testVersionRangeIntersectionSimpleExclusiveBegin() { VersionRange versionRange1 = Versions.parseVersionRange("[10,20)"); VersionRange versionRange2 = Versions.parseVersionRange("[10,17]"); TechnologyReference technologyReference = new TechnologyReference("tech", versionRange1); boolean overlap = technologyReference.versionRangesOverlap(versionRange2); Assert.assertTrue(overlap); }
Example 7
Source File: TechnologyReferenceTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testVersionRangeIntersectionSingleVersionExclusiveBegin() { VersionRange versionRange1 = Versions.parseVersionRange("[10]"); VersionRange versionRange2 = Versions.parseVersionRange("(10,17]"); TechnologyReference technologyReference = new TechnologyReference("tech", versionRange1); boolean overlap = technologyReference.versionRangesOverlap(versionRange2); Assert.assertFalse(overlap); }
Example 8
Source File: TechnologyReferenceTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testVersionRangeIntersectionSingleVersionInclusiveBegin() { VersionRange versionRange1 = Versions.parseVersionRange("[10]"); VersionRange versionRange2 = Versions.parseVersionRange("[10,17]"); TechnologyReference technologyReference = new TechnologyReference("tech", versionRange1); boolean overlap = technologyReference.versionRangesOverlap(versionRange2); Assert.assertTrue(overlap); }
Example 9
Source File: TechnologyReferenceTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testVersionRangeIntersectionSimpleNoOverlap() { VersionRange versionRange1 = Versions.parseVersionRange("(10,20)"); VersionRange versionRange2 = Versions.parseVersionRange("(8,9]"); TechnologyReference technologyReference = new TechnologyReference("tech", versionRange1); boolean overlap = technologyReference.versionRangesOverlap(versionRange2); Assert.assertFalse(overlap); }
Example 10
Source File: TechnologyReferenceTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testVersionPartialOverlapAcrossMax() { VersionRange versionRange1 = Versions.parseVersionRange("(10,20)"); VersionRange versionRange2 = Versions.parseVersionRange("(18,22)"); TechnologyReference technologyReference = new TechnologyReference("tech", versionRange1); boolean overlap = technologyReference.versionRangesOverlap(versionRange2); Assert.assertTrue(overlap); }
Example 11
Source File: TechnologyReferenceTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testVersionPartialOverlapAcrossMaxReverse() { VersionRange versionRange1 = Versions.parseVersionRange("(10,20)"); VersionRange versionRange2 = Versions.parseVersionRange("(18,22)"); TechnologyReference technologyReference = new TechnologyReference("tech", versionRange2); boolean overlap = technologyReference.versionRangesOverlap(versionRange1); Assert.assertTrue(overlap); }
Example 12
Source File: TechnologyReferenceTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testVersionPartialOverlapAcrossMin() { VersionRange versionRange1 = Versions.parseVersionRange("(10,20)"); VersionRange versionRange2 = Versions.parseVersionRange("(7,13)"); TechnologyReference technologyReference = new TechnologyReference("tech", versionRange1); boolean overlap = technologyReference.versionRangesOverlap(versionRange2); Assert.assertTrue(overlap); }
Example 13
Source File: TechnologyReferenceTest.java From windup with Eclipse Public License 1.0 | 5 votes |
@Test public void testVersionPartialOverlapAcrossMinReverse() { VersionRange versionRange1 = Versions.parseVersionRange("(10,20)"); VersionRange versionRange2 = Versions.parseVersionRange("(7,13)"); TechnologyReference technologyReference = new TechnologyReference("tech", versionRange1); boolean overlap = technologyReference.versionRangesOverlap(versionRange2); Assert.assertTrue(overlap); }