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());
}
Aggregations