/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.flowable.rest.api.engine.variable;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import org.flowable.rest.service.BaseSpringRestTestCase;
import org.flowable.rest.service.api.engine.variable.QueryVariable;

public class QueryVariableTest extends BaseSpringRestTestCase {

    protected ObjectMapper objectMapper = new ObjectMapper();

    public void testSerializeQueryVariable() throws Exception {
        // Create a QueryVariable
        QueryVariable origQueryVariable = new QueryVariable();
        origQueryVariable.setName("name");
        origQueryVariable.setOperation("notEquals");
        origQueryVariable.setType("type");
        origQueryVariable.setValue("value");
        // Check that the "operation" is valid
        assertEquals("notEquals", origQueryVariable.getOperation());
        assertEquals(QueryVariable.QueryVariableOperation.NOT_EQUALS, origQueryVariable.getVariableOperation());

        // Serialize
        JsonNode jsonNode = objectMapper.convertValue(origQueryVariable, JsonNode.class);

        // Reconstitute the QueryVariable
        QueryVariable newQueryVariable = objectMapper.convertValue(jsonNode, QueryVariable.class);
        // Recheck the "operation"
        assertEquals(QueryVariable.QueryVariableOperation.NOT_EQUALS, origQueryVariable.getVariableOperation());
        assertEquals("notEquals", origQueryVariable.getOperation());
    }
}

@@ -1819,16 +1819,40 @@
 eration%22
+ with the %22new%22 variable
 %0A       
@@ -1906,36 +1906,35 @@
 ion.NOT_EQUALS, 
-orig
+new
 QueryVariable.ge
@@ -1982,36 +1982,35 @@
 ls(%22notEquals%22, 
-orig
+new
 QueryVariable.ge

Fix cut-n-paste error in recently added test (#156)