use of org.fagu.fmv.soft.find.info.VersionDateSoftInfo 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.info.VersionDateSoftInfo 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.info.VersionDateSoftInfo in project fmv by f-agu.
the class SoftInfoContributor method content.
// *********************************************
/**
* @return
*/
private Map<String, String> content() {
Map<String, String> map = new HashMap<>();
for (Soft soft : Softs.getInfoContributors()) {
String msg = null;
if (soft.isFound()) {
StringBuilder buf = new StringBuilder(100);
SoftInfo softInfo = soft.getFirstInfo();
if (softInfo instanceof VersionSoftInfo) {
((VersionSoftInfo) softInfo).getVersion().ifPresent(v -> buf.append(v).append(", "));
}
if (softInfo instanceof VersionDateSoftInfo) {
((VersionDateSoftInfo) softInfo).getDate().ifPresent(d -> {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
buf.append(dateFormat.format(d)).append(", ");
});
}
buf.append(soft.getFile().getAbsolutePath());
msg = buf.toString();
} else {
StringJoiner joiner = new StringJoiner(" ; ");
for (SoftFound softFound : soft.getFounds()) {
StringBuilder buf = new StringBuilder();
FoundReason foundReason = softFound != null ? softFound.getFoundReason() : FoundReasons.NOT_FOUND;
buf.append(foundReason.name());
String reason = softFound.getReason();
if (reason != null) {
buf.append(": ").append(reason);
}
joiner.add(buf.toString());
}
msg = joiner.toString();
}
map.put(soft.getName(), msg);
}
return map;
}
Aggregations