### Question:
MetricWriter { public static boolean fileNameMatches(String fileName, String baseFileName) { if (fileName.startsWith(baseFileName)) { String part = fileName.substring(baseFileName.length()); return part.matches("\\.[0-9]{4}-[0-9]{2}-[0-9]{2}(\\.[0-9]*)?"); } else { return false; } } MetricWriter(long singleFileSize);  MetricWriter(long singleFileSize, int totalFileCount); synchronized void write(long time, List<MetricNode> nodes); synchronized void close(); static boolean fileNameMatches(String fileName, String baseFileName); static String formMetricFileName(String appName, int pid); static String formIndexFileName(String metricFileName); static final String METRIC_BASE_DIR; static final String METRIC_FILE; static final String METRIC_FILE_INDEX_SUFFIX; static final Comparator<String> METRIC_FILE_NAME_CMP; }### Answer:
@Test public void testFileNameMatches(){ String baseFileName = "Sentinel-SDK-Demo-metrics.log"; String fileName = "Sentinel-SDK-Demo-metrics.log.2018-03-06"; assertTrue(MetricWriter.fileNameMatches(fileName, baseFileName)); String baseFileName2 = "Sentinel-Admin-metrics.log.pid22568"; String fileName2 = "Sentinel-Admin-metrics.log.pid22568.2018-12-24"; assertTrue(MetricWriter.fileNameMatches(fileName2, baseFileName2)); String baseFileName3 = "Sentinel-SDK-Demo-metrics.log"; String fileName3 = "Sentinel-SDK-Demo-metrics.log.2018-03-06.11"; assertTrue(MetricWriter.fileNameMatches(fileName3, baseFileName3)); String baseFileName4 = "Sentinel-SDK-Demo-metrics.log"; String fileName4 = "Sentinel-SDK-Demo-metrics.log.XXX.2018-03-06.11"; assertFalse(MetricWriter.fileNameMatches(fileName4, baseFileName4)); String baseFileName5 = "Sentinel-SDK-Demo-metrics.log"; String fileName5 = "Sentinel-SDK-Demo-metrics.log.2018-03-06.11XXX"; assertFalse(MetricWriter.fileNameMatches(fileName5, baseFileName5)); }