11/*
2- * Copyright 2023-2024 the original author or authors.
2+ * Copyright 2023-2025 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1818
1919import java .util .HashMap ;
2020import java .util .Map ;
21- import java .util .Set ;
2221
2322import org .assertj .core .api .Assertions ;
2423import org .junit .jupiter .api .Test ;
@@ -45,7 +44,7 @@ void newApiPlaygroundTests() {
4544 // Try to render with missing value for template variable, expect exception
4645 Assertions .assertThatThrownBy (() -> pt .render (model ))
4746 .isInstanceOf (IllegalStateException .class )
48- .hasMessage ("Not all template variables were replaced. Missing variable names are [lastName]" );
47+ .hasMessage ("Not all variables were replaced in the template . Missing variable names are: [lastName]. " );
4948
5049 pt .add ("lastName" , "Park" ); // TODO investigate partial
5150 String promptString = pt .render (model );
@@ -93,44 +92,6 @@ void newApiPlaygroundTests() {
9392
9493 }
9594
96- @ Test
97- void testSingleInputVariable () {
98- String template = "This is a {foo} test" ;
99- PromptTemplate promptTemplate = new PromptTemplate (template );
100- Set <String > inputVariables = promptTemplate .getInputVariables ();
101- assertThat (inputVariables ).isNotEmpty ();
102- assertThat (inputVariables ).hasSize (1 );
103- assertThat (inputVariables ).contains ("foo" );
104- }
105-
106- @ Test
107- void testMultipleInputVariables () {
108- String template = "This {bar} is a {foo} test" ;
109- PromptTemplate promptTemplate = new PromptTemplate (template );
110- Set <String > inputVariables = promptTemplate .getInputVariables ();
111- assertThat (inputVariables ).isNotEmpty ();
112- assertThat (inputVariables ).hasSize (2 );
113- assertThat (inputVariables ).contains ("foo" , "bar" );
114- }
115-
116- @ Test
117- void testMultipleInputVariablesWithRepeats () {
118- String template = "This {bar} is a {foo} test {foo}." ;
119- PromptTemplate promptTemplate = new PromptTemplate (template );
120- Set <String > inputVariables = promptTemplate .getInputVariables ();
121- assertThat (inputVariables ).isNotEmpty ();
122- assertThat (inputVariables ).hasSize (2 );
123- assertThat (inputVariables ).contains ("foo" , "bar" );
124- }
125-
126- @ Test
127- void testBadFormatOfTemplateString () {
128- String template = "This is a {foo test" ;
129- Assertions .assertThatThrownBy (() -> new PromptTemplate (template ))
130- .isInstanceOf (IllegalArgumentException .class )
131- .hasMessage ("The template string is not valid." );
132- }
133-
13495 @ Test
13596 public void testPromptCopy () {
13697 String template = "Hello, {name}! Your age is {age}." ;
0 commit comments