#*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 *#
## ------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements.  See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You 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.
## ------------------------------------------------------------------------
## api-route-test.vm
/*
 * Camel Api Route test generated by camel-api-component-maven-plugin
 */
package $componentPackage;

import java.util.HashMap;
import java.util.Map;

import org.apache.camel.builder.RouteBuilder;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ${packageName}.${componentName}ApiCollection;
import ${packageName}.${enumName};

import static org.junit.jupiter.api.Assertions.assertNotNull;

/**
 * Test class for {@link ${proxyType.Name}} APIs.
 * TODO Move the file to src/test/java, populate parameter values, and remove @Disabled annotations.
 * The class source won't be generated again if the generator MOJO finds it under src/test/java.
 */
public class ${testName} extends Abstract${componentName}TestSupport {

    private static final Logger LOG = LoggerFactory.getLogger(${testName}.class);
    private static final String PATH_PREFIX = ${componentName}ApiCollection.getCollection().getApiName(${enumName}.class).getName();

#foreach ( $model in $models )
#set ( $testName = $helper.getTestName($model) )
#set ( $args = $model.Arguments )
#set ( $resultType = $model.ResultType )
#set ( $voidResult = $helper.isVoidType($resultType) )
## are parameter values needed
#if ( !$args.isEmpty() )
    // TODO provide parameter values for $model.Name
#end
    @Disabled
    @Test
    public void test${testName}() throws Exception {
## single argument, use as body
#if ( $args.size() == 1 )
#set ( $argType = $args.get(0).Type )
        // using $helper.getCanonicalName($argType) message body for single parameter "$args.get(0).Name"
## multiple arguments, pass them as headers
#elseif ( $args.size() > 1 )
        final Map<String, Object> headers = new HashMap<String, Object>();
#foreach ( $arg in $args )
#if ( !$arg.Type.isPrimitive() )
        // parameter type is $helper.getCanonicalName($arg.Type)
        headers.put("${helper.getExchangePropertyPrefix()}${arg.Name}", null);
#else
        headers.put("${helper.getExchangePropertyPrefix()}${arg.Name}", $helper.getDefaultArgValue($arg.Type));
#end
#end

#end
## method invocation result
        #if ( !$voidResult )#set ( $type = $helper.getResultDeclaration($resultType) )final $type result = #end
## actual template call
#if ( $args.isEmpty() )
requestBody("direct://${model.UniqueName}", null);
#elseif ( $args.size() == 1 )
## typecast body to avoid requestBody() conflict
requestBody("direct://${model.UniqueName}", $helper.getDefaultArgValue($argType));
#else
requestBodyAndHeaders("direct://${model.UniqueName}", null, headers);
#end
#if ( !$voidResult )

        assertNotNull(result, "${model.Name} result");
        LOG.debug("${model.Name}: " + result);
#end
    }

#end
    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() {
#foreach ( $model in $models )
#set ( $args = $model.Arguments )
                // test route for $model.Name
                from("direct://${model.UniqueName}")
                    .to("${scheme}://" + PATH_PREFIX + "/${model.Name}#if ( $args.size() == 1 )?inBody=${args.get(0).Name}#end");

#end
            }
        };
    }
}
