### Question:
PmdRuleSets { public static PmdRuleSet from(Reader configReader, ValidationMessages messages) { return createQuietly(new XmlRuleSetFactory(configReader, messages)); }  static PmdRuleSet from(Reader configReader, ValidationMessages messages); static PmdRuleSet from(ActiveRules activeRules, String repositoryKey); static PmdRuleSet from(RulesProfile rulesProfile, String repositoryKey);  }### Answer:
@Test void whenClosingTheResourceAfterParsingFailsThenReturnsResultQuietly() { final Reader mockReader = mock(Reader.class, invocationOnMock -> { throw new IOException(); }); final PmdRuleSet result = PmdRuleSets.from(mockReader, messages); assertThat(result) .isNotNull() .extracting("rules") .asList() .isEmpty(); }
@Test void whenActiveRulesGivenThenRuleSetIsReturned() { final ActiveRules mockedRules = mock(ActiveRules.class); final String anyRepoKey = "TEST"; final PmdRuleSet result = PmdRuleSets.from(mockedRules, anyRepoKey); assertThat(result) .isNotNull(); }
@Test void whenRulesProfileGivenThenRuleSetIsReturned() { final RulesProfile mockedProfile = mock(RulesProfile.class); final String anyRepoKey = "TEST"; final PmdRuleSet result = PmdRuleSets.from(mockedProfile, anyRepoKey); assertThat(result) .isNotNull(); }
@Test void whenClosingTheResourceAfterParsingFailsThenReturnsResultQuietly() { final Reader mockReader = mock(Reader.class, invocationOnMock -> { throw new IOException(); }); final PmdRuleSet result = PmdRuleSets.from(mockReader, messages); assertThat(result) .isNotNull() .extracting("rules") .element(0) .asList() .isEmpty(); }