/** * Test method for {@link com.sinet.gage.provision.service.DistrictService#deleteDistrict(Long)} */ @Test public void testUpdateDistrictNotExisting() { District district = createDistrict(1L); when(mockDistrictRepository.findOne(anyLong())).thenReturn(null); when(mockDistrictRepository.save(any(District.class))).thenReturn(district); District result = mockDistrictService.updateDistrict(district); assertEquals(ADMIN_FIRST_NAME, result.getAdministrator().getFirstName()); verify(mockDistrictRepository, times(1)).findOne(anyLong()); verify(mockDistrictRepository, times(1)).save(any(District.class)); }
/** * Test method for {@link com.sinet.gage.provision.service.DistrictService#deleteDistrict(Long)} */ @Test public void testUpdateDistrict() { District district = createDistrict(1L); when(mockDistrictRepository.findOne(anyLong())).thenReturn(district); when(mockDistrictRepository.save(any(District.class))).thenReturn(district); District result = mockDistrictService.updateDistrict(district); assertEquals(district, result); verify(mockDistrictRepository, times(1)).findOne(anyLong()); verify(mockDistrictRepository, times(1)).save(any(District.class)); }
/** * Test method for {@link com.sinet.gage.provision.service.DistrictService#updateSchool(Long, * School)} */ @Test public void testUpdateSchoolNotExisting() { School school = createSchool(); District district = createDistrict(1L); when(mockDistrictRepository.findOne(anyLong())).thenReturn(district); when(mockSchoolRepository.findOne(anyLong())).thenReturn(null); when(mockSchoolRepository.save(any(School.class))).thenReturn(school); when(mockDistrictRepository.save(any(District.class))).thenReturn(district); School result = mockDistrictService.updateSchool(1L, school); assertNotNull(result.getDistrict()); verify(mockDistrictRepository, times(1)).findOne(anyLong()); verify(mockSchoolRepository, times(1)).findOne(anyLong()); verify(mockDistrictRepository, times(1)).save(any(District.class)); verify(mockSchoolRepository, times(1)).save(any(School.class)); }
/** * Test method for {@link * com.sinet.gage.provision.service.DistrictService#insertDistrict(District)} */ @Test public void testInsertDistrict() { District district = createDistrict(1L); when(mockDistrictRepository.save(any(District.class))).thenReturn(district); District result = mockDistrictService.insertDistrict(district); assertNotNull(result.getDomainId()); verify(mockDistrictRepository, times(1)).save(any(District.class)); }
/** * Test method for {@link com.sinet.gage.provision.service.DistrictService#deleteDistrict(Long)} */ @Test public void testDeleteDistrictNotFound() { when(mockDistrictRepository.findOne(anyLong())).thenReturn(null); District result = mockDistrictService.deleteDistrict(1L); assertNull(result); verify(mockDistrictRepository, times(1)).findOne(anyLong()); verify(mockDistrictRepository, times(0)).delete(any(District.class)); }
/** * 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()); }