@Test public void testSetVidareBefordradOK() { FragaSvar fraga = buildFraga(1L, "frageText", Amne.OVRIGT, LocalDateTime.now()); when(webCertUserService.getUser()).thenReturn(createUser()); when(fragasvarRepositoryMock.findByIntygsReferensIntygsId(any(String.class))).thenReturn(ImmutableList.of(fraga)); assertFalse(fraga.getVidarebefordrad()); List<FragaSvar> fragaSvarList = service.setVidareBefordrad(fraga.getIntygsReferens().getIntygsId()); verify(fragasvarRepositoryMock).saveAll(anyList()); verifyNoInteractions(notificationServiceMock); assertTrue(fragaSvarList .stream() .allMatch(FragaSvar::getVidarebefordrad)); }
@Override public List<FragaSvar> setVidareBefordrad(final String intygsId) { Preconditions.checkArgument(!Strings.isNullOrEmpty(intygsId), "intygsId may not be null or empty"); final WebCertUser user = webCertUserService.getUser(); final List<FragaSvar> fragaSvarList = fragaSvarRepository.findByIntygsReferensIntygsId(intygsId) .stream() .peek(fs -> authoritiesValidator.given(user, fs.getIntygsReferens().getIntygsTyp()) .features(AuthoritiesConstants.FEATURE_HANTERA_FRAGOR) .privilege(AuthoritiesConstants.PRIVILEGE_VIDAREBEFORDRA_FRAGASVAR) .orThrow()) .peek(FragaSvar::setToVidareBefordrad) .collect(Collectors.toList()); return fragaSvarRepository.saveAll(fragaSvarList); }
FragaSvarServiceImpl implements FragaSvarService { @Override public List<FragaSvar> setVidareBefordrad(final String intygsId) { Preconditions.checkArgument(!Strings.isNullOrEmpty(intygsId), "intygsId may not be null or empty"); final WebCertUser user = webCertUserService.getUser(); final List<FragaSvar> fragaSvarList = fragaSvarRepository.findByIntygsReferensIntygsId(intygsId) .stream() .peek(fs -> authoritiesValidator.given(user, fs.getIntygsReferens().getIntygsTyp()) .features(AuthoritiesConstants.FEATURE_HANTERA_FRAGOR) .privilege(AuthoritiesConstants.PRIVILEGE_VIDAREBEFORDRA_FRAGASVAR) .orThrow()) .peek(FragaSvar::setToVidareBefordrad) .collect(Collectors.toList()); return fragaSvarRepository.saveAll(fragaSvarList); } }
FragaSvarServiceImpl implements FragaSvarService { @Override public List<FragaSvar> setVidareBefordrad(final String intygsId) { Preconditions.checkArgument(!Strings.isNullOrEmpty(intygsId), "intygsId may not be null or empty"); final WebCertUser user = webCertUserService.getUser(); final List<FragaSvar> fragaSvarList = fragaSvarRepository.findByIntygsReferensIntygsId(intygsId) .stream() .peek(fs -> authoritiesValidator.given(user, fs.getIntygsReferens().getIntygsTyp()) .features(AuthoritiesConstants.FEATURE_HANTERA_FRAGOR) .privilege(AuthoritiesConstants.PRIVILEGE_VIDAREBEFORDRA_FRAGASVAR) .orThrow()) .peek(FragaSvar::setToVidareBefordrad) .collect(Collectors.toList()); return fragaSvarRepository.saveAll(fragaSvarList); }  }
FragaSvarServiceImpl implements FragaSvarService { @Override public List<FragaSvar> setVidareBefordrad(final String intygsId) { Preconditions.checkArgument(!Strings.isNullOrEmpty(intygsId), "intygsId may not be null or empty"); final WebCertUser user = webCertUserService.getUser(); final List<FragaSvar> fragaSvarList = fragaSvarRepository.findByIntygsReferensIntygsId(intygsId) .stream() .peek(fs -> authoritiesValidator.given(user, fs.getIntygsReferens().getIntygsTyp()) .features(AuthoritiesConstants.FEATURE_HANTERA_FRAGOR) .privilege(AuthoritiesConstants.PRIVILEGE_VIDAREBEFORDRA_FRAGASVAR) .orThrow()) .peek(FragaSvar::setToVidareBefordrad) .collect(Collectors.toList()); return fragaSvarRepository.saveAll(fragaSvarList); }  @Override FragaSvar processIncomingQuestion(FragaSvar fragaSvar); @Override FragaSvar processIncomingAnswer(Long internId, String svarsText, LocalDateTime svarSigneringsDatum); @Override @Transactional(readOnly = true) List<FragaSvarView> getFragaSvar(String intygId); @Override FragaSvar saveSvar(Long fragaSvarsId, String svarsText); @Override List<FragaSvarView> answerKomplettering(final String intygsId, final String svarsText); @Override FragaSvar saveNewQuestion(String intygId, String typ, Amne amne, String frageText); @Override List<FragaSvar> setVidareBefordrad(final String intygsId); @Override FragaSvar closeQuestionAsHandled(Long frageSvarId); @Override void closeCompletionsAsHandled(String intygId); @Override void closeAllNonClosedQuestions(String intygsId); @Override FragaSvar openQuestionAsUnhandled(Long frageSvarId); @Override @Transactional(readOnly = true) QueryFragaSvarResponse filterFragaSvar(Filter filter); @Override @Transactional(readOnly = true) List<Lakare> getFragaSvarHsaIdByEnhet(String enhetsId); @Override Map<String, Long> getNbrOfUnhandledFragaSvarForCareUnits(List<String> vardenheterIds, Set<String> intygsTyper); }
FragaSvarServiceImpl implements FragaSvarService { @Override public List<FragaSvar> setVidareBefordrad(final String intygsId) { Preconditions.checkArgument(!Strings.isNullOrEmpty(intygsId), "intygsId may not be null or empty"); final WebCertUser user = webCertUserService.getUser(); final List<FragaSvar> fragaSvarList = fragaSvarRepository.findByIntygsReferensIntygsId(intygsId) .stream() .peek(fs -> authoritiesValidator.given(user, fs.getIntygsReferens().getIntygsTyp()) .features(AuthoritiesConstants.FEATURE_HANTERA_FRAGOR) .privilege(AuthoritiesConstants.PRIVILEGE_VIDAREBEFORDRA_FRAGASVAR) .orThrow()) .peek(FragaSvar::setToVidareBefordrad) .collect(Collectors.toList()); return fragaSvarRepository.saveAll(fragaSvarList); }  @Override FragaSvar processIncomingQuestion(FragaSvar fragaSvar); @Override FragaSvar processIncomingAnswer(Long internId, String svarsText, LocalDateTime svarSigneringsDatum); @Override @Transactional(readOnly = true) List<FragaSvarView> getFragaSvar(String intygId); @Override FragaSvar saveSvar(Long fragaSvarsId, String svarsText); @Override List<FragaSvarView> answerKomplettering(final String intygsId, final String svarsText); @Override FragaSvar saveNewQuestion(String intygId, String typ, Amne amne, String frageText); @Override List<FragaSvar> setVidareBefordrad(final String intygsId); @Override FragaSvar closeQuestionAsHandled(Long frageSvarId); @Override void closeCompletionsAsHandled(String intygId); @Override void closeAllNonClosedQuestions(String intygsId); @Override FragaSvar openQuestionAsUnhandled(Long frageSvarId); @Override @Transactional(readOnly = true) QueryFragaSvarResponse filterFragaSvar(Filter filter); @Override @Transactional(readOnly = true) List<Lakare> getFragaSvarHsaIdByEnhet(String enhetsId); @Override Map<String, Long> getNbrOfUnhandledFragaSvarForCareUnits(List<String> vardenheterIds, Set<String> intygsTyper);  }