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) {
|
||||
placeholderName = placeholder.substring(2, questionMark);
|
||||
defaultValue = placeholder.substring(questionMark + 1, placeholder.length() - 1);
|
||||
} else {
|
||||
defaultValue = "";
|
||||
}
|
||||
int bracket = placeholder.indexOf('(');
|
||||
if (bracket > 0) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package ctbrec.recorder.postprocessing;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.ZoneId;
|
||||
|
@ -150,4 +152,11 @@ public class AbstractPlaceholderAwarePostProcessorTest extends AbstractPpTest {
|
|||
input = "asdf_${modelGroupName?${utcDateTime?anonymous}}_asdf";
|
||||
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