Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed Jun 20, 2023
1 parent 4065e15 commit 2c0474e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.cryptomator.common;

import org.jetbrains.annotations.VisibleForTesting;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -27,7 +28,8 @@ public static void run() {
LOG.info("Preprocessed cryptomator properties.");
}

private static String process(String value) {
@VisibleForTesting
static String process(String value) {
return TEMPLATE.matcher(value).replaceAll(match -> //
switch (match.group(1)) {
case "appdir" -> ENV.get("APPDIR");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.cryptomator.common;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.mockito.Mockito;

public class PropertiesPreprocessorTest {

@ParameterizedTest
@CsvSource(value = """
org.example.@{mytest1}.test, org.example.@{mytest1}.test
@{only*word*digits*under_score\\},@{only*words*digits*under_score\\}
C:\\Users\\@{appdir}\\dir, C:\\Users\\\\dir
@{@{appdir}},@{}
Longer @{appdir} text with @{appdir}., Longer text with .
""")
public void test(String propertyValue, String expected) {
var result = PropertiesPreprocessor.process(propertyValue);
Assertions.assertEquals(result, expected);
}

}

0 comments on commit 2c0474e

Please sign in to comment.