package com.boundary.sdk.event.service;

import org.apache.camel.Exchange;
import org.apache.camel.Message;

import com.boundary.camel.component.ping.PingConfiguration;
import com.boundary.camel.component.port.PortConfiguration;

import static com.boundary.sdk.event.service.ServiceCheckPropertyNames.*;

public class ExtractServiceTestConfiguration {

	public PingConfiguration getPingConfiguration(ServiceTest<PingConfiguration> serviceTest) {
		return serviceTest.getConfiguration();
	}
	
	/**
	 * Extract the {@link PortConfiguration} from the {@link ServiceTest} and
	 * set as header in {@link Message}
	 * @param exchange {@link Exchange} from Camel route
	 */
	public void extractPortConfiguration(Exchange exchange) {
		Message message = exchange.getIn();
		ServiceTest<PortConfiguration> serviceTest = message.getBody(ServiceTest.class);
		PortConfiguration configuration = serviceTest.getConfiguration();
		
		message.setHeader(SERVICE_TEST_INSTANCE, serviceTest);
		message.setBody(configuration);
	}
	
	/**
	 * Extract the {@link PingConfiguration} from the {@link ServiceTest} and
	 * set as header in {@link Message}
	 * @param exchange {@link Exchange} from Camel route
	 */
	public void extractPingConfiguration(Exchange exchange) {
		Message message = exchange.getIn();
		ServiceTest<PingConfiguration> serviceTest = message.getBody(ServiceTest.class);
		PingConfiguration configuration = serviceTest.getConfiguration();
		
		message.setHeader(SERVICE_TEST_INSTANCE, serviceTest);
		message.setBody(configuration);
	}
}

@@ -221,16 +221,75 @@
 uration;
+%0Aimport com.boundary.camel.component.ssh.SshxConfiguration;
 %0A%0Aimport
@@ -1588,10 +1588,532 @@
 on);%0A%09%7D%0A
+%09%0A%09/**%0A%09 * Extract the %7B@link SshxConfiguration%7D from the %7B@link ServiceTest%7D and%0A%09 * set as header in %7B@link Message%7D%0A%09 * @param exchange %7B@link Exchange%7D from Camel route%0A%09 */%0A%09public void extractSshConfiguration(Exchange exchange) %7B%0A%09%09Message message = exchange.getIn();%0A%09%09ServiceTest%3CSshxConfiguration%3E serviceTest = message.getBody(ServiceTest.class);%0A%09%09SshxConfiguration configuration = serviceTest.getConfiguration();%0A%09%09%0A%09%09message.setHeader(SERVICE_TEST_INSTANCE, serviceTest);%0A%09%09message.setBody(configuration);%0A%09%7D%0A
 %7D%0A

Add extraction of SSH configuration