@Test public void updateBySwaggerTest() throws IOException { Mockito.when(apiRepository.findOne(Mockito.anyLong())).thenReturn(api); Mockito.when(swaggerService.importApiFromSwaggerJSON(api, "adsqwe", false)).thenReturn(api); apiService.updateBySwagger(1L, "asd", false); Mockito.verify(apiRepository, Mockito.times(1)).save(Mockito.any(Api.class)); }
public Api updateBySwagger(Long id, String swagger, boolean override) { Api api = apiRepository.findOne(id); HeimdallException.checkThrow(api == null, GLOBAL_RESOURCE_NOT_FOUND); try { api = swaggerService.importApiFromSwaggerJSON(api, swagger, override); } catch (IOException e) { HeimdallException.checkThrow(api == null, GLOBAL_SWAGGER_JSON_INVALID_FORMAT); } api = apiRepository.save(api); amqpRoute.dispatchRoutes(); return api; }
ApiService { public Api updateBySwagger(Long id, String swagger, boolean override) { Api api = apiRepository.findOne(id); HeimdallException.checkThrow(api == null, GLOBAL_RESOURCE_NOT_FOUND); try { api = swaggerService.importApiFromSwaggerJSON(api, swagger, override); } catch (IOException e) { HeimdallException.checkThrow(api == null, GLOBAL_SWAGGER_JSON_INVALID_FORMAT); } api = apiRepository.save(api); amqpRoute.dispatchRoutes(); return api; } }
ApiService { public Api updateBySwagger(Long id, String swagger, boolean override) { Api api = apiRepository.findOne(id); HeimdallException.checkThrow(api == null, GLOBAL_RESOURCE_NOT_FOUND); try { api = swaggerService.importApiFromSwaggerJSON(api, swagger, override); } catch (IOException e) { HeimdallException.checkThrow(api == null, GLOBAL_SWAGGER_JSON_INVALID_FORMAT); } api = apiRepository.save(api); amqpRoute.dispatchRoutes(); return api; }  }
ApiService { public Api updateBySwagger(Long id, String swagger, boolean override) { Api api = apiRepository.findOne(id); HeimdallException.checkThrow(api == null, GLOBAL_RESOURCE_NOT_FOUND); try { api = swaggerService.importApiFromSwaggerJSON(api, swagger, override); } catch (IOException e) { HeimdallException.checkThrow(api == null, GLOBAL_SWAGGER_JSON_INVALID_FORMAT); } api = apiRepository.save(api); amqpRoute.dispatchRoutes(); return api; }  Api find(Long id); Swagger findSwaggerByApi(Long id); ApiPage list(ApiDTO apiDTO, PageableDTO pageableDTO); List<Api> list(ApiDTO apiDTO); Api save(ApiDTO apiDTO); Api update(Long id, ApiDTO apiDTO); Api updateBySwagger(Long id, String swagger, boolean override); void delete(Long id); @Transactional(readOnly = true) List<Plan> plansByApi(Long id); }
ApiService { public Api updateBySwagger(Long id, String swagger, boolean override) { Api api = apiRepository.findOne(id); HeimdallException.checkThrow(api == null, GLOBAL_RESOURCE_NOT_FOUND); try { api = swaggerService.importApiFromSwaggerJSON(api, swagger, override); } catch (IOException e) { HeimdallException.checkThrow(api == null, GLOBAL_SWAGGER_JSON_INVALID_FORMAT); } api = apiRepository.save(api); amqpRoute.dispatchRoutes(); return api; }  Api find(Long id); Swagger findSwaggerByApi(Long id); ApiPage list(ApiDTO apiDTO, PageableDTO pageableDTO); List<Api> list(ApiDTO apiDTO); Api save(ApiDTO apiDTO); Api update(Long id, ApiDTO apiDTO); Api updateBySwagger(Long id, String swagger, boolean override); void delete(Long id); @Transactional(readOnly = true) List<Plan> plansByApi(Long id);  }