|
|
@ -132,6 +132,55 @@ public class ParameterKitTest extends Prepare { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void testAnalyzeAndMergeParameters() { |
|
|
|
|
|
|
|
ParameterProvider param1 = ParameterKit.newParameter("test1", "1"); |
|
|
|
|
|
|
|
ParameterProvider param2 = ParameterKit.newParameter("test2", "2"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String text1 = "${a}"; |
|
|
|
|
|
|
|
String text2 = "${test1}"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParameterProvider[] parameters1 = ParameterKit.analyzeAndMergeParameters( |
|
|
|
|
|
|
|
new String[]{text1, text2}, |
|
|
|
|
|
|
|
new ParameterProvider[] {param1, param2} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
ParameterProvider[] parameters2 = ParameterKit.analyzeAndMergeParameters(null, null); |
|
|
|
|
|
|
|
ParameterProvider[] parameters3 = ParameterKit.analyzeAndMergeParameters( |
|
|
|
|
|
|
|
null, |
|
|
|
|
|
|
|
new ParameterProvider[] {param1, param2} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
ParameterProvider[] parameters4 = ParameterKit.analyzeAndMergeParameters( |
|
|
|
|
|
|
|
new String[] {}, |
|
|
|
|
|
|
|
new ParameterProvider[] {param1, param2} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
ParameterProvider[] parameters5 = ParameterKit.analyzeAndMergeParameters( |
|
|
|
|
|
|
|
new String[]{text1, text2}, |
|
|
|
|
|
|
|
new ParameterProvider[] {} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(parameters1.length, 3); |
|
|
|
|
|
|
|
Assert.assertEquals(parameters1[0], param1); |
|
|
|
|
|
|
|
Assert.assertEquals(parameters1[1], param2); |
|
|
|
|
|
|
|
Assert.assertEquals(parameters1[2].getName(), "a"); |
|
|
|
|
|
|
|
Assert.assertEquals(parameters1[2].getValue(), ""); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(parameters2.length, 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(parameters3.length, 2); |
|
|
|
|
|
|
|
Assert.assertEquals(parameters3[0], param1); |
|
|
|
|
|
|
|
Assert.assertEquals(parameters3[1], param2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(parameters4.length, 2); |
|
|
|
|
|
|
|
Assert.assertEquals(parameters4[0], param1); |
|
|
|
|
|
|
|
Assert.assertEquals(parameters4[1], param2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(parameters5.length, 2); |
|
|
|
|
|
|
|
Assert.assertEquals(parameters5[0].getName(), "a"); |
|
|
|
|
|
|
|
Assert.assertEquals(parameters5[0].getValue(), ""); |
|
|
|
|
|
|
|
Assert.assertEquals(parameters5[1].getName(), "test1"); |
|
|
|
|
|
|
|
Assert.assertEquals(parameters5[1].getValue(), ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void json2Parameter() { |
|
|
|
public void json2Parameter() { |
|
|
|
String text = "{\"name\":\"p1\", \"type\":\"Formula\", \"value\":\"=1+1\"}"; |
|
|
|
String text = "{\"name\":\"p1\", \"type\":\"Formula\", \"value\":\"=1+1\"}"; |
|
|
|