|
|
|
@ -2,17 +2,15 @@ package com.jayway.jsonpath.internal.function;
|
|
|
|
|
|
|
|
|
|
import com.jayway.jsonpath.Configuration; |
|
|
|
|
import com.jayway.jsonpath.Configurations; |
|
|
|
|
import com.jayway.jsonpath.internal.EvaluationContext; |
|
|
|
|
import com.jayway.jsonpath.internal.PathRef; |
|
|
|
|
import com.jayway.jsonpath.InvalidPathException; |
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
|
import java.io.InvalidClassException; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; |
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertThrows; |
|
|
|
|
|
|
|
|
|
public class CustomFunctionTest extends BaseFunctionTest { |
|
|
|
|
class CustomFunctionTest extends BaseFunctionTest { |
|
|
|
|
|
|
|
|
|
private Configuration conf = Configurations.JSON_SMART_CONFIGURATION; |
|
|
|
|
|
|
|
|
@ -30,4 +28,10 @@ public class CustomFunctionTest extends BaseFunctionTest {
|
|
|
|
|
assertDoesNotThrow(()->PathFunctionFactory.addCustomFunction("toUpperCase",ToUpperCase.class)); |
|
|
|
|
verifyTextFunction(conf,"$['text'][0].toUpperCase()","A"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void testAddExistentFunction(){ |
|
|
|
|
assertThrows(InvalidPathException.class, () -> PathFunctionFactory.addCustomFunction("avg", |
|
|
|
|
ToUpperCase.class)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|