@Test
public void rejectNewResourceWithPathExistentInTheSameApi() {

     thrown.expect(BadRequestException.class);
     thrown.expectMessage("Only one resource per api");
     ResourceDTO res = new ResourceDTO();
     res.setName("name");
     Api api = new Api();
     api.setId(10L);
     Resource resData = new Resource();
     resData.setApi(api);
     Mockito.when(apiRepository.findOne(10L)).thenReturn(api);
     Mockito.when(resourceRepository.findByApiIdAndName(api.getId(), res.getName())).thenReturn(resData);
     resourceService.save(10L, res);
}