use of org.fagu.fmv.soft.find.SoftFound in project fmv by f-agu.
the class FFSoftProvider method createParser.
// ***********************************************************************
/**
* @param file
* @return
*/
Parser createParser(File file) {
return new Parser() {
private static final String CONFIGURATION_START_PATTERN = "configuration:";
private Version version = null;
private Date builtDate = null;
// configuration
private Set<String> configuration = null;
// lib versions
private Map<String, Version> libVersions = new HashMap<>();
private SoftFound softFound;
@Override
public void readLine(final String lineIn) {
if (StringUtils.isBlank(lineIn) || softFound != null) {
return;
}
String line = lineIn.trim();
// version
Matcher matcher = FF_FIRSTLINE_PATTERN.matcher(line);
if (matcher.matches()) {
String parsedTool = matcher.group(1).trim();
if (parsedTool.equalsIgnoreCase(getName())) {
version = getVersion(matcher.group(2).trim());
return;
}
softFound = SoftFound.foundError(file, "Wrong tool, need " + getName() + " and found " + parsedTool + ": " + line);
}
// configuration
if (line.startsWith(CONFIGURATION_START_PATTERN)) {
configuration = getConfiguration(StringUtils.substringAfter(line, CONFIGURATION_START_PATTERN).trim());
return;
}
// built
matcher = BUILD_PATTERN.matcher(line);
if (matcher.matches()) {
builtDate = getBuiltDate(matcher);
return;
}
// lib versions
matcher = LIBVERSION_PATTERN.matcher(line);
if (matcher.matches()) {
addLibVersions(libVersions, matcher);
}
}
@Override
public SoftFound closeAndParse(String cmdLineStr, int exitValue) throws IOException {
if (softFound != null) {
return softFound;
}
Integer builtVersion = null;
if (version != null && version.size() == 1) {
final int minBuildVersion = 100;
int major = version.getFieldValue(VersionUnit.VF_0_MAJOR, 0);
// N-70767-gd24af70
if (major > minBuildVersion) {
builtVersion = major;
version = null;
}
}
FFInfo ffInfo = new FFInfo(file, version, getName(), builtDate, builtVersion, configuration, libVersions);
return FFSoftPolicy.toSoftFound(ffInfo);
}
};
}
use of org.fagu.fmv.soft.find.SoftFound in project fmv by f-agu.
the class ConvertSoftProviderTestCase method test.
@Test
@Ignore
public void test() {
Soft soft = Convert.search();
for (SoftFound softFound : soft.getFounds()) {
System.out.println(softFound.getLocalizedBy());
System.out.println(softFound + " / " + softFound.getReason());
System.out.println();
}
}
use of org.fagu.fmv.soft.find.SoftFound in project fmv by f-agu.
the class IMInfoTestCase method assertInfo.
/**
* @param firstLine
* @param expectedVersion
* @param expectedDate
* @param expectedInfo
* @throws IOException
*/
private void assertInfo(Parser parser, Version expectedVersion, Date expectedDate, String expectedInfo) throws IOException {
SoftFound softFound = parser.closeAndParse("", 0);
VersionDateSoftInfo imInfo = (VersionDateSoftInfo) softFound.getSoftInfo();
assertEquals(expectedVersion, imInfo.getVersion().orElse(null));
assertEquals(expectedDate, imInfo.getDate().orElse(null));
assertEquals(expectedInfo, imInfo.getInfo());
}
use of org.fagu.fmv.soft.find.SoftFound in project fmv by f-agu.
the class GSSoftProviderTestCase method assertInfo.
/**
* @param parser
* @param expectedVersion
* @param expectedDate
* @throws IOException
*/
private void assertInfo(Parser parser, Version expectedVersion, Date expectedDate) throws IOException {
SoftFound softFound = parser.closeAndParse("", 0);
VersionDateSoftInfo softInfo = (VersionDateSoftInfo) softFound.getSoftInfo();
assertEquals(expectedVersion, softInfo.getVersion().orElse(null));
assertEquals(expectedDate, softInfo.getDate().orElse(null));
}
use of org.fagu.fmv.soft.find.SoftFound in project fmv by f-agu.
the class JavaSoftProviderTestCase method assertInfo.
/**
* @param parser
* @param expectedVersion
* @throws IOException
*/
private void assertInfo(Parser parser, Version expectedVersion) throws IOException {
SoftFound softFound = parser.closeAndParse("", 0);
VersionSoftInfo softInfo = (VersionSoftInfo) softFound.getSoftInfo();
assertEquals(expectedVersion, softInfo.getVersion().orElse(null));
}
Aggregations