Package web.servlets.tests

Source Code of web.servlets.tests.ResetEngineTest

package web.servlets.tests;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.scotlandyard.engine.json.JsonFactory;
import org.scotlandyard.impl.engine.GameEngine;
import org.scotlandyard.impl.engine.GameImpl;
import org.scotlandyard.impl.engine.UserImpl;
import org.scotlandyard.impl.engine.boardmap.BoardMapImpl;

import web.servlets.ResetGameEngine;
/**
* TODO add description
*
* @author Hussain Al-Mutawa
* @version 1.0
* @since Sept 2011
*
*/
public class ResetEngineTest {

  @Test  // TODO add test description
  public final void testGetOutput() throws Exception{
    final GameEngine engine=GameEngine.instance();
   
    assertEquals(
        "testing the number of maps before adding anything",
        0,
        engine.getBoardMaps().size()
        );
   
    assertEquals(
        "testing the number of games before adding anything",
        0,
        engine.getLobby().getAvailableGames().size()
        );
   
    assertEquals(
        "testing the number of users before adding anything",
        0,
        engine.getUsers().size()
        );
    GameImpl.getNewInstance("game1", null, null);
    GameImpl.getNewInstance("game2", null, null);
    UserImpl.getNewInstance("user", "email");
    BoardMapImpl.getNewInstance("map");

    assertEquals(
        "testing the number of maps after adding new values",
        1,
        engine.getBoardMaps().size()
        );
   
    assertEquals(
        "testing the number of games after adding new values",
        2,
        engine.getLobby().getAvailableGames().size()
        );
   
    assertEquals(
        "testing the number of users after adding new values",
        1,
        engine.getUsers().size()
        );
   
    String json = (String)new ResetGameEngine().processRequest(null, engine);
   
    assertEquals(
        "testing the output json object is not an exception",
        "The engine has been reset",
        JsonFactory.fromJson(json).message
        );
    assertEquals(
        "testing the number of maps after reseting the engine",
        0,
        engine.getBoardMaps().size()
        );
   
    assertEquals(
        "testing the number of games after reseting the engine",
        0,
        engine.getLobby().getAvailableGames().size()
        );
   
    assertEquals(
        "testing the number of users after reseting the engine",
        0,
        engine.getUsers().size()
        );
  }

}
TOP

Related Classes of web.servlets.tests.ResetEngineTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.