1
1
/*
2
- * Copyright 2023-2024 the original author or authors.
2
+ * Copyright 2023-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
18
18
19
19
import java .util .HashMap ;
20
20
import java .util .Map ;
21
- import java .util .Set ;
22
21
23
22
import org .assertj .core .api .Assertions ;
24
23
import org .junit .jupiter .api .Test ;
@@ -45,7 +44,7 @@ void newApiPlaygroundTests() {
45
44
// Try to render with missing value for template variable, expect exception
46
45
Assertions .assertThatThrownBy (() -> pt .render (model ))
47
46
.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]. " );
49
48
50
49
pt .add ("lastName" , "Park" ); // TODO investigate partial
51
50
String promptString = pt .render (model );
@@ -93,44 +92,6 @@ void newApiPlaygroundTests() {
93
92
94
93
}
95
94
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
-
134
95
@ Test
135
96
public void testPromptCopy () {
136
97
String template = "Hello, {name}! Your age is {age}." ;
0 commit comments