-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: shorten file names for selenium video recording
- Loading branch information
1 parent
3c192ca
commit 61227ec
Showing
2 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/integrationTest/java/io/jaconi/morp/TruncatedRecordingFileFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.jaconi.morp; | ||
|
||
import org.testcontainers.containers.DefaultRecordingFileFactory; | ||
import org.testcontainers.containers.VncRecordingContainer; | ||
|
||
import java.io.File; | ||
import java.net.URLDecoder; | ||
import java.net.URLEncoder; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import static org.apache.commons.lang3.StringUtils.substringAfter; | ||
import static org.apache.commons.lang3.StringUtils.substringBefore; | ||
|
||
public class TruncatedRecordingFileFactory extends DefaultRecordingFileFactory { | ||
|
||
@Override | ||
public File recordingFileForTest(File vncRecordingDirectory, String prefix, boolean succeeded) { | ||
return super.recordingFileForTest(vncRecordingDirectory, transformPrefix(prefix), succeeded); | ||
} | ||
|
||
@Override | ||
public File recordingFileForTest(File vncRecordingDirectory, String prefix, boolean succeeded, VncRecordingContainer.VncRecordingFormat recordingFormat) { | ||
return super.recordingFileForTest(vncRecordingDirectory, transformPrefix(prefix), succeeded, recordingFormat); | ||
} | ||
|
||
private String transformPrefix(String prefix) { | ||
var decodedPrefix = URLDecoder.decode(prefix, StandardCharsets.UTF_8); | ||
|
||
decodedPrefix = substringAfter(decodedPrefix,"/"); | ||
decodedPrefix = substringBefore(decodedPrefix, "(") + substringAfter(decodedPrefix, ")"); | ||
|
||
return URLEncoder.encode(decodedPrefix, StandardCharsets.UTF_8); | ||
} | ||
} |