// Path: src/main/java/me/bayes/vertx/vest/deploy/VestVerticle.java
// public class VestVerticle extends AbstractVestVerticle {
// 
// 	public VestApplication createApplication(final JsonObject config) throws Exception {
// 		
// 		final JsonArray vestPackagesToScan = config.getJsonArray("vestPackagesToScan");
// 		final JsonArray vestClasses = config.getJsonArray("vestClasses");
// 		final String applicationClass = config.getString("applicationClass", "me.bayes.vertx.vest.deploy.RootContextVestApplication");
// 		final VestApplication application = (VestApplication) Class.forName(applicationClass).newInstance();
// 		
// 		//Add packages to scan
// 		if(vestPackagesToScan != null) {
// 			for(Object obj : vestPackagesToScan) {
// 				application.addPackagesToScan(String.valueOf(obj));
// 			}
// 		}
// 		
// 		//Add classes
// 		if(vestClasses != null) {
// 			for(Object obj : vestClasses) {
// 				Class<?> clazz = Class.forName((String)obj);
// 				application.addEndpointClasses(clazz);
// 			}
// 		}
// 		
// 		application.addSingleton(vertx);
// 		if(vertx != null) {
// 			application.addSingleton(vertx.getOrCreateContext());
// 			application.addSingleton(vertx.getOrCreateContext().config());
// 		}
// 		
// 		return application;
// 	}
// 
// 
// 	public RouterBuilder createBuilder(VestApplication application)
// 			throws Exception {
// 		return new DefaultRouterBuilder(application);
// 	}
// 
// }
// 
// Path: src/test/java/me/bayes/vertx/vest/sample/PingEndpoint.java
// @Path("/ping")
// public class PingEndpoint {
// 
// 	@GET
// 	public void get() {
// 		System.out.println("Hello");
// 	}
// 	
// }


import static org.junit.Assert.*;
import javax.ws.rs.core.Application;
import io.vertx.core.json.JsonObject;
import me.bayes.vertx.vest.deploy.VestVerticle;
import me.bayes.vertx.vest.sample.PingEndpoint;
import org.junit.Before;
import org.junit.Test;
/**
 * Copyright 2013 Bayes Technologies
 *
 *  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 me.bayes.vertx.vest.deploy;





/**
 * @author kevinbayes
 *
 */
public class VestVerticleTest {

	private static final String JSON_CONFIG_PACKAGES_TO_SCAN = "{\"vestPackagesToScan\":[\"me.bayes.vertx.vest.sample\"]}";
	
	private static final String JSON_CONFIG_CLASSES_TO_ADD = "{\"vestClasses\":[\"me.bayes.vertx.vest.sample.PingEndpoint\"]}";
	
	private VestVerticle vestVerticle;
	
	@Before
	public void setUp() {
		vestVerticle = new VestVerticle();
	}
	
	
	/**
	 * Test method for {@link me.bayes.vertx.vest.deploy.VestVerticle#createApplication(org.vertx.java.core.json.JsonObject)}.
	 */
	@Test
	public void testCreateApplicationWithPackageScan() {
		//Given
		JsonObject config = new JsonObject(JSON_CONFIG_PACKAGES_TO_SCAN);
		Application application = null;
		
		try {
		
			//When
			application = vestVerticle.createApplication(config);
		 
		} catch (Exception e) {
			e.printStackTrace();
			fail(e.getMessage());
		}
		
		if(application == null) {
			fail("Application not initialized.");
		}
		
		//Then
		assertTrue(application.getClasses().size() == 1);
// Path: src/main/java/me/bayes/vertx/vest/deploy/VestVerticle.java
// public class VestVerticle extends AbstractVestVerticle {
// 
// 	public VestApplication createApplication(final JsonObject config) throws Exception {
// 		
// 		final JsonArray vestPackagesToScan = config.getJsonArray("vestPackagesToScan");
// 		final JsonArray vestClasses = config.getJsonArray("vestClasses");
// 		final String applicationClass = config.getString("applicationClass", "me.bayes.vertx.vest.deploy.RootContextVestApplication");
// 		final VestApplication application = (VestApplication) Class.forName(applicationClass).newInstance();
// 		
// 		//Add packages to scan
// 		if(vestPackagesToScan != null) {
// 			for(Object obj : vestPackagesToScan) {
// 				application.addPackagesToScan(String.valueOf(obj));
// 			}
// 		}
// 		
// 		//Add classes
// 		if(vestClasses != null) {
// 			for(Object obj : vestClasses) {
// 				Class<?> clazz = Class.forName((String)obj);
// 				application.addEndpointClasses(clazz);
// 			}
// 		}
// 		
// 		application.addSingleton(vertx);
// 		if(vertx != null) {
// 			application.addSingleton(vertx.getOrCreateContext());
// 			application.addSingleton(vertx.getOrCreateContext().config());
// 		}
// 		
// 		return application;
// 	}
// 
// 
// 	public RouterBuilder createBuilder(VestApplication application)
// 			throws Exception {
// 		return new DefaultRouterBuilder(application);
// 	}
// 
// }
// 
// Path: src/test/java/me/bayes/vertx/vest/sample/PingEndpoint.java
// @Path("/ping")
// public class PingEndpoint {
// 
// 	@GET
// 	public void get() {
// 		System.out.println("Hello");
// 	}
// 	
// }


// Path: src/test/java/me/bayes/vertx/vest/deploy/VestVerticleTest.java
import static org.junit.Assert.*;
import javax.ws.rs.core.Application;
import io.vertx.core.json.JsonObject;
import me.bayes.vertx.vest.deploy.VestVerticle;
import me.bayes.vertx.vest.sample.PingEndpoint;
import org.junit.Before;
import org.junit.Test;

/**
 * Copyright 2013 Bayes Technologies
 *
 *  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 me.bayes.vertx.vest.deploy;





/**
 * @author kevinbayes
 *
 */
public class VestVerticleTest {

	private static final String JSON_CONFIG_PACKAGES_TO_SCAN = "{\"vestPackagesToScan\":[\"me.bayes.vertx.vest.sample\"]}";
	
	private static final String JSON_CONFIG_CLASSES_TO_ADD = "{\"vestClasses\":[\"me.bayes.vertx.vest.sample.PingEndpoint\"]}";
	
	private VestVerticle vestVerticle;
	
	@Before
	public void setUp() {
		vestVerticle = new VestVerticle();
	}
	
	
	/**
	 * Test method for {@link me.bayes.vertx.vest.deploy.VestVerticle#createApplication(org.vertx.java.core.json.JsonObject)}.
	 */
	@Test
	public void testCreateApplicationWithPackageScan() {
		//Given
		JsonObject config = new JsonObject(JSON_CONFIG_PACKAGES_TO_SCAN);
		Application application = null;
		
		try {
		
			//When
			application = vestVerticle.createApplication(config);
		 
		} catch (Exception e) {
			e.printStackTrace();
			fail(e.getMessage());
		}
		
		if(application == null) {
			fail("Application not initialized.");
		}
		
		//Then
		assertTrue(application.getClasses().size() == 1);
		assertTrue(application.getClasses().contains(PingEndpoint.class));