public List testCompatibility()

in src/main/java/com/amazonaws/schemamanager/analyze/SchemaAnalyzerImpl.java [182:221]


	public List<ValidationError> testCompatibility(List<RepoSchema> newSchemas, List<Subject> registrySchemas) {
		
		Map<String, List<RepoSchema>> repoSubjects = new HashMap<>();
		newSchemas.forEach(s -> {
			RepoUtils.schemaToSubjectMap(s, repoSubjects);
		});
		
		Map<String, List<Subject>> regSubjectsMap = new HashMap<>();
		registrySchemas.forEach(regSubj -> {
			regSubjectsMap.computeIfAbsent(regSubj.getName(), n -> new LinkedList<Subject>()).add(regSubj);
		});
		
		List<ValidationError> errors = new LinkedList<>();
		
		repoSubjects.forEach((subj, repoSchemas) ->{
			List<Subject> regSubjects = regSubjectsMap.get(subj);
			if (regSubjects == null || regSubjects.isEmpty()) {
				// new Subject scenario. no errors
				log.info("New subject in repo: " + subj);
			}else {
				repoSchemas.forEach(repoSchema -> {
					CompatibilityLevel compLevel = repoSchema.getMetadata().getCompatibilityLevel(subj);
					regSubjects.forEach(regSubject -> {
						List<String> compIssues = repoSchema.getSchema().isCompatible(compLevel, regSubject.getSchemas());
						if (compIssues != null && !compIssues.isEmpty()) {
							compIssues.forEach(issue -> errors.add(new ValidationError(
									"Compatibility error. Path: %s, subject: %s, compatibility: %s. Error: %s", 
									repoSchema.getPath(),
									subj,
									compLevel,
									issue
									)));
						}
					});
				});
			}
		});
		
		return errors;
	}