* This method tests the moveGadget method by moving a gadget to another tab.
*/
@Test
public void testMoveGadgetToAnotherTab()
{
Tab fords1stTab = jpaTabMapper.findById(fordsFirstTabId);
Tab fords3rdTab = jpaTabMapper.findById(fordsThirdTabId);
TabTemplate fords1stTabTemplate = fords1stTab.getTemplate();
TabTemplate fords3rdTabTemplate = fords3rdTab.getTemplate();
// Ensure starting state.
// First Tab
assertEquals(fordsFirstTabFirstGadgetId, fords1stTabTemplate.getGadgets().get(0).getId());
assertEquals("Zone number should be 0 before the move", 0, fords1stTabTemplate.getGadgets().get(0)
.getZoneNumber());
assertEquals("Zone index should be 0 before the move", 0, fords1stTabTemplate.getGadgets().get(0)
.getZoneIndex());
assertEquals(fordsFirstTabSecondGadgetId, fords1stTabTemplate.getGadgets().get(1).getId());
assertEquals("Zone number should be 0 before the move", 0, fords1stTabTemplate.getGadgets().get(1)
.getZoneNumber());
assertEquals("Zone index should be 1 before the move", 1, fords1stTabTemplate.getGadgets().get(1)
.getZoneIndex());
assertEquals(fordsFirstTabThirdGadgetId, fords1stTabTemplate.getGadgets().get(2).getId());
assertEquals("Zone number should be 2 before the move", 2, fords1stTabTemplate.getGadgets().get(2)
.getZoneNumber());
assertEquals("Zone number index be 0 before the move", 0, fords1stTabTemplate.getGadgets().get(2)
.getZoneIndex());
// Third tab
assertEquals(fordsThirdTabFirstGadgetId, fords3rdTabTemplate.getGadgets().get(0).getId());
assertEquals("Zone number should be 0 before the move", 0, fords3rdTabTemplate.getGadgets().get(0)
.getZoneNumber());
assertEquals("Zone index should be 0 before the move", 0, fords3rdTabTemplate.getGadgets().get(0)
.getZoneIndex());
assertEquals(fordsThirdTabSecondGadgetId, fords3rdTabTemplate.getGadgets().get(1).getId());
assertEquals("Zone number should be 0 before the move", 0, fords3rdTabTemplate.getGadgets().get(1)
.getZoneNumber());
assertEquals("Zone index should be 1 before the move", 1, fords3rdTabTemplate.getGadgets().get(1)
.getZoneIndex());
assertEquals(fordsThirdTabThirdGadgetId, fords3rdTabTemplate.getGadgets().get(2).getId());
assertEquals("Zone number should be 0 before the move", 0, fords3rdTabTemplate.getGadgets().get(2)
.getZoneNumber());
assertEquals("Zone index should be 2 before the move", 2, fords3rdTabTemplate.getGadgets().get(2)
.getZoneIndex());
assertEquals(fordsThirdTabFourthGadgetId, fords3rdTabTemplate.getGadgets().get(3).getId());
assertEquals("Zone number should be 1 before the move", 1, fords3rdTabTemplate.getGadgets().get(3)
.getZoneNumber());
assertEquals("Zone index should be 0 before the move", 0, fords3rdTabTemplate.getGadgets().get(3)
.getZoneIndex());
jpaTabMapper.moveGadget(fordsFirstTabFirstGadgetId, fordsFirstTabId, 0, 0, fordsThirdTabId, 2, 0);
jpaTabMapper.flush();
getEntityManager().clear();
Tab fords1stTabAfterMove = jpaTabMapper.findById(fordsFirstTabId);
Tab fords3rdTabAfterMove = jpaTabMapper.findById(fordsThirdTabId);
TabTemplate fords1stTabTemplateAfterMove = fords1stTabAfterMove.getTemplate();
TabTemplate fords3rdTabTemplateAfterMove = fords3rdTabAfterMove.getTemplate();
// Assert after state.
assertEquals(fordsFirstTabSecondGadgetId, fords1stTabTemplateAfterMove.getGadgets().get(0).getId());
assertEquals("Zone number should be 0 after the move", 0, fords1stTabTemplateAfterMove.getGadgets().get(0)
.getZoneNumber());