Search in sources :

Example 1 with VersionDateSoftInfo

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());
}
Also used : SoftFound(org.fagu.fmv.soft.find.SoftFound) VersionDateSoftInfo(org.fagu.fmv.soft.find.info.VersionDateSoftInfo)

Example 2 with VersionDateSoftInfo

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));
}
Also used : SoftFound(org.fagu.fmv.soft.find.SoftFound) VersionDateSoftInfo(org.fagu.fmv.soft.find.info.VersionDateSoftInfo)

Example 3 with VersionDateSoftInfo

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;
}
Also used : VersionSoftInfo(org.fagu.fmv.soft.find.info.VersionSoftInfo) SoftInfo(org.fagu.fmv.soft.find.SoftInfo) VersionDateSoftInfo(org.fagu.fmv.soft.find.info.VersionDateSoftInfo) VersionSoftInfo(org.fagu.fmv.soft.find.info.VersionSoftInfo) FoundReason(org.fagu.fmv.soft.find.FoundReason) HashMap(java.util.HashMap) SoftFound(org.fagu.fmv.soft.find.SoftFound) VersionDateSoftInfo(org.fagu.fmv.soft.find.info.VersionDateSoftInfo) Soft(org.fagu.fmv.soft.Soft) SimpleDateFormat(java.text.SimpleDateFormat) StringJoiner(java.util.StringJoiner)

Aggregations

SoftFound (org.fagu.fmv.soft.find.SoftFound)3 VersionDateSoftInfo (org.fagu.fmv.soft.find.info.VersionDateSoftInfo)3 SimpleDateFormat (java.text.SimpleDateFormat)1 HashMap (java.util.HashMap)1 StringJoiner (java.util.StringJoiner)1 Soft (org.fagu.fmv.soft.Soft)1 FoundReason (org.fagu.fmv.soft.find.FoundReason)1 SoftInfo (org.fagu.fmv.soft.find.SoftInfo)1 VersionSoftInfo (org.fagu.fmv.soft.find.info.VersionSoftInfo)1