private School createSchool() { School school = new School(); school.setSchoolId(1L); school.setName("Canyon Elementary School"); school.setUserSpace("ces-12346"); school.setAdministrator(createAdministrator()); return school; }
/** * 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 testUpdateSchoolNoDomain() { School school = createSchool(); when(mockDistrictRepository.findOne(anyLong())).thenReturn(null); when(mockSchoolRepository.findOne(anyLong())).thenReturn(null); School result = mockDistrictService.updateSchool(1L, school); assertNull(result.getDistrict()); verify(mockDistrictRepository, times(1)).findOne(anyLong()); verify(mockSchoolRepository, times(1)).findOne(anyLong()); verify(mockDistrictRepository, times(0)).save(any(District.class)); verify(mockSchoolRepository, times(0)).save(any(School.class)); }