@Test public void testDelete() throws Exception { Soccer_records player = new Soccer_records("A", "17", 8, 9, 2); Soccer_records returnObject = crudService.remove(player); when(crudService.remove(player)).thenReturn(returnObject); Mockito.verify(crudService).remove(player); }
@Test public void testRead() throws Exception { Soccer_records team = new Soccer_records("A", "17", 8, 9, 2); Soccer_records returnObject = crudService.find(team.getAgeGroup()); when(crudService.find(team.getAgeGroup())).thenReturn(returnObject); Mockito.verify(crudService).find(team.getAgeGroup()); }
@Test public void testCreate() throws Exception { Soccer_records team = new Soccer_records("A", "17", 8, 9, 2); Soccer_records returnObject = crudService.persist(team); when(crudService.persist(team)).thenReturn(returnObject); Mockito.verify(crudService).persist(team); Assert.assertEquals("17", team.getAgeGroup(), "Name was changed"); Assert.assertEquals(team.getDivision(), "A", "The name update didnt run"); }
@Test public void testUpdate() throws Exception { Soccer_records team = new Soccer_records("A", "17", 8, 9, 2); when(crudService.merge(team)).thenReturn(team); Soccer_records returnObject = crudService.merge(team); Mockito.verify(crudService).merge(team); ////////////////////////////////////////////////////// Soccer_records updated = team.updateLoses(19); when(crudService.merge(updated)).thenReturn(team); Soccer_records returned = crudService.merge(updated); Assert.assertNotSame(returned, updated); }