// Path: src/main/java/factoryduke/exceptions/TemplateDuplicateException.java
// public class TemplateDuplicateException extends RuntimeException{
// 	public TemplateDuplicateException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java
// public class TemplateInstanciationException extends RuntimeException {
// 	public TemplateInstanciationException(Throwable cause) {
// 		super(cause);
// 	}
// }
// 
// Path: src/main/java/factoryduke/exceptions/TemplateNotFoundException.java
// public class TemplateNotFoundException extends RuntimeException {
// 	public TemplateNotFoundException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: src/test/java/model/Address.java
// public class Address {
// 	private String country;
// 	private String street;
// 	private String city;
// 
// 	public String getCountry() {
// 		return country;
// 	}
// 
// 	public void setCountry(String country) {
// 		this.country = country;
// 	}
// 
// 	public String getCity() {
// 		return city;
// 	}
// 
// 	public void setCity(String city) {
// 		this.city = city;
// 	}
// 
// 	public String getStreet() {
// 		return street;
// 	}
// 
// 	public void setStreet(String street) {
// 		this.street = street;
// 	}
// }
// 
// Path: src/test/java/model/User.java
// public class User {
// 	private long id;
// 	private String name;
// 	private String lastName;
// 	private Role role;
// 
// 	public long getId() {
// 		return id;
// 	}
// 
// 	public void setId(long id) {
// 		this.id = id;
// 	}
// 
// 	private Address addr;
// 
// 	public Role getRole() {
// 		return role;
// 	}
// 
// 	public void setRole(Role role) {
// 		this.role = role;
// 	}
// 
// 	public void setAddr(Address addr) {
// 		this.addr = addr;
// 	}
// 
// 	public void setLastName(String lastName) {
// 		this.lastName = lastName;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public Address getAddr() {
// 		return addr;
// 	}
// 
// 	public String getLastName() {
// 		return lastName;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// }


import factoryduke.exceptions.TemplateNotFoundException;
import model.Address;
import model.User;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.junit.Before;
import org.junit.Test;
import factoryduke.exceptions.TemplateDuplicateException;
import factoryduke.exceptions.TemplateInstanciationException;
/**
 * The MIT License
 * Copyright (c) 2016 Regis Leray
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package factoryduke;




public class FactoryRuntimeTest {

	@Before
	public void removeTemplate() {
		FactoryRuntimeHolder.getRuntime().reset();
	}

	@Test
	public void found_factories() {
		FactoryRuntimeHolder.getRuntime().load();
		assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).hasSize(7);
	}

	@Test
	public void reset() {
		assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).isEmpty();
	}

	@Test
	public void duplicate_definition() {
		Template tp = new ConsumerTemplate(User.class, User.class.getCanonicalName(), u -> u.setName("test"));
		FactoryRuntimeHolder.getRuntime().register(tp);

		assertThatThrownBy(() -> FactoryRuntimeHolder.getRuntime().register(tp))
// Path: src/main/java/factoryduke/exceptions/TemplateDuplicateException.java
// public class TemplateDuplicateException extends RuntimeException{
// 	public TemplateDuplicateException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java
// public class TemplateInstanciationException extends RuntimeException {
// 	public TemplateInstanciationException(Throwable cause) {
// 		super(cause);
// 	}
// }
// 
// Path: src/main/java/factoryduke/exceptions/TemplateNotFoundException.java
// public class TemplateNotFoundException extends RuntimeException {
// 	public TemplateNotFoundException(String message) {
// 		super(message);
// 	}
// }
// 
// Path: src/test/java/model/Address.java
// public class Address {
// 	private String country;
// 	private String street;
// 	private String city;
// 
// 	public String getCountry() {
// 		return country;
// 	}
// 
// 	public void setCountry(String country) {
// 		this.country = country;
// 	}
// 
// 	public String getCity() {
// 		return city;
// 	}
// 
// 	public void setCity(String city) {
// 		this.city = city;
// 	}
// 
// 	public String getStreet() {
// 		return street;
// 	}
// 
// 	public void setStreet(String street) {
// 		this.street = street;
// 	}
// }
// 
// Path: src/test/java/model/User.java
// public class User {
// 	private long id;
// 	private String name;
// 	private String lastName;
// 	private Role role;
// 
// 	public long getId() {
// 		return id;
// 	}
// 
// 	public void setId(long id) {
// 		this.id = id;
// 	}
// 
// 	private Address addr;
// 
// 	public Role getRole() {
// 		return role;
// 	}
// 
// 	public void setRole(Role role) {
// 		this.role = role;
// 	}
// 
// 	public void setAddr(Address addr) {
// 		this.addr = addr;
// 	}
// 
// 	public void setLastName(String lastName) {
// 		this.lastName = lastName;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// 	public Address getAddr() {
// 		return addr;
// 	}
// 
// 	public String getLastName() {
// 		return lastName;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// }


// Path: src/test/java/factoryduke/FactoryRuntimeTest.java
import factoryduke.exceptions.TemplateNotFoundException;
import model.Address;
import model.User;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.junit.Before;
import org.junit.Test;
import factoryduke.exceptions.TemplateDuplicateException;
import factoryduke.exceptions.TemplateInstanciationException;

/**
 * The MIT License
 * Copyright (c) 2016 Regis Leray
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package factoryduke;




public class FactoryRuntimeTest {

	@Before
	public void removeTemplate() {
		FactoryRuntimeHolder.getRuntime().reset();
	}

	@Test
	public void found_factories() {
		FactoryRuntimeHolder.getRuntime().load();
		assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).hasSize(7);
	}

	@Test
	public void reset() {
		assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).isEmpty();
	}

	@Test
	public void duplicate_definition() {
		Template tp = new ConsumerTemplate(User.class, User.class.getCanonicalName(), u -> u.setName("test"));
		FactoryRuntimeHolder.getRuntime().register(tp);

		assertThatThrownBy(() -> FactoryRuntimeHolder.getRuntime().register(tp))
				.isInstanceOf(TemplateDuplicateException.class)