@Test public void testFindPathNameTiebreaker_when_Extension() throws Exception { String incrementedName = videoStreamConstructor.findPathNameTiebreaker(pathName1 + ".xyz"); assertThat(incrementedName).isEqualTo(pathName1 + "(001).xyz"); }
public String findPathNameTiebreaker(String pathName) { if (filemanager.fileExist(pathName)) { String temp = pathName; int pos = pathName.lastIndexOf("."); if (pos > 0) { for (int idx = 1; idx < 200; idx++) { temp = String.format("%s(%03d)%s", pathName.substring(0, pos), idx, pathName.substring(pos)); if (!filemanager.fileExist(temp)) { return temp; } } } else { for (int idx = 1; idx < 200; idx++) { temp = String.format("%s(%03d)", pathName, idx); if (!filemanager.fileExist(temp)) { return temp; } } } LOG.debug("duplicate file(s) found :" + pathName); return pathName + "(duplicated)"; } else { return pathName; } }
VideoStreamConstructor { public String findPathNameTiebreaker(String pathName) { if (filemanager.fileExist(pathName)) { String temp = pathName; int pos = pathName.lastIndexOf("."); if (pos > 0) { for (int idx = 1; idx < 200; idx++) { temp = String.format("%s(%03d)%s", pathName.substring(0, pos), idx, pathName.substring(pos)); if (!filemanager.fileExist(temp)) { return temp; } } } else { for (int idx = 1; idx < 200; idx++) { temp = String.format("%s(%03d)", pathName, idx); if (!filemanager.fileExist(temp)) { return temp; } } } LOG.debug("duplicate file(s) found :" + pathName); return pathName + "(duplicated)"; } else { return pathName; } } }
VideoStreamConstructor { public String findPathNameTiebreaker(String pathName) { if (filemanager.fileExist(pathName)) { String temp = pathName; int pos = pathName.lastIndexOf("."); if (pos > 0) { for (int idx = 1; idx < 200; idx++) { temp = String.format("%s(%03d)%s", pathName.substring(0, pos), idx, pathName.substring(pos)); if (!filemanager.fileExist(temp)) { return temp; } } } else { for (int idx = 1; idx < 200; idx++) { temp = String.format("%s(%03d)", pathName, idx); if (!filemanager.fileExist(temp)) { return temp; } } } LOG.debug("duplicate file(s) found :" + pathName); return pathName + "(duplicated)"; } else { return pathName; } } VideoStreamConstructor(); }
VideoStreamConstructor { public String findPathNameTiebreaker(String pathName) { if (filemanager.fileExist(pathName)) { String temp = pathName; int pos = pathName.lastIndexOf("."); if (pos > 0) { for (int idx = 1; idx < 200; idx++) { temp = String.format("%s(%03d)%s", pathName.substring(0, pos), idx, pathName.substring(pos)); if (!filemanager.fileExist(temp)) { return temp; } } } else { for (int idx = 1; idx < 200; idx++) { temp = String.format("%s(%03d)", pathName, idx); if (!filemanager.fileExist(temp)) { return temp; } } } LOG.debug("duplicate file(s) found :" + pathName); return pathName + "(duplicated)"; } else { return pathName; } } VideoStreamConstructor(); String extractExtensionFromRequest(HttpRequestResponseInfo req); String extractNameFromRRInfo(HttpRequestResponseInfo req); String extractFullNameFromRRInfo(HttpRequestResponseInfo req); void extractVideo(StreamingVideoData streamingVideoData, HttpRequestResponseInfo request, Double timeStamp); void updateVideoNameSize(); String shortenNameByParts(String srcString, String matchStr, int groupCount); String buildSegmentFullPathName(StreamingVideoData streamingVideoData, HttpRequestResponseInfo request); String buildPath(StreamingVideoData streamingVideoData, HttpRequestResponseInfo request, int segmentID, String segmentQuality, String fileName); void collectFromFFMPEG(String fullPath, ChildManifest childManifest, Manifest manifest); ChildManifest locateChildManifestAndSegmentInfo(HttpRequestResponseInfo request, Double timeStamp, ManifestCollection manifestCollection); SegmentInfo nullSegmentInfo(); String buildByteRangeKey(HttpRequestResponseInfo request); Manifest extractManifestHLS(StreamingVideoData streamingVideoData, HttpRequestResponseInfo request); double parseResolution(String lines); boolean savePayload(byte[] content, String pathName); String findPathNameTiebreaker(String pathName); void addFailedRequest(HttpRequestResponseInfo request); Manifest extractManifestDash(StreamingVideoData streamingVideoData, HttpRequestResponseInfo request); ManifestCollection getManifestCollectionMap(); void init(); }
VideoStreamConstructor { public String findPathNameTiebreaker(String pathName) { if (filemanager.fileExist(pathName)) { String temp = pathName; int pos = pathName.lastIndexOf("."); if (pos > 0) { for (int idx = 1; idx < 200; idx++) { temp = String.format("%s(%03d)%s", pathName.substring(0, pos), idx, pathName.substring(pos)); if (!filemanager.fileExist(temp)) { return temp; } } } else { for (int idx = 1; idx < 200; idx++) { temp = String.format("%s(%03d)", pathName, idx); if (!filemanager.fileExist(temp)) { return temp; } } } LOG.debug("duplicate file(s) found :" + pathName); return pathName + "(duplicated)"; } else { return pathName; } } VideoStreamConstructor(); String extractExtensionFromRequest(HttpRequestResponseInfo req); String extractNameFromRRInfo(HttpRequestResponseInfo req); String extractFullNameFromRRInfo(HttpRequestResponseInfo req); void extractVideo(StreamingVideoData streamingVideoData, HttpRequestResponseInfo request, Double timeStamp); void updateVideoNameSize(); String shortenNameByParts(String srcString, String matchStr, int groupCount); String buildSegmentFullPathName(StreamingVideoData streamingVideoData, HttpRequestResponseInfo request); String buildPath(StreamingVideoData streamingVideoData, HttpRequestResponseInfo request, int segmentID, String segmentQuality, String fileName); void collectFromFFMPEG(String fullPath, ChildManifest childManifest, Manifest manifest); ChildManifest locateChildManifestAndSegmentInfo(HttpRequestResponseInfo request, Double timeStamp, ManifestCollection manifestCollection); SegmentInfo nullSegmentInfo(); String buildByteRangeKey(HttpRequestResponseInfo request); Manifest extractManifestHLS(StreamingVideoData streamingVideoData, HttpRequestResponseInfo request); double parseResolution(String lines); boolean savePayload(byte[] content, String pathName); String findPathNameTiebreaker(String pathName); void addFailedRequest(HttpRequestResponseInfo request); Manifest extractManifestDash(StreamingVideoData streamingVideoData, HttpRequestResponseInfo request); ManifestCollection getManifestCollectionMap(); void init();  }