TravisRestService { public void saveProf(ProfilingContext profilingContext) throws Exception { Build build = profContextDumpRepository.findOne(profilingContext.getProfId()).getBuild(); jandyWorker.put(build.getTravisBuildId(), JandyTask.SAVE, profilingContext); }  @Transactional void begin(BuildInfo bi); @Transactional Map<String, ?> createProf(ProfilingInfo profParams); void saveProf(ProfilingContext profilingContext); void updateTreeNodes(List<TreeNode> treeNodes); void finish(long buildId);  }
@Test public void testSaveProf() throws Exception { ProfilingContext profContext = new Gson().fromJson(IOUtils.toString(ClassLoader.getSystemResource("java-profiler-result/end.json")), ProfilingContext.class); Build build = new Build(); build.setId(3L); build.setLanguage(bi.getLang()); build.setTravisBuildId(bi.getBuildId()); build.setNumber(bi.getBuildNum()); build.setBranch(branch); build.setNumSamples(bi.getNumSamples()); ProfContextDump prof = new ProfContextDump(); prof.setId(profContext.getProfId()); prof.setBuild(build); prof.setState(ProfContextState.CREATED); when(profContextDumpRepository.findOne(anyLong())).thenReturn(prof); this.travisRestService.saveProf(profContext); verify(profContextDumpRepository, times(1)).findOne(eq(profContext.getProfId())); verify(jandyWorker, times(1)).put(eq(build.getTravisBuildId()), eq(JandyTask.SAVE), refEq(profContext)); }