CssMediaRule extends CssNestedAtRule { @Override public List<CssRuleSet> getCssRuleSets(INode element, MediaDeviceDescription deviceDescription) { List<CssRuleSet> result = new ArrayList<>(); for (MediaQuery mediaQuery : mediaQueries) { if (mediaQuery.matches(deviceDescription)) { for (CssStatement childStatement : body) { result.addAll(childStatement.getCssRuleSets(element, deviceDescription)); } break; } } return result; } CssMediaRule(String ruleParameters); @Override List<CssRuleSet> getCssRuleSets(INode element, MediaDeviceDescription deviceDescription); boolean matchMediaDevice(MediaDeviceDescription deviceDescription);  }
@Test public void getCssRuleSetsTest() { MediaDeviceDescription deviceDescription = new MediaDeviceDescription("all"); String html = "<a id=\"123\" class=\"baz = 'bar'\" style = media= all and (min-width: 600px) />"; IDocumentNode node = new JsoupHtmlParser().parse(html); List<CssRuleSet> ruleSets = new CssMediaRule("only all and (min-width: 600px) and (min-height: 600px)").getCssRuleSets(node, deviceDescription); Assert.assertNotNull(ruleSets); }