Created
September 21, 2018 15:37
-
-
Save eldermoraes/eedd802765406a9c46ccc90ecb7d9787 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PlayerRankHistoryServiceTest { | |
private EJBContainer ejbContainer; | |
@EJB | |
private PlayerService playerService; | |
@EJB | |
private PlayerRankHistoryService rankService; | |
public PlayerRankHistoryServiceTest() { | |
} | |
@Before | |
public void setUp() throws NamingException { | |
Properties p = new Properties(); | |
p.put("microDb", "new://Resource?type=DataSource"); | |
p.put("microDb.JdbcDriver", "org.hsqldb.jdbcDriver"); | |
p.put("microDb.JdbcUrl", "jdbc:hsqldb:mem:microdatabase"); | |
ejbContainer = EJBContainer.createEJBContainer(p); | |
ejbContainer.getContext().bind("inject", this); | |
} | |
@After | |
public void tearDown() { | |
ejbContainer.close(); | |
} | |
@Test | |
public void saveRankHistory() { | |
Player p = new Player(1L, "Player1", 10L); | |
playerService.save(p); | |
PlayerRankHistory r = new PlayerRankHistory(1L, p, 10L, 1000L, new Date()); | |
Response response = rankService.save(r); | |
assertEquals(202, response.getStatus()); | |
response = rankService.findAll(); | |
List<PlayerRankHistory> list = (List<PlayerRankHistory>) response.getEntity(); | |
assertEquals(1, list.size()); | |
} | |
@Test | |
public void findAllRankHistory() { | |
Player p = new Player(1L, "Player1", 10L); | |
playerService.save(p); | |
PlayerRankHistory r = new PlayerRankHistory(1L, p, 10L, 1000L, new Date()); | |
rankService.save(r); | |
Response response = rankService.findAll(); | |
List<PlayerRankHistory> list = (List<PlayerRankHistory>) response.getEntity(); | |
assertEquals(1, list.size()); | |
} | |
@Test | |
public void removeRankHistory() { | |
Player p = new Player(1L, "Player1", 10L); | |
playerService.save(p); | |
PlayerRankHistory r = new PlayerRankHistory(1L, p, 10L, 1000L, new Date()); | |
rankService.save(r); | |
Response response = rankService.remove(r); | |
assertEquals(202, response.getStatus()); | |
response = rankService.findAll(); | |
List<PlayerRankHistory> list = (List<PlayerRankHistory>) response.getEntity(); | |
assertEquals(0, list.size()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment