package com.artemis;

import com.artemis.annotations.Wire;
import org.junit.Assert;
import org.junit.Test;

/**
 * @author Daan van Yperen
 */
public class WireByConventionTest {

	@Test
	public void ensure_primitives_dont_cause_wire_exceptions() {

		class PrimitivesSystem extends BaseSystem {

			byte b;
			short s;
			int i;
			long l;
			float f;
			double d;
			boolean b2;
			char c;
			String z;

			@Override
			protected void processSystem() {
			}
		}

		new World(new WorldConfiguration().setSystem(new PrimitivesSystem()));
	}

	@Test
	public void ensure_explicit_wire_overrides_implicit_wire() {

		class TestSystem extends BaseSystem {
			@Override
			protected void processSystem() {
			}
		}

		class SuperSystem extends BaseSystem {

			TestSystem x;

			@Override
			protected void processSystem() {
			}
		}

		@Wire(injectInherited = false)
		class ExplicitlyWired extends SuperSystem {

			TestSystem y;

			@Override
			protected void processSystem() {
			}
		}

		ExplicitlyWired explicitlyWired = new ExplicitlyWired();
		new World(new WorldConfiguration()
				.setSystem(explicitlyWired)
				.setSystem(new TestSystem()));

		Assert.assertNotNull(explicitlyWired.y);
		Assert.assertNull(explicitlyWired.x);
	}
}

@@ -105,16 +105,50 @@
 t;%0A%0A/**%0A
+ * Wire applies by convention.%0A *%0A
  * @auth
@@ -207,16 +207,463 @@
 Test %7B%0A%0A
+%09@Test%0A%09public void ensure_wire_implicit_by_convention() %7B%0A%09%09class TestSystem extends BaseSystem %7B%0A%0A%09%09%09@Override%0A%09%09%09protected void processSystem() %7B%0A%0A%09%09%09%7D%0A%09%09%7D%0A%09%09class TestSystem2 extends BaseSystem %7B%0A%0A%09%09%09TestSystem x;%0A%09%09%09@Override%0A%09%09%09protected void processSystem() %7B%0A%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09TestSystem2 system2 = new TestSystem2();%0A%09%09new World(new WorldConfiguration().setSystem(new TestSystem()).setSystem(system2));%0A%0A%09%09Assert.assertNotNull(system2.x);%0A%09%7D%0A%0A
 %09@Test%0A%09

Add ensure_wire_implicit_by_convention test.