Search in sources :

Example 1 with DraftValidationMessage

use of se.inera.intyg.webcert.web.service.utkast.dto.DraftValidationMessage in project webcert by sklintyg.

the class UtkastModuleApiControllerTest method testValidateDraftWithWarningsArePropagatedToCaller.

@Test
public void testValidateDraftWithWarningsArePropagatedToCaller() {
    String intygTyp = "fk7263";
    String intygId = "intyg1";
    String draftAsJson = "test";
    byte[] payload = draftAsJson.getBytes();
    setupUser(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, intygTyp, false, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
    DraftValidation draftValidation = buildDraftValidation();
    draftValidation.addWarning(new DraftValidationMessage("category", "field", ValidationMessageType.WARN, "this.is.a.message", "dy.nam.ic.key"));
    when(utkastService.validateDraft(intygId, intygTyp, draftAsJson)).thenReturn(draftValidation);
    Response response = moduleApiController.validateDraft(intygTyp, intygId, payload);
    DraftValidation entity = (DraftValidation) response.getEntity();
    verify(utkastService).validateDraft(intygId, intygTyp, draftAsJson);
    assertEquals(OK.getStatusCode(), response.getStatus());
    assertEquals(ValidationStatus.VALID, entity.getStatus());
    assertEquals(0, entity.getMessages().size());
    assertEquals(1, entity.getWarnings().size());
}
Also used : Response(javax.ws.rs.core.Response) SaveDraftResponse(se.inera.intyg.webcert.web.service.utkast.dto.SaveDraftResponse) DraftValidation(se.inera.intyg.webcert.web.service.utkast.dto.DraftValidation) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DraftValidationMessage(se.inera.intyg.webcert.web.service.utkast.dto.DraftValidationMessage) Test(org.junit.Test)

Aggregations

Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 DraftValidation (se.inera.intyg.webcert.web.service.utkast.dto.DraftValidation)1 DraftValidationMessage (se.inera.intyg.webcert.web.service.utkast.dto.DraftValidationMessage)1 SaveDraftResponse (se.inera.intyg.webcert.web.service.utkast.dto.SaveDraftResponse)1