forked from j62/ctbrec
Fix bug in placeholder replacement
This commit is contained in:
parent
7d73f57f36
commit
5ef448fa14
|
@ -76,6 +76,8 @@ public abstract class AbstractPlaceholderAwarePostProcessor extends AbstractPost
|
||||||
if (questionMark > 0) {
|
if (questionMark > 0) {
|
||||||
placeholderName = placeholder.substring(2, questionMark);
|
placeholderName = placeholder.substring(2, questionMark);
|
||||||
defaultValue = placeholder.substring(questionMark + 1, placeholder.length() - 1);
|
defaultValue = placeholder.substring(questionMark + 1, placeholder.length() - 1);
|
||||||
|
} else {
|
||||||
|
defaultValue = "";
|
||||||
}
|
}
|
||||||
int bracket = placeholder.indexOf('(');
|
int bracket = placeholder.indexOf('(');
|
||||||
if (bracket > 0) {
|
if (bracket > 0) {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package ctbrec.recorder.postprocessing;
|
package ctbrec.recorder.postprocessing;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
import static org.mockito.ArgumentMatchers.*;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
@ -150,4 +152,11 @@ public class AbstractPlaceholderAwarePostProcessorTest extends AbstractPpTest {
|
||||||
input = "asdf_${modelGroupName?${utcDateTime?anonymous}}_asdf";
|
input = "asdf_${modelGroupName?${utcDateTime?anonymous}}_asdf";
|
||||||
assertEquals("asdf_anonymous_asdf", placeHolderAwarePp.fillInPlaceHolders(input, ctx));
|
assertEquals("asdf_anonymous_asdf", placeHolderAwarePp.fillInPlaceHolders(input, ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMissingValueForPlaceholder() throws IOException {
|
||||||
|
String input = "asdf_${modelNotes}_asdf";
|
||||||
|
when(config.getModelNotes(any())).thenReturn(null);
|
||||||
|
assertEquals("asdf__asdf", placeHolderAwarePp.fillInPlaceHolders(input, createPostProcessingContext(rec, null, config)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue