/** * Test method for {@link com.sinet.gage.provision.service.DistrictService#insertSchool(Long, * School)} */ @Test public void testInsertSchoolNoDistrict() { School school = createSchool(); when(mockDistrictRepository.findOne(anyLong())).thenReturn(null); when(mockSchoolRepository.save(any(School.class))).thenReturn(school); School result = mockDistrictService.insertSchool(1L, school); assertNotNull(result.getSchoolId()); verifyZeroInteractions(mockSchoolRepository); verify(mockDistrictRepository, times(1)).findOne(anyLong()); }
/** * Test method for {@link com.sinet.gage.provision.service.DistrictService#updateSchool(Long, * School)} */ @Test public void testUpdateSchoolFailed() { School school = createSchool(); District district = createDistrict(1L); when(mockDistrictRepository.findOne(anyLong())).thenReturn(district); when(mockSchoolRepository.findOne(anyLong())).thenReturn(school); when(mockSchoolRepository.save(any(School.class))).thenReturn(null); School result = mockDistrictService.updateSchool(1L, school); assertNull(result); verify(mockDistrictRepository, times(1)).findOne(anyLong()); verify(mockSchoolRepository, times(1)).findOne(anyLong()); verify(mockDistrictRepository, times(0)).save(any(District.class)); verify(mockSchoolRepository, times(1)).save(any(School.class)); }