Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mbenson committed Apr 27, 2024
1 parent 855abe3 commit f4d7bac
Showing 1 changed file with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.InputStream;
import java.util.List;
import java.util.function.UnaryOperator;

import junit.framework.TestCase;
import org.apache.maven.model.Model;
Expand All @@ -44,29 +45,41 @@ private Model read(String pom) throws Exception {
}

private SimpleProblemCollector validate(String pom) throws Exception {
return validateEffective(pom, ModelBuildingRequest.VALIDATION_LEVEL_STRICT);
return validateEffective(pom, UnaryOperator.identity());
}

private SimpleProblemCollector validateRaw(String pom) throws Exception {
return validateRaw(pom, ModelBuildingRequest.VALIDATION_LEVEL_STRICT);
return validateRaw(pom, UnaryOperator.identity());
}

private SimpleProblemCollector validateEffective(String pom, int level) throws Exception {
ModelBuildingRequest request = new DefaultModelBuildingRequest().setValidationLevel(level);
return validateEffective(pom, mbr -> mbr.setValidationLevel(level));
}

private SimpleProblemCollector validateEffective(String pom, UnaryOperator<ModelBuildingRequest> requestConfigurer)
throws Exception {
Model model = read(pom);

SimpleProblemCollector problems = new SimpleProblemCollector(read(pom));
SimpleProblemCollector problems = new SimpleProblemCollector(model);

validator.validateEffectiveModel(problems.getModel(), request, problems);
validator.validateEffectiveModel(model, requestConfigurer.apply(new DefaultModelBuildingRequest()), problems);

return problems;
}

private SimpleProblemCollector validateRaw(String pom, int level) throws Exception {
ModelBuildingRequest request = new DefaultModelBuildingRequest().setValidationLevel(level);
return validateRaw(pom, mbr -> mbr.setValidationLevel(level));
}

private SimpleProblemCollector validateRaw(String pom, UnaryOperator<ModelBuildingRequest> requestConfigurer)
throws Exception {
Model model = read(pom);

SimpleProblemCollector problems = new SimpleProblemCollector(model);

SimpleProblemCollector problems = new SimpleProblemCollector(read(pom));
ModelBuildingRequest request = requestConfigurer.apply(new DefaultModelBuildingRequest());

validator.validateRawModel(problems.getModel(), request, problems);
validator.validateRawModel(model, request, problems);

return problems;
}
Expand Down

0 comments on commit f4d7bac

Please sign in to comment.