package de.gurkenlabs.litiengine.graphics;

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

import org.junit.jupiter.api.Test;

import de.gurkenlabs.litiengine.Align;
import de.gurkenlabs.litiengine.Valign;
import de.gurkenlabs.litiengine.annotation.EmitterInfo;
import de.gurkenlabs.litiengine.annotation.EntityInfo;
import de.gurkenlabs.litiengine.configuration.Quality;
import de.gurkenlabs.litiengine.graphics.emitters.Emitter;
import de.gurkenlabs.litiengine.graphics.emitters.particles.Particle;

public class EmitterTests {

  @Test
  public void testInitializationByAnnotation() {
    TestEmitter testEmitter = new TestEmitter();
    
    assertEquals(false, testEmitter.isActivateOnInit());
    assertEquals(false, testEmitter.isActivated());
    assertEquals(false, testEmitter.isPaused());
    
    assertEquals(2500, testEmitter.getTimeToLive());
    assertEquals(500, testEmitter.getMaxParticles());
    assertEquals(1000, testEmitter.getParticleMaxTTL());
    assertEquals(100, testEmitter.getParticleMinTTL());
    assertEquals(10, testEmitter.getParticleUpdateRate());
    assertEquals(Quality.HIGH, testEmitter.getRequiredQuality());
    assertEquals(15, testEmitter.getSpawnAmount());
    assertEquals(20, testEmitter.getSpawnRate());
    assertEquals(50, testEmitter.getWidth());
    assertEquals(50, testEmitter.getHeight());

    assertEquals(Align.CENTER, testEmitter.getOriginAlign());
    assertEquals(Valign.MIDDLE, testEmitter.getOriginValign());
    assertEquals(25, testEmitter.getOrigin().getX());
    assertEquals(25, testEmitter.getOrigin().getY());
  }
  
  @EmitterInfo(
      activateOnInit = false,
      emitterTTL = 2500,
      maxParticles = 500,
      originAlign = Align.CENTER,
      originVAlign = Valign.MIDDLE,
      particleMaxTTL = 1000,
      particleMinTTL = 100,
      particleUpdateRate = 10,
      requiredQuality = Quality.HIGH,
      spawnAmount = 15,
      spawnRate = 20)
  @EntityInfo(width = 50, height = 50)
  class TestEmitter extends Emitter{

    @Override
    protected Particle createNewParticle() {
      return null;
    }
  }
}

@@ -97,16 +97,177 @@
 tEquals;
+%0Aimport static org.junit.jupiter.api.Assertions.assertTrue;%0A%0Aimport java.awt.Color;%0Aimport java.util.Arrays;%0Aimport java.util.Collections;%0Aimport java.util.List;
 %0A%0Aimport
@@ -1186,32 +1186,156 @@
 ticleMinTTL());%0A
+    assertTrue(testEmitter.getRandomParticleTTL() %3E= 100);%0A    assertTrue(testEmitter.getRandomParticleTTL() %3C= 1000);%0A    %0A
     assertEquals
@@ -1880,16 +1880,450 @@
 %0A  %7D%0A  %0A
+  @Test%0A  public void testRandomValueGeneration() %7B%0A    TestEmitter testEmitter = new TestEmitter();%0A    assertTrue(testEmitter.getRandomParticleTTL() %3E= 100);%0A    assertTrue(testEmitter.getRandomParticleTTL() %3C= 1000);%0A    %0A    Color %5B%5D colors = new Color %5B%5D %7BColor.RED, Color.ORANGE, Color.YELLOW%7D;%0A    testEmitter.setColors(colors);%0A    %0A    assertTrue(Arrays.asList(colors).contains(testEmitter.getRandomParticleColor()));%0A  %7D%0A  %0A
   @Emitt
@@ -2785,24 +2785,24 @@
 article() %7B%0A
-
       return
@@ -2814,14 +2814,236 @@
 ;%0A    %7D%0A
+    %0A    @Override%0A    public int getRandomParticleTTL() %7B%0A      return super.getRandomParticleTTL();%0A    %7D%0A    %0A    @Override%0A    public Color getRandomParticleColor() %7B%0A      return super.getRandomParticleColor();%0A    %7D%0A
   %7D%0A%7D%0A

Add another emitter test.