Skip to content

Commit

Permalink
Add WCAG2.2 profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Dec 13, 2023
1 parent 2304c18 commit 711c196
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.verapdf.webapp.jobservice.model.entity.enums;

public enum Profile {
TAGGED_PDF("Tagged PDF"),
PDFUA_1_MACHINE("PDF/UA-1 (Machine)"),
PDFUA_2_MACHINE("PDF/UA-2 (Machine)"),
PDFUA_2_TAGGED_PDF("PDF/UA-2 + Tagged PDF"),
PDFUA_1_HUMAN("PDF/UA-1 (Human)"),
WCAG_2_1("WCAG 2.1 (Extra)"),
WCAG_2_1_COMPLETE("WCAG 2.1 (All)"),
WCAG_2_1_DEV("WCAG 2.1 (DEV)"),
TAGGED_PDF("ISO 32005"),
PDFUA_1("PDF/UA-1"),
PDFUA_2("PDF/UA-2"),
PDFUA_2_TAGGED_PDF("PDF/UA-2 & ISO 32005"),
WCAG_2_2_HUMAN("WCAG 2.2 (Human)"),
WCAG_2_2_MACHINE("WCAG 2.2 (Machine)"),
WCAG_2_2_COMPLETE("WCAG 2.2 Machine & Human (experimental)"),
WCAG_2_2_DEV("WCAG 2.2 (DEV)"),
PDFA_1_A("PDF/A-1A"),
PDFA_1_B("PDF/A-1B"),
PDFA_2_A("PDF/A-2A"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ public class ProfileController {

public ProfileController() {
this.profiles = new ArrayList<>();
this.profiles.add(new ProfileDTO(Profile.WCAG_2_1_COMPLETE, true));
this.profiles.add(new ProfileDTO(Profile.WCAG_2_1, true));
this.profiles.add(new ProfileDTO(Profile.WCAG_2_1_DEV, true));
this.profiles.add(new ProfileDTO(Profile.PDFUA_1_MACHINE, true));
this.profiles.add(new ProfileDTO(Profile.PDFUA_1_HUMAN, false));
this.profiles.add(new ProfileDTO(Profile.WCAG_2_2_COMPLETE, true));
this.profiles.add(new ProfileDTO(Profile.WCAG_2_2_MACHINE, true));
this.profiles.add(new ProfileDTO(Profile.WCAG_2_2_HUMAN, true));
this.profiles.add(new ProfileDTO(Profile.WCAG_2_2_DEV, false));
this.profiles.add(new ProfileDTO(Profile.PDFUA_1, true));
this.profiles.add(new ProfileDTO(Profile.PDFUA_2, true));
this.profiles.add(new ProfileDTO(Profile.PDFUA_2_TAGGED_PDF, true));
this.profiles.add(new ProfileDTO(Profile.TAGGED_PDF, true));
this.profiles.add(new ProfileDTO(Profile.PDFA_1_A, false));
this.profiles.add(new ProfileDTO(Profile.PDFA_1_B, false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class JobServiceUpdateJobTests {
public void createUpdateGetJobWithTasksTest() throws Exception {
String uploadedJobId = createJobWithTasksAndReturnJobId();

String updateRequestBody = "{\"profile\": \"WCAG_2_1\"," +
String updateRequestBody = "{\"profile\": \"WCAG_2_2_COMPLETE\"," +
"\"tasks\": [" +
" {" +
" \"fileId\":\"777bd16b-6bd5-404e-808e-5dc731c73963\"" +
Expand All @@ -73,7 +73,7 @@ public void createUpdateGetJobWithTasksTest() throws Exception {
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().json("{'id':'" + uploadedJobId + "'," +
"'profile':'WCAG_2_1'," +
"'profile':'WCAG_2_2_COMPLETE'," +
"'status':'CREATED'," +
"'progress':null," +
"'queuePosition':null," +
Expand All @@ -97,7 +97,7 @@ public void createUpdateGetJobWithTasksTest() throws Exception {
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(content().json("{'id':'" + uploadedJobId + "'," +
"'profile':'WCAG_2_1'," +
"'profile':'WCAG_2_2_COMPLETE'," +
"'status':'CREATED'," +
"'progress':null," +
"'queuePosition':null," +
Expand All @@ -120,7 +120,7 @@ public void createUpdateGetJobWithTasksTest() throws Exception {
public void createUpdateGetJobWithSameTasksTest() throws Exception {
String uploadedJobId = createJobWithTasksAndReturnJobId();

String updateRequestBody = "{\"profile\": \"WCAG_2_1\"," +
String updateRequestBody = "{\"profile\": \"WCAG_2_2_COMPLETE\"," +
"\"tasks\": [" +
" {" +
" \"fileId\":\"774bd16b-7ad5-354e-808e-5dc731c73963\"" +
Expand All @@ -138,7 +138,7 @@ public void createUpdateGetJobWithSameTasksTest() throws Exception {
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().json("{'id':'" + uploadedJobId + "'," +
"'profile':'WCAG_2_1'," +
"'profile':'WCAG_2_2_COMPLETE'," +
"'status':'CREATED'," +
"'progress':null," +
"'queuePosition':null," +
Expand All @@ -159,7 +159,7 @@ public void createUpdateGetJobWithSameTasksTest() throws Exception {
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(content().json("{'id':'" + uploadedJobId + "'," +
"'profile':'WCAG_2_1'," +
"'profile':'WCAG_2_2_COMPLETE'," +
"'status':'CREATED'," +
"'progress':null," +
"'queuePosition':null," +
Expand All @@ -178,7 +178,7 @@ public void createUpdateGetJobWithSameTasksTest() throws Exception {
public void createUpdateGetJobWithPartialTaskUpdateTest() throws Exception {
String uploadedJobId = createJobWithTasksAndReturnJobId();

String updateRequestBody = "{\"profile\": \"WCAG_2_1\"," +
String updateRequestBody = "{\"profile\": \"WCAG_2_2_COMPLETE\"," +
"\"tasks\": [" +
" {" +
" \"fileId\":\"774bd16b-7ad5-354e-808e-5dc731c73963\"" +
Expand All @@ -196,7 +196,7 @@ public void createUpdateGetJobWithPartialTaskUpdateTest() throws Exception {
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().json("{'id':'" + uploadedJobId + "'," +
"'profile':'WCAG_2_1'," +
"'profile':'WCAG_2_2_COMPLETE'," +
"'status':'CREATED'," +
"'progress':null," +
"'queuePosition':null," +
Expand All @@ -216,7 +216,7 @@ public void createUpdateGetJobWithPartialTaskUpdateTest() throws Exception {
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(content().json("{'id':'" + uploadedJobId + "'," +
"'profile':'WCAG_2_1'," +
"'profile':'WCAG_2_2_COMPLETE'," +
"'status':'CREATED'," +
"'progress':null," +
"'queuePosition':null," +
Expand All @@ -236,15 +236,15 @@ public void createUpdateGetJobWithoutTasksTest() throws Exception {
String uploadedJobId = createJobWithTasksAndReturnJobId();

//Updating job
String updateRequestBody = "{\"profile\": \"WCAG_2_1\"}";
String updateRequestBody = "{\"profile\": \"WCAG_2_2_COMPLETE\"}";

mockMvc.perform(MockMvcRequestBuilders.put("/jobs/" + uploadedJobId)
.contentType(MediaType.APPLICATION_JSON)
.content(updateRequestBody))
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().json("{'id':'" + uploadedJobId + "'," +
"'profile':'WCAG_2_1'," +
"'profile':'WCAG_2_2_COMPLETE'," +
"'status':'CREATED'," +
"'progress':null," +
"'queuePosition':null," +
Expand All @@ -256,7 +256,7 @@ public void createUpdateGetJobWithoutTasksTest() throws Exception {
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(content().json("{'id':'" + uploadedJobId + "'," +
"'profile':'WCAG_2_1'," +
"'profile':'WCAG_2_2_COMPLETE'," +
"'status':'CREATED'," +
"'progress':null," +
"'queuePosition':null," +
Expand All @@ -269,7 +269,7 @@ public void createUpdateJobWithProcessingStatusTest() throws Exception {
job.setStatus(JobStatus.PROCESSING);
job = jobRepository.saveAndFlush(job);

String updateRequestBody = "{\"profile\": \"WCAG_2_1\"," +
String updateRequestBody = "{\"profile\": \"WCAG_2_2_COMPLETE\"," +
"\"tasks\": [" +
" {" +
" \"fileId\":\"777bd16b-6bd5-404e-808e-5dc731c73963\"" +
Expand Down Expand Up @@ -308,7 +308,7 @@ public void createUpdateJobWithFinishedStatusTest() throws Exception {
job.setStatus(JobStatus.FINISHED);
job = jobRepository.saveAndFlush(job);

String updateRequestBody = "{\"profile\": \"WCAG_2_1\"," +
String updateRequestBody = "{\"profile\": \"WCAG_2_2_COMPLETE\"," +
"\"tasks\": [" +
" {" +
" \"fileId\":\"777bd16b-6bd5-404e-808e-5dc731c73963\"" +
Expand Down Expand Up @@ -338,7 +338,7 @@ public void createUpdateJobWithFinishedStatusTest() throws Exception {
@Test
public void updateJobWithoutJobInDatabaseTest() throws Exception {
String id = "893ce251-4754-4d92-a6bc-69f775ab1ac6";
String updateRequestBody = "{\"profile\": \"WCAG_2_1\"}";
String updateRequestBody = "{\"profile\": \"WCAG_2_2_COMPLETE\"}";

//Updating job
Exception resolvedException = mockMvc.perform(MockMvcRequestBuilders.put("/jobs/" + id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,29 @@ void getProfilesTest() throws Exception {
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON))
.andExpect(content().json("[" +
"{\"profileName\":\"WCAG_2_1_COMPLETE\"," +
"\"humanReadableName\":\"WCAG 2.1 (All)\"," +
"{\"profileName\":\"WCAG_2_2_COMPLETE\"," +
"\"humanReadableName\":\"WCAG 2.2 Machine & Human (experimental)\"," +
"\"enabled\":true}," +
"{\"profileName\":\"WCAG_2_2_MACHINE\"," +
"\"humanReadableName\":\"WCAG 2.2 (Machine)\"," +
"\"enabled\":true}," +
"{\"profileName\":\"WCAG_2_1\"," +
"\"humanReadableName\":\"WCAG 2.1 (Extra)\"," +
"{\"profileName\":\"WCAG_2_2_HUMAN\"," +
"\"humanReadableName\":\"WCAG 2.2 (Human)\"," +
"\"enabled\":true}," +
"{\"profileName\":\"WCAG_2_1_DEV\"," +
"\"humanReadableName\":\"WCAG 2.1 (DEV)\"," +
"{\"profileName\":\"WCAG_2_2_DEV\"," +
"\"humanReadableName\":\"WCAG 2.2 (DEV)\"," +
"\"enabled\":false}," +
"{\"profileName\":\"PDFUA_1\"," +
"\"humanReadableName\":\"PDF/UA-1\"," +
"\"enabled\":true}," +
"{\"profileName\":\"PDFUA_1_MACHINE\"," +
"\"humanReadableName\":\"PDF/UA-1 (Machine)\"," +
"{\"profileName\":\"PDFUA_2\"," +
"\"humanReadableName\":\"PDF/UA-2\"," +
"\"enabled\":true}," +
"{\"profileName\":\"PDFUA_2_TAGGED_PDF\"," +
"\"humanReadableName\":\"PDF/UA-2 & ISO 32005\"," +
"\"enabled\":true}," +
"{\"profileName\":\"PDFUA_1_HUMAN\"," +
"\"humanReadableName\":\"PDF/UA-1 (Human)\"," +
"\"enabled\":false}," +
"{\"profileName\":\"TAGGED_PDF\"," +
"\"humanReadableName\":\"Tagged PDF\"," +
"\"humanReadableName\":\"ISO 32005\"," +
"\"enabled\":true}," +
"{\"profileName\":\"PDFA_1_A\"," +
"\"humanReadableName\":\"PDF/A-1A\"," +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ public ProfileMapper() throws JAXBException {
.getValidationProfileByFlavour(PDFAFlavour.PDFA_3_U));

// PDF/UA related profilesMap
this.profilesMap.put(Profile.WCAG_2_1_COMPLETE,
this.profilesMap.put(Profile.WCAG_2_2_COMPLETE,
Profiles.profileFromXml(Objects.requireNonNull(getClass().getResourceAsStream(
"/profiles/veraPDF-validation-profiles/PDF_UA/WCAG-21-Complete.xml"))));
this.profilesMap.put(Profile.PDFUA_1_MACHINE,
"/profiles/veraPDF-validation-profiles/PDF_UA/WCAG-22-Complete.xml"))));
this.profilesMap.put(Profile.WCAG_2_2_MACHINE,
Profiles.profileFromXml(Objects.requireNonNull(getClass().getResourceAsStream(
"/profiles/veraPDF-validation-profiles/PDF_UA/WCAG-22-Machine.xml"))));
this.profilesMap.put(Profile.PDFUA_1,
Profiles.profileFromXml(Objects.requireNonNull(getClass().getResourceAsStream(
"/profiles/veraPDF-validation-profiles/PDF_UA/PDFUA-1.xml"))));
this.profilesMap.put(Profile.PDFUA_2_MACHINE,
this.profilesMap.put(Profile.PDFUA_2,
Profiles.profileFromXml(Objects.requireNonNull(getClass().getResourceAsStream(
"/profiles/veraPDF-validation-profiles/PDF_UA/PDFUA-2.xml"))));
this.profilesMap.put(Profile.PDFUA_2_TAGGED_PDF,
Expand All @@ -54,12 +57,12 @@ public ProfileMapper() throws JAXBException {
this.profilesMap.put(Profile.TAGGED_PDF,
Profiles.profileFromXml(Objects.requireNonNull(getClass().getResourceAsStream(
"/profiles/veraPDF-validation-profiles/PDF_UA/ISO-32005-Tagged.xml"))));
this.profilesMap.put(Profile.WCAG_2_1,
this.profilesMap.put(Profile.WCAG_2_2_HUMAN,
Profiles.profileFromXml(Objects.requireNonNull(getClass().getResourceAsStream(
"/profiles/veraPDF-validation-profiles/PDF_UA/WCAG-21.xml"))));
this.profilesMap.put(Profile.WCAG_2_1_DEV,
"/profiles/veraPDF-validation-profiles/PDF_UA/WCAG-22.xml"))));
this.profilesMap.put(Profile.WCAG_2_2_DEV,
Profiles.profileFromXml(Objects.requireNonNull(getClass().getResourceAsStream(
"/profiles/veraPDF-validation-profiles/PDF_UA/WCAG-21-Dev.xml"))));
"/profiles/veraPDF-validation-profiles/PDF_UA/WCAG-22-Dev.xml"))));
}

public ValidationProfile getValidationProfile(Profile profile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public class ProfileMapperTests {
private QueueListener queueListener;

@ParameterizedTest
@EnumSource(value = Profile.class, names = {"PDFA_AUTO", "PDFUA_1_HUMAN"}, mode = EnumSource.Mode.EXCLUDE)
@EnumSource(value = Profile.class, names = {"PDFA_AUTO"}, mode = EnumSource.Mode.EXCLUDE)
public void checkExistenceOfAllProfiles(Profile profile) {
Assertions.assertNotNull(profileMapper.getValidationProfile(profile));
}

@ParameterizedTest
@EnumSource(value = Profile.class, names = {"PDFA_AUTO", "PDFUA_1_HUMAN"})
@EnumSource(value = Profile.class, names = {"PDFA_AUTO"})
public void checkMissingProfiles(Profile profile) {
Assertions.assertNull(profileMapper.getValidationProfile(profile));
}
Expand Down

0 comments on commit 711c196

Please sign in to comment.