Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
<artifactId>guice</artifactId>
<version>6.0.0</version>
</dependency>
<dependency>
<!-- Required for project validation -->
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
import ch.ivyteam.ivy.project.validation.ProjectValidator;
import ch.ivyteam.ivy.project.validation.ProjectValidatorContext;
import ch.ivyteam.ivy.project.validation.ProjectValidatorResult.Message;
import ch.ivyteam.ivy.rest.client.config.impl.RestClientProjectValidator;
import ch.ivyteam.ivy.role.impl.RoleProjectValidator;
import ch.ivyteam.ivy.user.impl.UserProjectValidator;
import ch.ivyteam.ivy.vars.impl.VariableProjectValidator;
import ch.ivyteam.ivy.webservice.datamodel.impl.WebServiceClientProjectValidator;

/**
Expand Down Expand Up @@ -67,7 +69,9 @@ private List<ProjectValidator> validators() {
return List.of(
new UserProjectValidator(),
new RoleProjectValidator(),
new WebServiceClientProjectValidator());
new WebServiceClientProjectValidator(),
new VariableProjectValidator(),
new RestClientProjectValidator());
}

private void log(Message message) {
Expand All @@ -93,7 +97,7 @@ private ContextBuilder(MavenProject project, MavenSession session) {
}

private ProjectValidatorContext build() {
return ProjectValidatorContext.create(toProject(), toAllProjects());
return ProjectValidatorContext.create().project(toProject()).allProjects(toAllProjects()).toContext();
Comment thread
ivy-edp marked this conversation as resolved.
}

private Project toProject() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,34 @@ void validate() throws IOException {
""";
Files.writeString(file, content);

file = dir.resolve("rest-clients.yaml");
content = """
RestClients:
test name:
Name: Test
test.name:
Name: Another
""";
Files.writeString(file, content);

file = dir.resolve("variables.yaml");
content = """
Variables:
Test: Something
Test: Something else
""";
Files.writeString(file, content);
var log = new LogCollector();
mojo.setLog(log);
mojo.execute();
assertThat(log.getWarnings().toString())
.contains("config/users.yaml: User 'Alex' is configured to have role 'Gangster' which is not defined.")
.contains("config/webservice-clients.yaml: The web service client key 'test.name' should be sanitized to 'testname' to avoid potential issues. Use the name for a better readability.")
.contains("config/webservice-clients.yaml: The web service client key 'test name' should be sanitized to 'test-name' to avoid potential issues. Use the name for a better readability.");
.contains("config/webservice-clients.yaml: The web service client key 'test name' should be sanitized to 'test-name' to avoid potential issues. Use the name for a better readability.")
.contains("config/rest-clients.yaml: The rest client key 'test.name' should be sanitized to 'testname' to avoid potential issues. Use the name for a better readability.")
.contains("config/rest-clients.yaml: The rest client key 'test name' should be sanitized to 'test-name' to avoid potential issues. Use the name for a better readability.");
assertThat(log.getErrors().toString())
.contains("config/roles.yaml: Role 'HR Manager' has an unknown parent 'Manager'.");
.contains("config/roles.yaml: Role 'HR Manager' has an unknown parent 'Manager'.")
.contains("config/variables.yaml: Variable 'Test' is defined multiple times in variables.yaml.");
}
}
Loading