public void testMergeRequirements_findsDuplicates() { Compiler compiler = createCompiler(); ErrorManager errorManager = new BlackHoleErrorManager(); compiler.setErrorManager(errorManager); ConformanceConfig.Builder builder = ConformanceConfig.newBuilder(); builder.addRequirementBuilder().addWhitelist("x").addWhitelist("x"); CheckConformance.mergeRequirements(compiler, ImmutableList.of(builder.build())); assertEquals(1, errorManager.getErrorCount()); }
public void testMergeRequirements() { Compiler compiler = createCompiler(); ConformanceConfig.Builder builder = ConformanceConfig.newBuilder(); builder.addRequirementBuilder().setRuleId("a").addWhitelist("x").addWhitelistRegexp("m"); builder.addRequirementBuilder().setExtends("a").addWhitelist("y").addWhitelistRegexp("n"); List<Requirement> requirements = CheckConformance.mergeRequirements(compiler, ImmutableList.of(builder.build())); assertThat(requirements).hasSize(1); Requirement requirement = requirements.get(0); assertEquals(2, requirement.getWhitelistCount()); assertEquals(2, requirement.getWhitelistRegexpCount()); }