Search in sources :

Example 6 with ArendeDraft

use of se.inera.intyg.webcert.persistence.arende.model.ArendeDraft in project webcert by sklintyg.

the class ArendeDraftServiceImpl method createDraft.

private ArendeDraft createDraft(String intygId, String questionId, String text, String amne) {
    ArendeDraft draft;
    draft = new ArendeDraft();
    draft.setIntygId(intygId);
    draft.setQuestionId(questionId);
    draft.setText(text);
    draft.setAmne(amne);
    return draft;
}
Also used : ArendeDraft(se.inera.intyg.webcert.persistence.arende.model.ArendeDraft)

Example 7 with ArendeDraft

use of se.inera.intyg.webcert.persistence.arende.model.ArendeDraft in project webcert by sklintyg.

the class ArendeDraftServiceImpl method saveDraft.

@Override
public boolean saveDraft(String intygId, String questionId, String text, String amne) {
    ArendeDraft draft = arendeDraftRepository.findByIntygIdAndQuestionId(intygId, questionId);
    if (draft != null) {
        draft.setText(text);
        draft.setAmne(amne);
    } else {
        draft = createDraft(intygId, questionId, text, amne);
    }
    arendeDraftRepository.save(draft);
    return true;
}
Also used : ArendeDraft(se.inera.intyg.webcert.persistence.arende.model.ArendeDraft)

Example 8 with ArendeDraft

use of se.inera.intyg.webcert.persistence.arende.model.ArendeDraft in project webcert by sklintyg.

the class ArendeDraftRepositoryTest method buildArendeDraft.

private ArendeDraft buildArendeDraft(String intygId, String questionId) {
    ArendeDraft arendeDraft = new ArendeDraft();
    arendeDraft.setQuestionId(questionId);
    arendeDraft.setIntygId(intygId);
    return arendeDraft;
}
Also used : ArendeDraft(se.inera.intyg.webcert.persistence.arende.model.ArendeDraft)

Example 9 with ArendeDraft

use of se.inera.intyg.webcert.persistence.arende.model.ArendeDraft in project webcert by sklintyg.

the class FragaSvarServiceImplTest method buildArendeDraft.

private ArendeDraft buildArendeDraft(String intygId, String questionId, String text) {
    ArendeDraft draft = new ArendeDraft();
    draft.setIntygId(intygId);
    draft.setQuestionId(questionId);
    draft.setText(text);
    return draft;
}
Also used : ArendeDraft(se.inera.intyg.webcert.persistence.arende.model.ArendeDraft)

Example 10 with ArendeDraft

use of se.inera.intyg.webcert.persistence.arende.model.ArendeDraft in project webcert by sklintyg.

the class ArendeDraftServiceImplTest method testDeleteExisting.

@Test
public void testDeleteExisting() {
    final String intygId = "intygId";
    final String questionId = "questionId";
    ArendeDraft draft = buildArendeDraft(intygId, questionId, null, null);
    when(repo.findByIntygIdAndQuestionId(intygId, questionId)).thenReturn(draft);
    boolean res = arendeDraftService.delete(intygId, questionId);
    assertTrue(res);
    verify(repo).findByIntygIdAndQuestionId(intygId, questionId);
    verify(repo).delete(draft);
    verifyNoMoreInteractions(repo);
}
Also used : ArendeDraft(se.inera.intyg.webcert.persistence.arende.model.ArendeDraft) Test(org.junit.Test)

Aggregations

ArendeDraft (se.inera.intyg.webcert.persistence.arende.model.ArendeDraft)11 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Collectors (java.util.stream.Collectors)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 AnsweredWithIntygUtil (se.inera.intyg.webcert.web.converter.util.AnsweredWithIntygUtil)2 FrageStallare (se.inera.intyg.webcert.web.service.fragasvar.dto.FrageStallare)2 AnsweredWithIntyg (se.inera.intyg.webcert.web.web.controller.api.dto.AnsweredWithIntyg)2 Preconditions (com.google.common.base.Preconditions)1 Strings (com.google.common.base.Strings)1 Throwables (com.google.common.base.Throwables)1 ImmutableList (com.google.common.collect.ImmutableList)1 LocalDateTime (java.time.LocalDateTime)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1