@Test
public void saveResource() {

     Mockito.when(apiRepository.findOne(1L)).thenReturn(api);
     Mockito.when(resourceRepository.save(Mockito.any(Resource.class))).thenReturn(resource);
     Resource saved = resourceService.save(1L, resource);
     assertEquals(saved.getId(), resource.getId());
}